summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-11-18 20:22:14 +0100
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:30 +0100
commite5c567d79557eecbd708f4fabe8d04c92cf66ea1 (patch)
tree107f3835eb76b0d1e907e00363699eb75681d1dc /tests
parent3eab1813bfb9efeea65ab3ad9798b8e8dba6d163 (diff)
[feat] first phase of key regeneration
- if current key pair is expired, it'll be extended for a day first - new key pair will be signed by the old key
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/keymanager/test_keymanager.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/integration/keymanager/test_keymanager.py b/tests/integration/keymanager/test_keymanager.py
index 466414a1..4e6d62c8 100644
--- a/tests/integration/keymanager/test_keymanager.py
+++ b/tests/integration/keymanager/test_keymanager.py
@@ -21,7 +21,7 @@ import json
import urllib
import tempfile
import pkg_resources
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, date
from twisted.internet import defer
from twisted.trial import unittest
@@ -554,26 +554,27 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
km.send_key.assert_called_once_with()
@defer.inlineCallbacks
- def test_keymanager_extend_key_expiry_date_for_key_pair(self):
+ def test_key_regenerate_gets_new_expiry_date_and_signed_by_old_key(self):
km = self._key_manager(user=ADDRESS_EXPIRING)
yield km._openpgp.put_raw_key(PRIVATE_EXPIRING_KEY, ADDRESS_EXPIRING)
- key = yield km.get_key(ADDRESS_EXPIRING)
+ old_key = yield km.get_key(ADDRESS_EXPIRING)
- yield km.extend_key(validity='1w')
+ new_key = yield km.regenerate_key()
- new_expiry_date = datetime.strptime(
- KEY_EXPIRING_CREATION_DATE, '%Y-%m-%d')
- new_expiry_date += timedelta(weeks=1)
+ today = datetime.now()
+ new_expiry_date = date(today.year + 1, today.month, today.day)
renewed_public_key = yield km.get_key(ADDRESS_EXPIRING)
renewed_private_key = yield km.get_key(ADDRESS_EXPIRING, private=True)
- self.assertEqual(new_expiry_date.date(),
+ self.assertEqual(new_expiry_date,
renewed_public_key.expiry_date.date())
- self.assertEqual(new_expiry_date.date(),
+ self.assertEqual(new_expiry_date,
renewed_private_key.expiry_date.date())
- self.assertEqual(key.fingerprint, renewed_public_key.fingerprint)
- self.assertEqual(key.fingerprint, renewed_private_key.fingerprint)
+ self.assertNotEqual(old_key.fingerprint,
+ renewed_public_key.fingerprint)
+ self.assertEqual(new_key.fingerprint, renewed_public_key.fingerprint)
+ self.assertIn(old_key.fingerprint[-16:], renewed_public_key.signatures)
@defer.inlineCallbacks
def test_key_extension_with_invalid_period_throws_exception(self):