summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/src/leap/soledad/client/_secrets/crypto.py2
-rw-r--r--testing/tests/client/test_secrets.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/client/src/leap/soledad/client/_secrets/crypto.py b/client/src/leap/soledad/client/_secrets/crypto.py
index afa80034..8148151d 100644
--- a/client/src/leap/soledad/client/_secrets/crypto.py
+++ b/client/src/leap/soledad/client/_secrets/crypto.py
@@ -72,7 +72,7 @@ class SecretsCrypto(object):
#
def decrypt(self, data):
- version = data.get('version', 1)
+ version = data.setdefault('version', 1)
method = getattr(self, '_decrypt_v%d' % version)
try:
return method(data)
diff --git a/testing/tests/client/test_secrets.py b/testing/tests/client/test_secrets.py
index 7c909bcb..7b643cb4 100644
--- a/testing/tests/client/test_secrets.py
+++ b/testing/tests/client/test_secrets.py
@@ -158,8 +158,9 @@ class SecretsCryptoTestCase(unittest.TestCase):
decrypted = self._crypto.decrypt(encrypted)
self.assertEqual(decrypted, self.SECRETS)
- def test__decrypt_v1_without_version_field(self):
+ def test__no_version_defaults_to_v1(self):
encrypted = dict(self.ENCRYPTED_V1)
del encrypted['version']
decrypted = self._crypto.decrypt(encrypted)
self.assertEqual(decrypted, self.SECRETS)
+ self.assertEqual(encrypted['version'], 1)