Fix #908: updating configuration without secrets was failing

This commit is contained in:
Arik Fraimovich 2016-03-10 11:56:49 +02:00
parent 6104e5df3c
commit 33a5e06eb1
2 changed files with 9 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class ConfigurationContainer(object):
return self._config.iteritems()
def to_dict(self, mask_secrets=False):
if (mask_secrets is False or 'secret' not in self.schema):
if mask_secrets is False or 'secret' not in self.schema:
return self._config
config = self._config.copy()
@ -53,7 +53,7 @@ class ConfigurationContainer(object):
config = {}
for k, v in new_config.iteritems():
if k in self.schema['secret'] and v == SECRET_PLACEHOLDER:
if k in self.schema.get('secret', []) and v == SECRET_PLACEHOLDER:
config[k] = self[k]
else:
config[k] = v

View File

@ -74,3 +74,10 @@ class TestConfigurationUpdate(TestCase):
self.assertEqual(container['a'], 1)
self.assertEqual('test', container['b'])
self.assertNotIn('e', container)
def test_works_for_schema_without_secret(self):
secretless = configuration_schema.copy()
secretless.pop('secret')
container = ConfigurationContainer({'a': 1, 'b': 'test', 'e': 3}, secretless)
container.update({'a': 2})
self.assertEqual(container['a'], 2)