@@ -614,30 +614,53 @@ pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1
614614mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
615615-----END CERTIFICATE-----
616616""")
617- c0.isIssuerCert(c1) and c1.isIssuerCert(c2) and not c0.isIssuerCert(c2)
617+ assert c0.isIssuerCert(c1) and c1.isIssuerCert(c2) and not c0.isIssuerCert(c2)
618618
619619= Cert class : Checking isSelfSigned()
620- c2.isSelfSigned() and not c1.isSelfSigned() and not c0.isSelfSigned()
620+ assert c2.isSelfSigned() and not c1.isSelfSigned() and not c0.isSelfSigned()
621621
622622= PubKey class : Checking verifyCert()
623- c2.pubKey.verifyCert(c2) and c1.pubKey.verifyCert(c0)
623+ assert c2.pubKey.verifyCert(c2) and c1.pubKey.verifyCert(c0)
624+
625+ = CertTree class : Checking verification of chain
626+ chain0 = CertTree([c0, c1, c2]).getchain(c0)
627+ assert len(chain0) == 3
628+ assert chain0[0] == c1
629+ assert chain0[1] == c0
630+ assert chain0[2] == c2
631+ chain1 = CertTree([c2, c1, c0]).getchain(c1)
632+ assert len(chain1) == 2
633+ assert chain1[0] == c1
634+ assert chain1[1] == c2
635+ chain2 = CertTree([c0, c2, c1]).getchain(c2)
636+ assert len(chain2) == 1
637+ assert chain2[0] == c2
638+
639+ = CertTree class : show()
640+
641+ expected_repr = '/C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Root Certificate Authority - G2 [Self Signed]\n /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./OU=http://certs.starfieldtech.com/repository//CN=Starfield Secure Certificate Authority - G2 [Not Self Signed]\n /OU=Domain Control Validated/CN=*.tools.ietf.org [Not Self Signed]\n'
642+ assert CertTree([c0, c1, c2]).show(ret=True) == expected_repr
643+
644+ repr_str = CertTree([], c0).show(ret=True)
645+ assert repr_str == '/OU=Domain Control Validated/CN=*.tools.ietf.org [Not Self Signed]\n'
646+
647+ = CertTree class : verify
648+
649+ CertTree([c1, c2]).verify(c0)
650+ CertTree([c2]).verify(c1)
651+
652+ try:
653+ CertTree([c1]).verify(c0)
654+ assert False
655+ except ValueError:
656+ pass
657+
658+ try:
659+ CertTree([c2]).verify(c0)
660+ assert False
661+ except ValueError:
662+ pass
624663
625- = Chain class : Checking chain construction
626- assert len(Chain([c0, c1, c2])) == 3
627- assert len(Chain([c0], c1)) == 2
628- len(Chain([c0], c2)) == 1
629-
630- = Chain class : repr
631-
632- expected_repr = """__ /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Root Certificate Authority - G2 [Self Signed]
633- _ /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./OU=http://certs.starfieldtech.com/repository//CN=Starfield Secure Certificate Authority - G2
634- _ /OU=Domain Control Validated/CN=*.tools.ietf.org"""
635- assert str(Chain([c0, c1, c2])) == expected_repr
636-
637- = Test __repr__
638-
639- repr_str = Chain([], c0).__repr__()
640- assert repr_str == '__ /OU=Domain Control Validated/CN=*.tools.ietf.org [Not Self Signed]\n'
641664
642665= Test GeneralizedTime
643666
0 commit comments