From 075042999258a524a34f5835ac5a9f4aa73c2510 Mon Sep 17 00:00:00 2001 From: Andy Clayton Date: Tue, 3 Jul 2018 13:17:10 -0500 Subject: [PATCH] fix settings to support falsy valued overrides Up until recently there were settings with truthy defaults but with no need to be set to a false value. That changed with OIDC_INTROSPECTION_VALIDATE_AUDIENCE_SCOPE. Now there is a setting that has both a true default and a meaningful false value, and without this fix that setting cannot be changed making it not much of a setting at all. --- oidc_provider/settings.py | 3 ++- oidc_provider/tests/cases/test_settings.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/oidc_provider/settings.py b/oidc_provider/settings.py index 1fddbfa..6d0607e 100644 --- a/oidc_provider/settings.py +++ b/oidc_provider/settings.py @@ -203,7 +203,8 @@ def get(name, import_str=False): default_value.update(value) value = default_value else: - value = value or default_value + if value is None: + value = default_value value = import_from_str(value) if import_str else value return value diff --git a/oidc_provider/tests/cases/test_settings.py b/oidc_provider/tests/cases/test_settings.py index e8c252a..00510bf 100644 --- a/oidc_provider/tests/cases/test_settings.py +++ b/oidc_provider/tests/cases/test_settings.py @@ -23,3 +23,7 @@ class SettingsTest(TestCase): key1 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY') key2 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY') self.assertEqual(key1, key2) + + @override_settings(OIDC_INTROSPECTION_VALIDATE_AUDIENCE_SCOPE=False) + def test_can_override_with_false_value(self): + self.assertFalse(settings.get('OIDC_INTROSPECTION_VALIDATE_AUDIENCE_SCOPE'))