summaryrefslogtreecommitdiff
path: root/src/leap/keymanager/tests/test_keymanager.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/keymanager/tests/test_keymanager.py')
-rw-r--r--src/leap/keymanager/tests/test_keymanager.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/leap/keymanager/tests/test_keymanager.py b/src/leap/keymanager/tests/test_keymanager.py
index 39b729d..65f8f39 100644
--- a/src/leap/keymanager/tests/test_keymanager.py
+++ b/src/leap/keymanager/tests/test_keymanager.py
@@ -28,6 +28,7 @@ from leap.keymanager import (
KeyManager,
openpgp,
KeyNotFound,
+ KeyAttributesDiffer,
errors,
)
from leap.keymanager.openpgp import OpenPGPKey
@@ -477,6 +478,55 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
self.assertIsInstance(key, OpenPGPKey)
self.assertEqual(ADDRESS, key.address)
+ def test_fetch_uri_ascii_key(self):
+ """
+ Test that fetch key downloads the ascii key and gets included in
+ the local storage
+ """
+ km = self._key_manager()
+
+ class Response(object):
+ ok = True
+ content = PUBLIC_KEY
+
+ km._fetcher.get = Mock(return_value=Response())
+ km.ca_cert_path = 'cacertpath'
+
+ km.fetch_key(ADDRESS, "http://site.domain/key", OpenPGPKey)
+ key = km.get_key(ADDRESS, OpenPGPKey)
+ self.assertEqual(KEY_FINGERPRINT, key.fingerprint)
+
+ def test_fetch_uri_empty_key(self):
+ """
+ Test that fetch key raises KeyNotFound if no key in the url
+ """
+ km = self._key_manager()
+
+ class Response(object):
+ ok = True
+ content = ""
+
+ km._fetcher.get = Mock(return_value=Response())
+ km.ca_cert_path = 'cacertpath'
+ self.assertRaises(KeyNotFound, km.fetch_key,
+ ADDRESS, "http://site.domain/key", OpenPGPKey)
+
+ def test_fetch_uri_address_differ(self):
+ """
+ Test that fetch key raises KeyAttributesDiffer if the address
+ don't match
+ """
+ km = self._key_manager()
+
+ class Response(object):
+ ok = True
+ content = PUBLIC_KEY
+
+ km._fetcher.get = Mock(return_value=Response())
+ km.ca_cert_path = 'cacertpath'
+ self.assertRaises(KeyAttributesDiffer, km.fetch_key,
+ ADDRESS_2, "http://site.domain/key", OpenPGPKey)
+
class KeyManagerCryptoTestCase(KeyManagerWithSoledadTestCase):