summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-11-21 12:07:10 +0100
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:30 +0100
commit0454dc3545693a8c6325f4864d89154c514b3bcb (patch)
tree157a12a02cccca3184814ba8b059a8648b2cea54 /tests
parente5c567d79557eecbd708f4fabe8d04c92cf66ea1 (diff)
[feat] reset sign_used flag after regenerating key pair
- this flag is used by leap.mail to attach the new key
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/keymanager/test_keymanager.py12
-rw-r--r--tests/integration/keymanager/test_openpgp.py27
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/integration/keymanager/test_keymanager.py b/tests/integration/keymanager/test_keymanager.py
index 4e6d62c8..e11e19b8 100644
--- a/tests/integration/keymanager/test_keymanager.py
+++ b/tests/integration/keymanager/test_keymanager.py
@@ -577,6 +577,18 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
self.assertIn(old_key.fingerprint[-16:], renewed_public_key.signatures)
@defer.inlineCallbacks
+ def test_key_regenerate_resets_all_public_key_sign_used(self):
+ km = self._key_manager(user=ADDRESS_EXPIRING)
+
+ yield km._openpgp.put_raw_key(PRIVATE_EXPIRING_KEY, ADDRESS_EXPIRING)
+ yield km._openpgp.put_raw_key(PUBLIC_KEY_2, ADDRESS_2)
+ km._openpgp.reset_all_keys_sign_used = mock.Mock()
+
+ yield km.regenerate_key()
+
+ km._openpgp.reset_all_keys_sign_used.assert_called_once()
+
+ @defer.inlineCallbacks
def test_key_extension_with_invalid_period_throws_exception(self):
km = self._key_manager(user=ADDRESS_EXPIRING)
diff --git a/tests/integration/keymanager/test_openpgp.py b/tests/integration/keymanager/test_openpgp.py
index d04f5d01..d994f801 100644
--- a/tests/integration/keymanager/test_openpgp.py
+++ b/tests/integration/keymanager/test_openpgp.py
@@ -100,6 +100,33 @@ class OpenPGPCryptoTestCase(KeyManagerWithSoledadTestCase):
yield self._assert_key_not_found(pgp, ADDRESS)
@inlineCallbacks
+ def test_reset_sign_used_for_all_keys(self):
+ pgp = openpgp.OpenPGPScheme(
+ self._soledad, gpgbinary=self.gpg_binary_path)
+
+ yield pgp.put_raw_key(PRIVATE_KEY, ADDRESS)
+ yield pgp.put_raw_key(PUBLIC_KEY, ADDRESS)
+ yield pgp.put_raw_key(PUBLIC_KEY_2, ADDRESS_2)
+ pubkey = yield pgp.get_key(ADDRESS)
+ pubkey.sign_used = True
+ yield pgp.put_key(pubkey)
+ pubkey2 = yield pgp.get_key(ADDRESS_2)
+ pubkey2.sign_used = True
+ yield pgp.put_key(pubkey2)
+
+ yield pgp.reset_all_keys_sign_used()
+
+ pubkey_refetched = yield pgp.get_key(ADDRESS)
+ pubkey2_refetched = yield pgp.get_key(ADDRESS_2)
+
+ self.assertEqual(False, pubkey_refetched.sign_used)
+ self.assertEqual(False, pubkey2_refetched.sign_used)
+ self.assertEqual(pubkey.fingerprint, pubkey_refetched.fingerprint)
+ self.assertEqual(pubkey.key_data, pubkey_refetched.key_data)
+ self.assertEqual(pubkey2.fingerprint, pubkey2_refetched.fingerprint)
+ self.assertEqual(pubkey2.key_data, pubkey2_refetched.key_data)
+
+ @inlineCallbacks
def test_openpgp_encrypt_decrypt(self):
data = 'data'
pgp = openpgp.OpenPGPScheme(