summaryrefslogtreecommitdiff
path: root/keymanager
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2014-10-08 19:28:33 -0500
committerRuben Pollan <meskio@sindominio.net>2014-10-09 10:22:08 -0500
commitca81004d13ef48206b860cf4ff70e8bbdfbc61af (patch)
treef8ab2461b07a8078dc30901bdc32d4b4958c8755 /keymanager
parent242d903cd39fbb81a492406b8b8a53df46087d12 (diff)
Accept ascii keys on put_key
Diffstat (limited to 'keymanager')
-rw-r--r--keymanager/changes/feature-put_key_ascii1
-rw-r--r--keymanager/src/leap/keymanager/__init__.py9
-rw-r--r--keymanager/src/leap/keymanager/tests/test_keymanager.py11
3 files changed, 18 insertions, 3 deletions
diff --git a/keymanager/changes/feature-put_key_ascii b/keymanager/changes/feature-put_key_ascii
new file mode 100644
index 0000000..78f2907
--- /dev/null
+++ b/keymanager/changes/feature-put_key_ascii
@@ -0,0 +1 @@
+- KeyManager.put_key now accepts also ascii keys
diff --git a/keymanager/src/leap/keymanager/__init__.py b/keymanager/src/leap/keymanager/__init__.py
index bd85c2d..da679ac 100644
--- a/keymanager/src/leap/keymanager/__init__.py
+++ b/keymanager/src/leap/keymanager/__init__.py
@@ -515,11 +515,14 @@ class KeyManager(object):
"""
Put C{key} in local storage.
- :param key: The key to be stored.
- :type key: OpenPGPKey
+ :param key: The key to be stored. It can be ascii key or an OpenPGPKey
+ :type key: str or OpenPGPKey
"""
try:
- self._wrapper_map[type(key)].put_key(key)
+ if isinstance(key, basestring):
+ self._wrapper_map[OpenPGPKey].put_ascii_key(key)
+ else:
+ self._wrapper_map[type(key)].put_key(key)
except IndexError as e:
leap_assert(False, "Unsupported key type. Error {0!r}".format(e))
diff --git a/keymanager/src/leap/keymanager/tests/test_keymanager.py b/keymanager/src/leap/keymanager/tests/test_keymanager.py
index 7192bfb..39b729d 100644
--- a/keymanager/src/leap/keymanager/tests/test_keymanager.py
+++ b/keymanager/src/leap/keymanager/tests/test_keymanager.py
@@ -466,6 +466,17 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
self.assertIsInstance(key, OpenPGPKey)
self.assertEqual(ADDRESS, key.address)
+ def test_put_key_ascii(self):
+ """
+ Test that putting ascii key works
+ """
+ km = self._key_manager(url='http://nickserver.domain')
+
+ km.put_key(PUBLIC_KEY)
+ key = km.get_key(ADDRESS, OpenPGPKey)
+ self.assertIsInstance(key, OpenPGPKey)
+ self.assertEqual(ADDRESS, key.address)
+
class KeyManagerCryptoTestCase(KeyManagerWithSoledadTestCase):