summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2017-04-10 18:52:20 -0300
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:37 +0100
commit85c0e9b95dfc3d7134e47aac7e7e485270b42b96 (patch)
treefce3f93d1126af00fb01e872f0b720106cddabaf
parent873012e432cd6125c3174a2bc6ef9498166d94ea (diff)
[bug] remove change_key_expiration from the API
This was intended to offer the option of only extend the old key and not change it for a new one. However, we don't plan to use this behavior anymore.
-rw-r--r--src/leap/bitmask/keymanager/__init__.py23
-rw-r--r--tests/integration/keymanager/test_keymanager.py60
2 files changed, 2 insertions, 81 deletions
diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py
index b6c36d3c..d1fd4edb 100644
--- a/src/leap/bitmask/keymanager/__init__.py
+++ b/src/leap/bitmask/keymanager/__init__.py
@@ -786,29 +786,6 @@ class KeyManager(object):
pubkey.validation = validation
yield self.put_key(pubkey)
- @defer.inlineCallbacks
- def change_key_expiration(self, expiration_time='1y', passphrase=None):
- """
- Change the expiration date of the key pair bound to the user's address
- by the expiration_time period, from the current day.
-
- :param expiration_time: new expiration time from current day in 'n',
- 'nw', 'nm' or 'ny' where n is a number
- :type expiration_time: str
-
- :return: The updated secret key, with new expiry date
- :rtype: OpenPGPKey
-
- :raise KeyExpirationError: if invalid expiration time period
- """
- my_secret_key = yield self.get_key(self._address, private=True)
- renewed_key = yield self._openpgp.expire(
- my_secret_key,
- expiration_time=expiration_time,
- passphrase=passphrase)
- yield self._openpgp.reset_all_keys_sign_used()
- defer.returnValue(renewed_key)
-
def _split_email(address):
"""
diff --git a/tests/integration/keymanager/test_keymanager.py b/tests/integration/keymanager/test_keymanager.py
index 334b3356..88a8ba93 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, date
+from datetime import datetime, date
from twisted.internet import defer
from twisted.trial import unittest
@@ -31,7 +31,6 @@ import mock
from leap.common import ca_bundle
from leap.bitmask.keymanager import errors
-from leap.bitmask.keymanager.errors import KeyExpirationError
from leap.bitmask.keymanager.keys import (
OpenPGPKey,
is_address,
@@ -652,61 +651,6 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
km._openpgp.reset_all_keys_sign_used.assert_called_once()
- @defer.inlineCallbacks
- def test_keymanager_change_key_expiry_date_for_key_pair(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, fetch_remote=False)
-
- yield km.change_key_expiration(expiration_time='1w')
-
- new_expiry_date = date.today() + timedelta(weeks=1)
-
- renewed_public_key = yield km.get_key(ADDRESS_EXPIRING,
- fetch_remote=False)
- renewed_private_key = yield km.get_key(ADDRESS_EXPIRING, private=True)
-
- self.assertEqual(new_expiry_date,
- renewed_public_key.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)
-
- @defer.inlineCallbacks
- def test_change_key_expiration_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)
- km._openpgp.reset_all_keys_sign_used = mock.Mock()
-
- yield km.change_key_expiration(expiration_time='1w')
-
- km._openpgp.reset_all_keys_sign_used.assert_called_once()
-
- @defer.inlineCallbacks
- def test_change_key_expiration_with_invalid_period_throws_exception(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, fetch_remote=False)
-
- invalid_expiration_time_option = '2xw'
-
- with self.assertRaises(KeyExpirationError):
- yield km.change_key_expiration(
- expiration_time=invalid_expiration_time_option)
-
- renewed_public_key = yield km.get_key(ADDRESS_EXPIRING,
- fetch_remote=False)
- renewed_private_key = yield km.get_key(ADDRESS_EXPIRING, private=True)
-
- self.assertEqual(key.expiry_date, renewed_public_key.expiry_date)
- self.assertEqual(key.expiry_date, renewed_private_key.expiry_date)
- self.assertEqual(key.fingerprint, renewed_public_key.fingerprint)
- self.assertEqual(key.fingerprint, renewed_private_key.fingerprint)
-
class KeyManagerCryptoTestCase(KeyManagerWithSoledadTestCase):
RAW_DATA = 'data'
@@ -740,7 +684,7 @@ class KeyManagerCryptoTestCase(KeyManagerWithSoledadTestCase):
self.assertNotEqual(self.RAW_DATA, encdata)
# renew key
- new_key = yield km.regenerate_key()
+ yield km.regenerate_key()
# decrypt
rawdata, signingkey = yield km.decrypt(