Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock callback validation flag should be inverse of DEBUG #88

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading