2015-05-15 09:41:15 +00:00
|
|
|
"""
|
|
|
|
|
Settings file for the Auditlog test suite.
|
|
|
|
|
"""
|
2024-02-10 20:18:46 +00:00
|
|
|
|
2020-04-22 21:00:12 +00:00
|
|
|
import os
|
2015-05-15 09:41:15 +00:00
|
|
|
|
2020-08-31 11:57:10 +00:00
|
|
|
DEBUG = True
|
|
|
|
|
|
2020-12-06 20:29:24 +00:00
|
|
|
SECRET_KEY = "test"
|
2015-05-15 09:41:15 +00:00
|
|
|
|
2025-08-17 14:50:23 +00:00
|
|
|
TEST_DB_BACKEND = os.getenv("TEST_DB_BACKEND", "sqlite3")
|
|
|
|
|
|
2015-05-15 09:41:15 +00:00
|
|
|
INSTALLED_APPS = [
|
2020-12-06 20:29:24 +00:00
|
|
|
"django.contrib.auth",
|
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
|
"django.contrib.messages",
|
|
|
|
|
"django.contrib.sessions",
|
|
|
|
|
"django.contrib.admin",
|
|
|
|
|
"django.contrib.staticfiles",
|
2025-06-23 18:34:16 +00:00
|
|
|
"django.contrib.postgres",
|
2025-11-19 08:46:43 +00:00
|
|
|
"custom_logentry_app",
|
2020-12-06 20:29:24 +00:00
|
|
|
"auditlog",
|
2025-03-19 16:28:43 +00:00
|
|
|
"test_app",
|
2015-05-15 09:41:15 +00:00
|
|
|
]
|
|
|
|
|
|
2025-08-17 14:50:23 +00:00
|
|
|
|
2022-06-28 16:56:36 +00:00
|
|
|
MIDDLEWARE = [
|
2020-12-06 20:29:24 +00:00
|
|
|
"django.middleware.common.CommonMiddleware",
|
|
|
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
|
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
|
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
2022-06-28 16:56:36 +00:00
|
|
|
]
|
2015-05-15 09:41:15 +00:00
|
|
|
|
2025-11-19 08:46:43 +00:00
|
|
|
if os.environ.get("AUDITLOG_LOGENTRY_MODEL", None):
|
|
|
|
|
MIDDLEWARE = MIDDLEWARE + ["auditlog.middleware.AuditlogMiddleware"]
|
|
|
|
|
else:
|
|
|
|
|
MIDDLEWARE = MIDDLEWARE + ["middleware.CustomAuditlogMiddleware"]
|
|
|
|
|
|
|
|
|
|
|
2025-08-17 14:50:23 +00:00
|
|
|
if TEST_DB_BACKEND == "postgresql":
|
|
|
|
|
DATABASES = {
|
|
|
|
|
"default": {
|
|
|
|
|
"ENGINE": "django.db.backends.postgresql",
|
|
|
|
|
"NAME": os.getenv(
|
|
|
|
|
"TEST_DB_NAME", "auditlog" + os.environ.get("TOX_PARALLEL_ENV", "")
|
|
|
|
|
),
|
|
|
|
|
"USER": os.getenv("TEST_DB_USER", "postgres"),
|
|
|
|
|
"PASSWORD": os.getenv("TEST_DB_PASS", ""),
|
|
|
|
|
"HOST": os.getenv("TEST_DB_HOST", "127.0.0.1"),
|
|
|
|
|
"PORT": os.getenv("TEST_DB_PORT", "5432"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elif TEST_DB_BACKEND == "mysql":
|
|
|
|
|
DATABASES = {
|
|
|
|
|
"default": {
|
|
|
|
|
"ENGINE": "django.db.backends.mysql",
|
|
|
|
|
"NAME": os.getenv(
|
|
|
|
|
"TEST_DB_NAME", "auditlog" + os.environ.get("TOX_PARALLEL_ENV", "")
|
|
|
|
|
),
|
|
|
|
|
"USER": os.getenv("TEST_DB_USER", "root"),
|
|
|
|
|
"PASSWORD": os.getenv("TEST_DB_PASS", ""),
|
|
|
|
|
"HOST": os.getenv("TEST_DB_HOST", "127.0.0.1"),
|
|
|
|
|
"PORT": os.getenv("TEST_DB_PORT", "3306"),
|
|
|
|
|
"OPTIONS": {
|
|
|
|
|
"charset": "utf8mb4",
|
|
|
|
|
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elif TEST_DB_BACKEND == "sqlite3":
|
|
|
|
|
DATABASES = {
|
|
|
|
|
"default": {
|
|
|
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
|
|
|
"NAME": os.getenv(
|
|
|
|
|
"TEST_DB_NAME",
|
|
|
|
|
(
|
|
|
|
|
":memory:"
|
|
|
|
|
if os.getenv("TOX_PARALLEL_ENV")
|
|
|
|
|
else "test_auditlog.sqlite3"
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
}
|
2015-05-15 09:41:15 +00:00
|
|
|
}
|
2025-08-17 14:50:23 +00:00
|
|
|
else:
|
|
|
|
|
raise ValueError(f"Unsupported database backend: {TEST_DB_BACKEND}")
|
2016-01-23 20:41:19 +00:00
|
|
|
|
2018-01-04 16:49:39 +00:00
|
|
|
TEMPLATES = [
|
|
|
|
|
{
|
2020-12-06 20:29:24 +00:00
|
|
|
"APP_DIRS": True,
|
|
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
|
|
|
"DIRS": [],
|
|
|
|
|
"OPTIONS": {
|
|
|
|
|
"context_processors": [
|
|
|
|
|
"django.template.context_processors.request",
|
|
|
|
|
"django.contrib.auth.context_processors.auth",
|
|
|
|
|
"django.contrib.messages.context_processors.messages",
|
2018-01-04 16:49:39 +00:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
2020-12-06 20:29:24 +00:00
|
|
|
STATIC_URL = "/static/"
|
2020-08-31 11:57:10 +00:00
|
|
|
|
2025-03-19 16:28:43 +00:00
|
|
|
ROOT_URLCONF = "test_app.urls"
|
2017-01-11 19:07:10 +00:00
|
|
|
|
|
|
|
|
USE_TZ = True
|
2021-05-24 21:22:34 +00:00
|
|
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
2025-11-19 08:46:43 +00:00
|
|
|
|
|
|
|
|
AUDITLOG_LOGENTRY_MODEL = os.environ.get("AUDITLOG_LOGENTRY_MODEL", "auditlog.LogEntry")
|