From a0ebd51f6256bd069b16b65ba5bc613231ab93da Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 22 Dec 2022 11:45:07 +0100 Subject: [PATCH] Configured Github workflows to use CI settings --- .github/workflows/ci.yml | 2 +- src/open_inwoner/conf/ci.py | 51 ++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7cae9b9a0..327d6129aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,7 @@ jobs: python src/manage.py collectstatic --noinput --link coverage run src/manage.py test src env: - DJANGO_SETTINGS_MODULE: open_inwoner.conf.dev + DJANGO_SETTINGS_MODULE: open_inwoner.conf.ci SECRET_KEY: dummy DB_USER: postgres DB_PASSWORD: '' diff --git a/src/open_inwoner/conf/ci.py b/src/open_inwoner/conf/ci.py index cafbe89f4d..86212e1be1 100644 --- a/src/open_inwoner/conf/ci.py +++ b/src/open_inwoner/conf/ci.py @@ -1,4 +1,5 @@ import os +import warnings os.environ.setdefault("DEBUG", "no") os.environ.setdefault("ENVIRONMENT", "ci") @@ -8,7 +9,6 @@ from .base import * # noqa isort:skip - LOGGING["loggers"].update( { "django": { @@ -19,12 +19,49 @@ } ) +CACHES.update( + { + "default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, + # See: https://github.com/jazzband/django-axes/blob/master/docs/configuration.rst#cache-problems + "axes": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}, + "oidc": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, + } +) -# in memory cache and django-axes don't get along. -# https://django-axes.readthedocs.io/en/latest/configuration.html#known-configuration-problems -CACHES = { - "default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, - "axes": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}, -} +# Allow logging in with both username+password and email+password +AUTHENTICATION_BACKENDS = [ + "open_inwoner.accounts.backends.CustomAxesBackend", + "open_inwoner.accounts.backends.UserModelEmailBackend", + "django.contrib.auth.backends.ModelBackend", + # mock login like dev.py + "digid_eherkenning.mock.backends.DigiDBackend", + "open_inwoner.accounts.backends.CustomOIDCBackend", +] ELASTIC_APM["DEBUG"] = True + +ELASTICSEARCH_DSL_AUTO_REFRESH = False +ELASTICSEARCH_DSL_AUTOSYNC = False +ES_INDEX_PRODUCTS = "products_test" + +ENVIRONMENT = "CI" + +# +# Django-axes +# +AXES_BEHIND_REVERSE_PROXY = False + +# Django privates +SENDFILE_BACKEND = "django_sendfile.backends.development" + +# Two factor auth +TWO_FACTOR_FORCE_OTP_ADMIN = False +TWO_FACTOR_PATCH_ADMIN = False + +# THOU SHALT NOT USE NAIVE DATETIMES +warnings.filterwarnings( + "error", + r"DateTimeField .* received a naive datetime", + RuntimeWarning, + r"django\.db\.models\.fields", +)