Skip to content

Commit

Permalink
✅ Add test for falsy dynamic setting default
Browse files Browse the repository at this point in the history
and add missing testapp migrations
  • Loading branch information
stevenbal committed Jul 2, 2024
1 parent fb22256 commit 9cdd3c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions testapp/migrations/0003_remove_emptyconfig_oidc_exempt_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.2 on 2024-07-02 07:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("testapp", "0002_emptyconfig_oidc_keycloak_idp_hint_and_more"),
]

operations = [
migrations.RemoveField(
model_name="emptyconfig",
name="oidc_exempt_urls",
),
]
15 changes: 15 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from mozilla_django_oidc_db.backends import OIDCAuthenticationBackend
from mozilla_django_oidc_db.config import lookup_config
from mozilla_django_oidc_db.middleware import SessionRefresh
from mozilla_django_oidc_db.models import OpenIDConnectConfig
from mozilla_django_oidc_db.views import OIDCAuthenticationRequestView

Expand Down Expand Up @@ -74,3 +75,17 @@ def test_view_settings_derived_from_model_oidc_enabled(
# verify that the settings are derived from OpenIDConnectConfig
assert view.OIDC_RP_CLIENT_ID == "testid"
assert view.OIDC_OP_AUTH_ENDPOINT == "http://some.endpoint/v1/auth"


@pytest.mark.oidcconfig(
enabled=True,
oidc_rp_client_id="testid",
oidc_op_authorization_endpoint="http://some.endpoint/v1/auth",
)
def test_middleware_use_falsy_default(
dummy_config: OpenIDConnectConfig,
):
middleware = SessionRefresh(lambda x: x)

# verify that the defaults are allowed
assert middleware.OIDC_EXEMPT_URLS == []

0 comments on commit 9cdd3c6

Please sign in to comment.