aboutsummaryrefslogtreecommitdiff
path: root/tests/test_rfc8226.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-01-26 18:20:17 +0100
committerGitHub <noreply@github.com>2019-01-26 18:20:17 +0100
commit456d3f2987b901b3cd9dbb7774926b9d362c2f59 (patch)
tree0a62eb0dcd39f24502ab3b9307c64a07be9653ca /tests/test_rfc8226.py
parentee7f9f20a2464bf52b3895efe5f6c5ab999520eb (diff)
downloadpyasn1-modules-456d3f2987b901b3cd9dbb7774926b9d362c2f59.tar.gz
Add RFC8226 (#21)
Implement RFC8226 Implements JWT Claim Constraints and TN Authorization List for X.509 certificate extensions. Also fixes bug in `rfc5280.AlgorithmIdentifier` ANY type definition.
Diffstat (limited to 'tests/test_rfc8226.py')
-rw-r--r--tests/test_rfc8226.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_rfc8226.py b/tests/test_rfc8226.py
new file mode 100644
index 0000000..a7dc036
--- /dev/null
+++ b/tests/test_rfc8226.py
@@ -0,0 +1,54 @@
+#
+# This file is part of pyasn1-modules software.
+#
+# Created by Russ Housley
+# Copyright (c) 2019, Vigil Security, LLC
+# License: http://snmplabs.com/pyasn1/license.html
+#
+
+import sys
+
+from pyasn1.codec.der import decoder as der_decoder
+from pyasn1.codec.der import encoder as der_encoder
+
+from pyasn1_modules import pem
+from pyasn1_modules import rfc8226
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+
+class JWTClaimConstraintsTestCase(unittest.TestCase):
+ jwtcc_pem_text = "MD2gBzAFFgNmb2+hMjAwMBkWA2ZvbzASDARmb28xDARmb28yDARmb28zMBMWA2JhcjAMDARiYXIxDARiYXIy"
+
+ def setUp(self):
+ self.asn1Spec = rfc8226.JWTClaimConstraints()
+
+ def testDerCodec(self):
+ substrate = pem.readBase64fromText(self.jwtcc_pem_text)
+ asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec)
+ assert not rest
+ assert asn1Object.prettyPrint()
+ assert der_encoder.encode(asn1Object) == substrate
+
+
+class TNAuthorizationListTestCase(unittest.TestCase):
+ tnal_pem_text = "MCugBxYFYm9ndXOhEjAQFgo1NzE1NTUxMjEyAgIDFKIMFgo3MDM1NTUxMjEy"
+
+ def setUp(self):
+ self.asn1Spec = rfc8226.TNAuthorizationList()
+
+ def testDerCodec(self):
+ substrate = pem.readBase64fromText(self.tnal_pem_text)
+ asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec)
+ assert not rest
+ assert asn1Object.prettyPrint()
+ assert der_encoder.encode(asn1Object) == substrate
+
+
+suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
+
+if __name__ == '__main__':
+ unittest.TextTestRunner(verbosity=2).run(suite)