Skip to content

Commit

Permalink
✅[#114] use setup config management command
Browse files Browse the repository at this point in the history
  • Loading branch information
Coperh committed Aug 14, 2024
1 parent 8761799 commit 68d3a61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,16 @@
LOGIN_REDIRECT_URL = reverse_lazy("admin:index")

STATIC_URL = "/static/"

# Django setup configuration settings
try:
import django_setup_configuration

INSTALLED_APPS += ["django_setup_configuration"]

OIDC_DB_CONFIG_ENABLE = True
SETUP_CONFIGURATION_STEPS = [
"mozilla_django_oidc_db.setupconfig.bootstrap.AdminOIDCConfigurationStep",
]
except ImportError:
pass
12 changes: 6 additions & 6 deletions tests/setupconfig/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.test import override_settings
from django.core.management import call_command

import pytest
import requests
Expand All @@ -8,14 +8,14 @@
OpenIDConnectConfig,
UserInformationClaimsSources,
)
from mozilla_django_oidc_db.setupconfig.boostrap import AdminOIDCConfigurationStep
from mozilla_django_oidc_db.setupconfig.bootstrap import AdminOIDCConfigurationStep

from ..conftest import KEYCLOAK_BASE_URL


@pytest.mark.django_db
def test_configure(setup_config_full):
AdminOIDCConfigurationStep().configure()
call_command("setup_configuration")

config = OpenIDConnectConfig.get_solo()

Expand Down Expand Up @@ -61,6 +61,7 @@ def test_configure(setup_config_full):

@pytest.mark.django_db
def test_configure_use_defaults(setup_config_defaults):
call_command("setup_configuration")

AdminOIDCConfigurationStep().configure()

Expand Down Expand Up @@ -110,8 +111,7 @@ def test_configure_use_defaults(setup_config_defaults):
@pytest.mark.vcr
@pytest.mark.django_db
def test_configure_use_discovery_endpoint(setup_config_discovery):

AdminOIDCConfigurationStep().configure()
call_command("setup_configuration")

config = OpenIDConnectConfig.get_solo()

Expand All @@ -136,7 +136,7 @@ def test_configure_use_discovery_endpoint(setup_config_discovery):


@pytest.mark.django_db
def test_configure_failure(requests_mock, setup_config_discovery):
def test_configure_discovery_failure(requests_mock, setup_config_discovery):
mock_kwargs = (
{"exc": requests.ConnectTimeout},
{"exc": requests.ConnectionError},
Expand Down

0 comments on commit 68d3a61

Please sign in to comment.