summaryrefslogtreecommitdiff
path: root/keymanager
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2015-01-05 08:54:24 -0600
committerRuben Pollan <meskio@sindominio.net>2015-01-15 13:10:57 -0600
commitabf2bde0d74e9f6dbafa7fc088a094d7684f8d5a (patch)
treeb17de439fdbfafff239fb2fa60e143523f72c042 /keymanager
parentcf8b6825d15ec970a6e54aac408d007605f3bb57 (diff)
Port validation levels to enum34
Diffstat (limited to 'keymanager')
-rw-r--r--keymanager/pkg/requirements.pip2
-rw-r--r--keymanager/src/leap/keymanager/keys.py2
-rw-r--r--keymanager/src/leap/keymanager/tests/test_keymanager.py2
-rw-r--r--keymanager/src/leap/keymanager/validation.py20
4 files changed, 13 insertions, 13 deletions
diff --git a/keymanager/pkg/requirements.pip b/keymanager/pkg/requirements.pip
index 207483c..11c4229 100644
--- a/keymanager/pkg/requirements.pip
+++ b/keymanager/pkg/requirements.pip
@@ -4,4 +4,4 @@ requests
# if we bump the gnupg version, bump also the sanity check
# in keymanager.__init__
gnupg>=1.4.0
-enum
+enum34
diff --git a/keymanager/src/leap/keymanager/keys.py b/keymanager/src/leap/keymanager/keys.py
index 4e98de6..562c0a9 100644
--- a/keymanager/src/leap/keymanager/keys.py
+++ b/keymanager/src/leap/keymanager/keys.py
@@ -213,7 +213,7 @@ class EncryptionKey(object):
KEY_EXPIRY_DATE_KEY: expiry_date,
KEY_LAST_AUDITED_AT_KEY: last_audited_at,
KEY_REFRESHED_AT_KEY: refreshed_at,
- KEY_VALIDATION_KEY: str(self.validation),
+ KEY_VALIDATION_KEY: self.validation.name,
KEY_ENCR_USED_KEY: self.encr_used,
KEY_SIGN_USED_KEY: self.sign_used,
KEY_TAGS_KEY: [KEYMANAGER_KEY_TAG],
diff --git a/keymanager/src/leap/keymanager/tests/test_keymanager.py b/keymanager/src/leap/keymanager/tests/test_keymanager.py
index 86832ba..93bc42c 100644
--- a/keymanager/src/leap/keymanager/tests/test_keymanager.py
+++ b/keymanager/src/leap/keymanager/tests/test_keymanager.py
@@ -79,7 +79,7 @@ class KeyManagerUtilTestCase(unittest.TestCase):
'expiry_date': 0,
'last_audited_at': 0,
'refreshed_at': 1311239602,
- 'validation': str(ValidationLevel.Weak_Chain),
+ 'validation': ValidationLevel.Weak_Chain.name,
'encr_used': False,
'sign_used': True,
}
diff --git a/keymanager/src/leap/keymanager/validation.py b/keymanager/src/leap/keymanager/validation.py
index c6fe478..c81d533 100644
--- a/keymanager/src/leap/keymanager/validation.py
+++ b/keymanager/src/leap/keymanager/validation.py
@@ -24,17 +24,17 @@ See:
from datetime import datetime
-from enum import Enum
+from enum import IntEnum
-ValidationLevel = Enum(
- "Weak_Chain",
- "Provider_Trust",
- "Provider_Endorsement",
- "Third_Party_Endorsement",
- "Third_Party_Consensus",
- "Historically_Auditing",
- "Known_Key",
+ValidationLevel = IntEnum("ValidationLevel",
+ "Weak_Chain "
+ "Provider_Trust "
+ "Provider_Endorsement "
+ "Third_Party_Endorsement "
+ "Third_Party_Consensus "
+ "Historically_Auditing "
+ "Known_Key "
"Fingerprint")
@@ -49,7 +49,7 @@ def toValidationLevel(value):
:raises ValueError: if C{value} is not a validation level
"""
for level in ValidationLevel:
- if value == str(level):
+ if value == level.name:
return level
raise ValueError("Not valid validation level: %s" % (value,))