X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=tests%2Ftest_crts.py;h=7fb3f74d2f36a020938a44271e7b9f5fd69c7de6;hb=16f6fd50b698cba058661ceba684237bd82229e4;hp=04e54e4747194edf72ecd84113eb3eb36dfb2c23;hpb=88a72bcbbb16c2e0d58b6c6fdc6c51b8e517ee7f;p=pyderasn.git diff --git a/tests/test_crts.py b/tests/test_crts.py index 04e54e4..7fb3f74 100644 --- a/tests/test_crts.py +++ b/tests/test_crts.py @@ -1,11 +1,10 @@ # coding: utf-8 # PyDERASN -- Python ASN.1 DER codec with abstract structures -# Copyright (C) 2017-2018 Sergey Matveev +# Copyright (C) 2017-2019 Sergey Matveev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. +# published by the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -221,12 +220,12 @@ class TestGoSelfSignedVector(TestCase): expect.encode(), ) assert_raw_equals(tbs["serialNumber"], Integer(10143011886257155224)) - algo_id = AlgorithmIdentifier() - algo_id["algorithm"] = ObjectIdentifier("1.2.840.113549.1.1.5") - algo_id["parameters"] = Any(Null()) + algo_id = AlgorithmIdentifier(( + ("algorithm", ObjectIdentifier("1.2.840.113549.1.1.5")), + ("parameters", Any(Null())), + )) self.assertEqual(tbs["signature"], algo_id) assert_raw_equals(tbs["signature"], algo_id) - issuer = Name() rdnSeq = RDNSequence() for oid, klass, text in ( ("2.5.4.6", PrintableString, "XX"), @@ -236,22 +235,25 @@ class TestGoSelfSignedVector(TestCase): ("2.5.4.3", PrintableString, "false.example.com"), ("1.2.840.113549.1.9.1", IA5String, "false@example.com"), ): - attr = AttributeTypeAndValue() - attr["type"] = AttributeType(oid) - attr["value"] = AttributeValue(klass(text)) - rdn = RelativeDistinguishedName() - rdn.append(attr) - rdnSeq.append(rdn) - issuer["rdnSequence"] = rdnSeq + rdnSeq.append( + RelativeDistinguishedName(( + AttributeTypeAndValue(( + ("type", AttributeType(oid)), + ("value", AttributeValue(klass(text))), + )), + )) + ) + issuer = Name(("rdnSequence", rdnSeq)) self.assertEqual(tbs["issuer"], issuer) assert_raw_equals(tbs["issuer"], issuer) - validity = Validity() - validity["notBefore"] = Time( - ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53))) - ) - validity["notAfter"] = Time( - ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53))) - ) + validity = Validity(( + ("notBefore", Time( + ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53))) + )), + ("notAfter", Time( + ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53))) + )), + )) self.assertEqual(tbs["validity"], validity) assert_raw_equals(tbs["validity"], validity) self.assertEqual(tbs["subject"], issuer) @@ -282,9 +284,10 @@ class TestGoSelfSignedVector(TestCase): tbs = TBSCertificate() tbs["serialNumber"] = CertificateSerialNumber(10143011886257155224) - sign_algo_id = AlgorithmIdentifier() - sign_algo_id["algorithm"] = ObjectIdentifier("1.2.840.113549.1.1.5") - sign_algo_id["parameters"] = Any(Null()) + sign_algo_id = AlgorithmIdentifier(( + ("algorithm", ObjectIdentifier("1.2.840.113549.1.1.5")), + ("parameters", Any(Null())), + )) tbs["signature"] = sign_algo_id rdnSeq = RDNSequence() @@ -296,20 +299,27 @@ class TestGoSelfSignedVector(TestCase): ("2.5.4.3", PrintableString, "false.example.com"), ("1.2.840.113549.1.9.1", IA5String, "false@example.com"), ): - attr = AttributeTypeAndValue() - attr["type"] = AttributeType(oid) - attr["value"] = AttributeValue(klass(text)) - rdn = RelativeDistinguishedName() - rdn.append(attr) - rdnSeq.append(rdn) + rdnSeq.append( + RelativeDistinguishedName(( + AttributeTypeAndValue(( + ("type", AttributeType(oid)), + ("value", AttributeValue(klass(text))), + )), + )) + ) issuer = Name() issuer["rdnSequence"] = rdnSeq tbs["issuer"] = issuer tbs["subject"] = issuer - validity = Validity() - validity["notBefore"] = Time(("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53)))) - validity["notAfter"] = Time(("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53)))) + validity = Validity(( + ("notBefore", Time( + ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53)),), + )), + ("notAfter", Time( + ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53)),), + )), + )) tbs["validity"] = validity spki = SubjectPublicKeyInfo()