[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Add an ExtensionType enum
commit 0a491e031f5ae5a9d0ab939ccff252589596625a
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Mar 26 17:00:08 2017 +0200
Add an ExtensionType enum
Enumeration of extension types (presently there's just one) to make
comparisions nicer...
if extension_type == ExtensionType.HAS_SIGNING_KEY:
...
Rather than comparing with '4'.
---
stem/descriptor/certificate.py | 11 +++++++++++
test/unit/descriptor/certificate.py | 4 +++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/stem/descriptor/certificate.py b/stem/descriptor/certificate.py
index aacf67f..e513dac 100644
--- a/stem/descriptor/certificate.py
+++ b/stem/descriptor/certificate.py
@@ -28,6 +28,16 @@ used to validate the key used to sign server descriptors.
**AUTH** authentication key signed with ed25519 signing key
============== ===========
+.. data::ExtensionType (enum)
+
+ Recognized exception types.
+
+ ==================== ===========
+ ExtensionType Description
+ ==================== ===========
+ HAS_SIGNING_KEY includes key used to sign the certificate
+ ==================== ===========
+
.. data::ExtensionFlag (enum)
Flags that can be assigned to Ed25519 certificate extensions.
@@ -50,6 +60,7 @@ ED25519_HEADER_LENGTH = 40
ED25519_SIGNATURE_LENGTH = 64
CertType = enum.UppercaseEnum('SIGNING', 'LINK_CERT', 'AUTH')
+ExtensionType = enum.Enum(('HAS_SIGNING_KEY', 4),)
ExtensionFlag = enum.UppercaseEnum('AFFECTS_VALIDATION', 'UNKNOWN')
diff --git a/test/unit/descriptor/certificate.py b/test/unit/descriptor/certificate.py
index 5728711..9c1ef10 100644
--- a/test/unit/descriptor/certificate.py
+++ b/test/unit/descriptor/certificate.py
@@ -11,7 +11,7 @@ import stem.descriptor.certificate
import stem.prereq
import test.runner
-from stem.descriptor.certificate import ED25519_SIGNATURE_LENGTH, CertType, ExtensionFlag, Ed25519Certificate, Ed25519CertificateV1, Ed25519Extension
+from stem.descriptor.certificate import ED25519_SIGNATURE_LENGTH, CertType, ExtensionType, ExtensionFlag, Ed25519Certificate, Ed25519CertificateV1, Ed25519Extension
ED25519_CERT = """
AQQABhtZAaW2GoBED1IjY3A6f6GNqBEl5A83fD2Za9upGke51JGqAQAgBABnprVR
@@ -58,6 +58,8 @@ class TestEd25519Certificate(unittest.TestCase):
Ed25519Extension(extension_type = 5, flags = [ExtensionFlag.UNKNOWN], flag_int = 4, data = b''),
], cert.extensions)
+ self.assertEqual(ExtensionType.HAS_SIGNING_KEY, cert.extensions[0].extension_type)
+
def test_with_real_cert(self):
cert = Ed25519Certificate.parse(ED25519_CERT)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits