diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-06 16:33:22 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-06 16:33:47 -0400 |
commit | 728ffae25134b6d68be7567803ed8310a18a86a6 (patch) | |
tree | 5e8a3a578b30c5fb72245bd35bfdf6345ed2703d /tests/integration | |
parent | a0c08653bfa1b9f5a3b86595dfcd015eac8f7fca (diff) |
[tests] factor out the common pieces to keymanager.testing
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/keymanager/common.py | 70 | ||||
-rw-r--r-- | tests/integration/keymanager/test_keymanager.py | 2 | ||||
-rw-r--r-- | tests/integration/keymanager/test_migrator.py | 5 | ||||
-rw-r--r-- | tests/integration/keymanager/test_openpgp.py | 2 | ||||
-rw-r--r-- | tests/integration/keymanager/test_validation.py | 2 |
5 files changed, 5 insertions, 76 deletions
diff --git a/tests/integration/keymanager/common.py b/tests/integration/keymanager/common.py index e170d78..3371ceb 100644 --- a/tests/integration/keymanager/common.py +++ b/tests/integration/keymanager/common.py @@ -32,76 +32,6 @@ PATH = os.path.dirname(os.path.realpath(__file__)) ADDRESS = 'leap@leap.se' ADDRESS_2 = 'anotheruser@leap.se' - -class KeyManagerWithSoledadTestCase(unittest.TestCase, BaseLeapTest): - - def setUp(self): - self.gpg_binary_path = self._find_gpg() - - self._soledad = Soledad( - u"leap@leap.se", - u"123456", - secrets_path=self.tempdir + "/secret.gpg", - local_db_path=self.tempdir + "/soledad.u1db", - server_url='', - cert_file=None, - auth_token=None, - syncable=False - ) - - def tearDown(self): - km = self._key_manager() - - # wait for the indexes to be ready for the tear down - d = km._openpgp.deferred_init - d.addCallback(lambda _: self.delete_all_keys(km)) - d.addCallback(lambda _: self._soledad.close()) - return d - - def delete_all_keys(self, km): - def delete_keys(keys): - deferreds = [] - for key in keys: - d = km._openpgp.delete_key(key) - deferreds.append(d) - return gatherResults(deferreds) - - def check_deleted(_, private): - d = km.get_all_keys(private=private) - d.addCallback(lambda keys: self.assertEqual(keys, [])) - return d - - deferreds = [] - for private in [True, False]: - d = km.get_all_keys(private=private) - d.addCallback(delete_keys) - d.addCallback(check_deleted, private) - deferreds.append(d) - return gatherResults(deferreds) - - def _key_manager(self, user=ADDRESS, url='', token=None, - ca_cert_path=None): - return KeyManager(user, url, self._soledad, token=token, - gpgbinary=self.gpg_binary_path, - ca_cert_path=ca_cert_path) - - def _find_gpg(self): - gpg_path = distutils.spawn.find_executable('gpg') - if gpg_path is not None: - return os.path.realpath(gpg_path) - else: - return "/usr/bin/gpg" - - def get_public_binary_key(self): - with open(PATH + '/fixtures/public_key.bin', 'r') as binary_public_key: - return binary_public_key.read() - - def get_private_binary_key(self): - with open( - PATH + '/fixtures/private_key.bin', 'r') as binary_private_key: - return binary_private_key.read() - - # key 24D18DDF: public key "Leap Test Key <leap@leap.se>" KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF" PUBLIC_KEY = """ diff --git a/tests/integration/keymanager/test_keymanager.py b/tests/integration/keymanager/test_keymanager.py index 568cbd2..4588a04 100644 --- a/tests/integration/keymanager/test_keymanager.py +++ b/tests/integration/keymanager/test_keymanager.py @@ -38,9 +38,9 @@ from leap.bitmask.keymanager.keys import ( build_key_from_dict, ) from leap.bitmask.keymanager.validation import ValidationLevels +from leap.bitmask.keymanager.testing import KeyManagerWithSoledadTestCase from common import ( - KeyManagerWithSoledadTestCase, ADDRESS, ADDRESS_2, KEY_FINGERPRINT, diff --git a/tests/integration/keymanager/test_migrator.py b/tests/integration/keymanager/test_migrator.py index 163e57e..52c9c1c 100644 --- a/tests/integration/keymanager/test_migrator.py +++ b/tests/integration/keymanager/test_migrator.py @@ -38,9 +38,8 @@ from leap.bitmask.keymanager.documents import ( KEY_SIGN_USED_KEY, ) from leap.bitmask.keymanager.validation import ValidationLevels - -from common import ( - KeyManagerWithSoledadTestCase, +from leap.bitmask.keymanager.testing import KeyManagerWithSoledadTestCase +from leap.bitmask.keymanager.testing import ( ADDRESS, ADDRESS_2, KEY_FINGERPRINT, diff --git a/tests/integration/keymanager/test_openpgp.py b/tests/integration/keymanager/test_openpgp.py index 9af35a1..a730bd4 100644 --- a/tests/integration/keymanager/test_openpgp.py +++ b/tests/integration/keymanager/test_openpgp.py @@ -30,9 +30,9 @@ from leap.bitmask.keymanager.documents import ( TYPE_ADDRESS_PRIVATE_INDEX, ) from leap.bitmask.keymanager.keys import OpenPGPKey +from leap.bitmask.keymanager.testing import KeyManagerWithSoledadTestCase from common import ( - KeyManagerWithSoledadTestCase, ADDRESS, ADDRESS_2, KEY_FINGERPRINT, diff --git a/tests/integration/keymanager/test_validation.py b/tests/integration/keymanager/test_validation.py index 8a41137..dccd0f6 100644 --- a/tests/integration/keymanager/test_validation.py +++ b/tests/integration/keymanager/test_validation.py @@ -24,7 +24,7 @@ from twisted.internet.defer import inlineCallbacks from leap.bitmask.keymanager.errors import KeyNotValidUpgrade from leap.bitmask.keymanager.validation import ValidationLevels -from common import ( +from leap.bitmask.keymanager.testing import ( KeyManagerWithSoledadTestCase, ADDRESS, PUBLIC_KEY, |