Skip to content

Commit

Permalink
Merge pull request #88 from maykinmedia/85-fix-mock-callback-validate…
Browse files Browse the repository at this point in the history
…-flag

Mock callback validation flag should be inverse of DEBUG
  • Loading branch information
swrichards authored Jan 9, 2025
2 parents 70741df + f158bfd commit 7a99838
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion digid_eherkenning/mock/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def should_validate_idp_callback_urls() -> bool:
"""
Whether to validate that the `next_url` and `cancel_urls` are safe
"""
flag = getattr(settings, "DIGID_MOCK_IDP_VALIDATE_CALLBACK_URLS", settings.DEBUG)
flag = getattr(
settings, "DIGID_MOCK_IDP_VALIDATE_CALLBACK_URLS", not settings.DEBUG
)
if not isinstance(flag, bool):
raise ImproperlyConfigured(
"DIGID_MOCK_IDP_VALIDATE_CALLBACK_URLS should be a boolean"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mock_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ def test_conf_setting_must_be_a_bool(self):
should_validate_idp_callback_urls()

@override_settings()
def test_conf_setting_defaults_to_debug_flag(self):
def test_conf_setting_defaults_to_inverse_of_debug_flag(self):
del settings.DIGID_MOCK_IDP_VALIDATE_CALLBACK_URLS

with override_settings(DEBUG=True):
with override_settings(DEBUG=False):
self.assertTrue(should_validate_idp_callback_urls())

with override_settings(DEBUG=False):
with override_settings(DEBUG=True):
self.assertFalse(should_validate_idp_callback_urls())


Expand Down

0 comments on commit 7a99838

Please sign in to comment.