summaryrefslogtreecommitdiff
path: root/src/leap/common/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/common/tests')
-rw-r--r--src/leap/common/tests/test_keymanager.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/leap/common/tests/test_keymanager.py b/src/leap/common/tests/test_keymanager.py
index 1d7a382..d3dee40 100644
--- a/src/leap/common/tests/test_keymanager.py
+++ b/src/leap/common/tests/test_keymanager.py
@@ -169,7 +169,7 @@ class KeyManagerWithSoledadTestCase(BaseLeapTest):
class OpenPGPCryptoTestCase(KeyManagerWithSoledadTestCase):
- def test_openpgp_gen_key(self):
+ def _test_openpgp_gen_key(self):
pgp = openpgp.OpenPGPScheme(self._soledad)
self.assertRaises(KeyNotFound, pgp.get_key, 'user@leap.se')
key = pgp.gen_key('user@leap.se')
@@ -363,6 +363,34 @@ class KeyManagerKeyManagementTestCase(
'leap@leap.se'
)
+ def test_verify_with_private_raises(self):
+ km = self._key_manager()
+ km._wrapper_map[OpenPGPKey].put_key_raw(PRIVATE_KEY)
+ data = 'data'
+ privkey = km.get_key(ADDRESS, OpenPGPKey, private=True)
+ signed = openpgp.sign(data, privkey)
+ self.assertRaises(
+ AssertionError,
+ openpgp.verify, signed, privkey)
+
+ def test_sign_with_public_raises(self):
+ km = self._key_manager()
+ km._wrapper_map[OpenPGPKey].put_key_raw(PUBLIC_KEY)
+ data = 'data'
+ pubkey = km.get_key(ADDRESS, OpenPGPKey, private=False)
+ self.assertRaises(
+ AssertionError,
+ openpgp.sign, data, pubkey)
+
+ def test_sign_verify(self):
+ km = self._key_manager()
+ km._wrapper_map[OpenPGPKey].put_key_raw(PRIVATE_KEY)
+ data = 'data'
+ privkey = km.get_key(ADDRESS, OpenPGPKey, private=True)
+ signed = openpgp.sign(data, privkey)
+ pubkey = km.get_key(ADDRESS, OpenPGPKey, private=False)
+ self.assertTrue(openpgp.verify(signed, pubkey))
+
# Key material for testing
KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF"