aboutsummaryrefslogtreecommitdiff
path: root/tests/test_rfc8226.py
diff options
context:
space:
mode:
authorRuss Housley <housley@vigilsec.com>2019-07-20 06:58:55 -0400
committerIlya Etingof <etingof@gmail.com>2019-07-20 12:58:55 +0200
commit23608be1bc0ce8a4ac5fbaba92af905c88ea4ab6 (patch)
tree67be142d26a66e2a874502f60c3e97d0059bd769 /tests/test_rfc8226.py
parent06f5be85d5229cffeb24f9ae622df665d7ae506b (diff)
downloadpyasn1-modules-23608be1bc0ce8a4ac5fbaba92af905c88ea4ab6.tar.gz
Added maps for use with openType (#53)
Diffstat (limited to 'tests/test_rfc8226.py')
-rwxr-xr-x[-rw-r--r--]tests/test_rfc8226.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_rfc8226.py b/tests/test_rfc8226.py
index a7dc036..19e7fc7 100644..100755
--- a/tests/test_rfc8226.py
+++ b/tests/test_rfc8226.py
@@ -12,6 +12,7 @@ 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 rfc5280
from pyasn1_modules import rfc8226
try:
@@ -48,6 +49,43 @@ class TNAuthorizationListTestCase(unittest.TestCase):
assert der_encoder.encode(asn1Object) == substrate
+class CertificateOpenTypesTestCase(unittest.TestCase):
+ cert_pem_text = """\
+MIICkTCCAhegAwIBAgIJAKWzVCgbsG4+MAoGCCqGSM49BAMDMD8xCzAJBgNVBAYT
+AlVTMQswCQYDVQQIDAJWQTEQMA4GA1UEBwwHSGVybmRvbjERMA8GA1UECgwIQm9n
+dXMgQ0EwHhcNMTkwNzE4MTUwNzQ5WhcNMjAwNzE3MTUwNzQ5WjBxMQswCQYDVQQG
+EwJVUzELMAkGA1UECBMCVkExEDAOBgNVBAcTB0hlcm5kb24xKDAmBgNVBAoTH0Zh
+a2UgVGVsZXBob25lIFNlcnZpY2UgUHJvdmlkZXIxGTAXBgNVBAMTEGZha2UuZXhh
+bXBsZS5jb20wdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARLyLhnsvrS9WBY29tmN2LI
+CF/wuX4ohhUy3sxO0ynCplHHojpDg+tghGzusf0aLtMDu1II915O8YK5XVL+KZJD
+C82jybxWIKjjzX2qc5/O06joUttdEDzkTaD0kgbcXl6jgawwgakwCwYDVR0PBAQD
+AgeAMEIGCWCGSAGG+EIBDQQ1FjNUaGlzIGNlcnRpZmljYXRlIGNhbm5vdCBiZSB0
+cnVzdGVkIGZvciBhbnkgcHVycG9zZS4wHQYDVR0OBBYEFHOI3GpDt9dWsTAZxhcj
+96uyL2aIMB8GA1UdIwQYMBaAFPI12zQE2qVV8r1pA5mwYuziFQjBMBYGCCsGAQUF
+BwEaBAowCKAGFgRmYWtlMAoGCCqGSM49BAMDA2gAMGUCMQCy+qFhT7X1i18jcyIa
+Jkgz/tumrPsaBA2RihkooTEr4GbqC650Z4Cwt7+x2xZq37sCMFSM6fRueLyV5StG
+yEFWA6G95b/HbtPMTjLpPKtrOjhofc4LyVCDYhFhKzpvHh1qeA==
+"""
+
+ def setUp(self):
+ self.asn1Spec = rfc5280.Certificate()
+
+ def testDerCodec(self):
+ substrate = pem.readBase64fromText(self.cert_pem_text)
+ asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec)
+ assert not rest
+ assert asn1Object.prettyPrint()
+ assert der_encoder.encode(asn1Object) == substrate
+
+ for extn in asn1Object['tbsCertificate']['extensions']:
+ if extn['extnID'] in rfc5280.certificateExtensionsMap.keys():
+ extnValue, rest = der_decoder.decode(extn['extnValue'],
+ asn1Spec=rfc5280.certificateExtensionsMap[extn['extnID']])
+ assert der_encoder.encode(extnValue) == extn['extnValue']
+
+ if extn['extnID'] == rfc8226.id_pe_TNAuthList:
+ assert extnValue[0]['spc'] == 'fake'
+
suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
if __name__ == '__main__':