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.
This commit is contained in:
Andy Clayton 2018-07-03 13:17:10 -05:00
parent 72f123c0b5
commit 0750429992
2 changed files with 6 additions and 1 deletions

View file

@ -203,7 +203,8 @@ def get(name, import_str=False):
default_value.update(value) default_value.update(value)
value = default_value value = default_value
else: else:
value = value or default_value if value is None:
value = default_value
value = import_from_str(value) if import_str else value value = import_from_str(value) if import_str else value
return value return value

View file

@ -23,3 +23,7 @@ class SettingsTest(TestCase):
key1 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY') key1 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY')
key2 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY') key2 = settings.get('OIDC_UNAUTHENTICATED_SESSION_MANAGEMENT_KEY')
self.assertEqual(key1, key2) 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'))