mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix failing tests for YAML SDB module
This commit is contained in:
parent
5980860f06
commit
de5cdde2c1
2 changed files with 10 additions and 4 deletions
|
@ -73,13 +73,12 @@ def get(key, profile=None): # pylint: disable=W0613
|
|||
Get a value from the dictionary
|
||||
'''
|
||||
data = _get_values(profile)
|
||||
gpgrender = salt.loader.render(__opts__, __salt__)['gpg']
|
||||
|
||||
# Decrypt SDB data if specified in the profile
|
||||
if profile and profile.get('gpg', False):
|
||||
return salt.utils.data.traverse_dict_and_list(gpgrender(data), key, None)
|
||||
return salt.utils.data.traverse_dict_and_list(_decrypt(data), key, None)
|
||||
|
||||
return salt.utils.traverse_dict_and_list(data, key, None)
|
||||
return salt.utils.data.traverse_dict_and_list(data, key, None)
|
||||
|
||||
|
||||
def _get_values(profile=None):
|
||||
|
@ -101,3 +100,10 @@ def _get_values(profile=None):
|
|||
except TypeError:
|
||||
log.error("Error deserializing sdb file '{0}'".format(fname))
|
||||
return ret
|
||||
|
||||
|
||||
def _decrypt(data):
|
||||
'''
|
||||
Pass the dictionary through the GPG renderer to decrypt encrypted values.
|
||||
'''
|
||||
return salt.loader.render(__opts__, __salt__)['gpg'](data)
|
||||
|
|
|
@ -45,6 +45,6 @@ class TestYamlRenderer(TestCase):
|
|||
Assume the content is plaintext if GPG is not configured
|
||||
'''
|
||||
plain = {'foo': 'bar'}
|
||||
with patch('salt.renderers.gpg.render', MagicMock(return_value=plain)):
|
||||
with patch('salt.sdb.yaml._decrypt', MagicMock(return_value=plain)):
|
||||
with patch('salt.sdb.yaml._get_values', MagicMock(return_value=None)):
|
||||
self.assertEqual(sdb.get('foo', profile={'gpg': True}), 'bar')
|
||||
|
|
Loading…
Add table
Reference in a new issue