2015-01-03 16:09:30 +00:00
|
|
|
import os
|
2020-11-23 17:54:00 +00:00
|
|
|
|
|
|
|
|
import django
|
2017-06-28 21:09:44 +00:00
|
|
|
from celery import Celery
|
2015-01-03 16:09:30 +00:00
|
|
|
|
2020-11-23 17:54:00 +00:00
|
|
|
|
2019-11-15 18:22:14 +00:00
|
|
|
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:",}}
|
2015-01-01 16:31:28 +00:00
|
|
|
|
2014-12-31 01:17:15 +00:00
|
|
|
|
|
|
|
|
SITE_ID = 1
|
|
|
|
|
|
2019-01-29 12:50:02 +00:00
|
|
|
MIDDLEWARE = (
|
2019-11-15 18:22:14 +00:00
|
|
|
"django.middleware.common.CommonMiddleware",
|
|
|
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
|
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
|
|
|
"defender.middleware.FailedLoginMiddleware",
|
2022-10-11 16:33:05 +00:00
|
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
2014-12-31 01:17:15 +00:00
|
|
|
)
|
|
|
|
|
|
2019-11-15 18:22:14 +00:00
|
|
|
ROOT_URLCONF = "defender.test_urls"
|
2014-12-31 01:17:15 +00:00
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2019-11-15 18:22:14 +00:00
|
|
|
"django.contrib.auth",
|
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
|
"django.contrib.sessions",
|
|
|
|
|
"django.contrib.sites",
|
|
|
|
|
"django.contrib.messages",
|
|
|
|
|
"django.contrib.admin",
|
|
|
|
|
"defender",
|
2014-12-31 01:17:15 +00:00
|
|
|
]
|
|
|
|
|
|
2016-02-01 16:05:17 +00:00
|
|
|
TEMPLATES = [
|
|
|
|
|
{
|
2019-11-15 18:22:14 +00:00
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
|
|
|
"APP_DIRS": True,
|
|
|
|
|
"OPTIONS": {
|
|
|
|
|
"context_processors": [
|
|
|
|
|
"django.contrib.auth.context_processors.auth",
|
|
|
|
|
"django.template.context_processors.debug",
|
|
|
|
|
"django.template.context_processors.i18n",
|
|
|
|
|
"django.template.context_processors.media",
|
|
|
|
|
"django.template.context_processors.static",
|
|
|
|
|
"django.template.context_processors.tz",
|
|
|
|
|
"django.contrib.messages.context_processors.messages",
|
2022-04-13 13:07:29 +00:00
|
|
|
"django.template.context_processors.request",
|
2017-04-14 22:30:58 +00:00
|
|
|
],
|
|
|
|
|
},
|
2016-02-01 16:05:17 +00:00
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
2019-11-15 18:22:14 +00:00
|
|
|
SECRET_KEY = os.environ.get("SECRET_KEY", "too-secret-for-test")
|
2014-12-31 01:17:15 +00:00
|
|
|
|
2019-11-15 18:22:14 +00:00
|
|
|
LOGIN_REDIRECT_URL = "/admin"
|
2014-12-31 01:17:15 +00:00
|
|
|
|
2014-12-31 17:19:06 +00:00
|
|
|
DEFENDER_LOGIN_FAILURE_LIMIT = 10
|
|
|
|
|
DEFENDER_COOLOFF_TIME = 2
|
2015-01-01 17:51:46 +00:00
|
|
|
DEFENDER_REDIS_URL = None
|
|
|
|
|
# use mock redis in unit tests locally.
|
|
|
|
|
DEFENDER_MOCK_REDIS = True
|
2015-01-03 21:33:51 +00:00
|
|
|
|
|
|
|
|
# celery settings
|
|
|
|
|
CELERY_ALWAYS_EAGER = True
|
2019-11-15 18:22:14 +00:00
|
|
|
BROKER_BACKEND = "memory"
|
|
|
|
|
BROKER_URL = "memory://"
|
2015-01-03 21:33:51 +00:00
|
|
|
|
|
|
|
|
# set the default Django settings module for the 'celery' program.
|
2019-11-15 18:22:14 +00:00
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "defender.test_settings")
|
2015-01-03 21:33:51 +00:00
|
|
|
|
2019-11-15 18:22:14 +00:00
|
|
|
app = Celery("defender")
|
2015-01-03 21:33:51 +00:00
|
|
|
|
|
|
|
|
# Using a string here means the worker will not have to
|
|
|
|
|
# pickle the object when using Windows.
|
2019-11-15 18:22:14 +00:00
|
|
|
app.config_from_object("django.conf:settings")
|
2015-01-03 21:33:51 +00:00
|
|
|
app.autodiscover_tasks(lambda: INSTALLED_APPS)
|