summaryrefslogtreecommitdiff
path: root/src/leap/keymanager/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/keymanager/tests')
-rw-r--r--src/leap/keymanager/tests/test_keymanager.py13
-rw-r--r--src/leap/keymanager/tests/test_validation.py18
2 files changed, 14 insertions, 17 deletions
diff --git a/src/leap/keymanager/tests/test_keymanager.py b/src/leap/keymanager/tests/test_keymanager.py
index 55f892e9..08d37500 100644
--- a/src/leap/keymanager/tests/test_keymanager.py
+++ b/src/leap/keymanager/tests/test_keymanager.py
@@ -36,10 +36,7 @@ from leap.keymanager.keys import (
is_address,
build_key_from_dict,
)
-from leap.keymanager.validation import (
- ValidationLevel,
- toValidationLevel
-)
+from leap.keymanager.validation import ValidationLevels
from leap.keymanager.tests import (
KeyManagerWithSoledadTestCase,
ADDRESS,
@@ -82,7 +79,7 @@ class KeyManagerUtilTestCase(unittest.TestCase):
'expiry_date': 0,
'last_audited_at': 0,
'refreshed_at': 1311239602,
- 'validation': ValidationLevel.Weak_Chain.name,
+ 'validation': str(ValidationLevels.Weak_Chain),
'encr_used': False,
'sign_used': True,
}
@@ -115,7 +112,7 @@ class KeyManagerUtilTestCase(unittest.TestCase):
datetime.fromtimestamp(kdict['refreshed_at']), key.refreshed_at,
'Wrong data in key.')
self.assertEqual(
- toValidationLevel(kdict['validation']), key.validation,
+ ValidationLevels.get(kdict['validation']), key.validation,
'Wrong data in key.')
self.assertEqual(
kdict['encr_used'], key.encr_used,
@@ -227,7 +224,7 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
key = yield self._fetch_key(km, ADDRESS, PUBLIC_KEY)
self.assertIsInstance(key, OpenPGPKey)
self.assertTrue(ADDRESS in key.address)
- self.assertEqual(key.validation, ValidationLevel.Provider_Trust)
+ self.assertEqual(key.validation, ValidationLevels.Provider_Trust)
@inlineCallbacks
def test_get_key_fetches_other_domain(self):
@@ -239,7 +236,7 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase):
key = yield self._fetch_key(km, ADDRESS_OTHER, PUBLIC_KEY_OTHER)
self.assertIsInstance(key, OpenPGPKey)
self.assertTrue(ADDRESS_OTHER in key.address)
- self.assertEqual(key.validation, ValidationLevel.Weak_Chain)
+ self.assertEqual(key.validation, ValidationLevels.Weak_Chain)
def _fetch_key(self, km, address, key):
"""
diff --git a/src/leap/keymanager/tests/test_validation.py b/src/leap/keymanager/tests/test_validation.py
index 15e7d27d..0c1d155f 100644
--- a/src/leap/keymanager/tests/test_validation.py
+++ b/src/leap/keymanager/tests/test_validation.py
@@ -31,10 +31,10 @@ from leap.keymanager.tests import (
PUBLIC_KEY,
KEY_FINGERPRINT
)
-from leap.keymanager.validation import ValidationLevel
+from leap.keymanager.validation import ValidationLevels
-class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
+class ValidationLevelsTestCase(KeyManagerWithSoledadTestCase):
@inlineCallbacks
def test_none_old_key(self):
@@ -47,7 +47,7 @@ class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
def test_cant_upgrade(self):
km = self._key_manager()
yield km.put_raw_key(PUBLIC_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Provider_Trust)
+ validation=ValidationLevels.Provider_Trust)
d = km.put_raw_key(UNRELATED_KEY, OpenPGPKey, ADDRESS)
yield self.assertFailure(d, KeyNotValidUpgrade)
@@ -56,7 +56,7 @@ class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
km = self._key_manager()
yield km.put_raw_key(PUBLIC_KEY, OpenPGPKey, ADDRESS)
yield km.put_raw_key(UNRELATED_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Fingerprint)
+ validation=ValidationLevels.Fingerprint)
key = yield km.get_key(ADDRESS, OpenPGPKey, fetch_remote=False)
self.assertEqual(key.fingerprint, UNRELATED_FINGERPRINT)
@@ -73,12 +73,12 @@ class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
km = self._key_manager()
yield km.put_raw_key(
EXPIRED_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Third_Party_Endorsement)
+ validation=ValidationLevels.Third_Party_Endorsement)
d = km.put_raw_key(
UNRELATED_KEY,
OpenPGPKey,
ADDRESS,
- validation=ValidationLevel.Provider_Trust)
+ validation=ValidationLevels.Provider_Trust)
yield self.assertFailure(d, KeyNotValidUpgrade)
@inlineCallbacks
@@ -93,9 +93,9 @@ class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
def test_not_used(self):
km = self._key_manager()
yield km.put_raw_key(UNEXPIRED_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Provider_Trust)
+ validation=ValidationLevels.Provider_Trust)
yield km.put_raw_key(UNRELATED_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Provider_Endorsement)
+ validation=ValidationLevels.Provider_Endorsement)
key = yield km.get_key(ADDRESS, OpenPGPKey, fetch_remote=False)
self.assertEqual(key.fingerprint, UNRELATED_FINGERPRINT)
@@ -114,7 +114,7 @@ class ValidationLevelTestCase(KeyManagerWithSoledadTestCase):
yield km.verify(TEXT, ADDRESS, OpenPGPKey, detached_sig=signature)
d = km.put_raw_key(
UNRELATED_KEY, OpenPGPKey, ADDRESS,
- validation=ValidationLevel.Provider_Endorsement)
+ validation=ValidationLevels.Provider_Endorsement)
yield self.assertFailure(d, KeyNotValidUpgrade)
@inlineCallbacks