From 409a0c8d66a074033f7c6359c4f1578c9f479245 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 14 Sep 2017 11:15:58 +0800 Subject: implement __hash__ on DistributionPoint and CRLDistributionPoints (#3915) --- tests/x509/test_x509_ext.py | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'tests/x509/test_x509_ext.py') diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index d121a92b..b9400b64 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -3629,6 +3629,46 @@ class TestDistributionPoint(object): ">)>])>" ) + def test_hash(self): + dp = x509.DistributionPoint( + [x509.UniformResourceIdentifier(b"http://crypt.og/crl")], + None, + frozenset([x509.ReasonFlags.superseded]), + [ + x509.DirectoryName( + x509.Name([ + x509.NameAttribute( + NameOID.COMMON_NAME, u"Important CA" + ) + ]) + ) + ], + ) + dp2 = x509.DistributionPoint( + [x509.UniformResourceIdentifier(b"http://crypt.og/crl")], + None, + frozenset([x509.ReasonFlags.superseded]), + [ + x509.DirectoryName( + x509.Name([ + x509.NameAttribute( + NameOID.COMMON_NAME, u"Important CA" + ) + ]) + ) + ], + ) + dp3 = x509.DistributionPoint( + None, + x509.RelativeDistinguishedName([ + x509.NameAttribute(NameOID.COMMON_NAME, u"myCN") + ]), + None, + None, + ) + assert hash(dp) == hash(dp2) + assert hash(dp) != hash(dp3) + class TestCRLDistributionPoints(object): def test_invalid_distribution_points(self): @@ -3780,6 +3820,40 @@ class TestCRLDistributionPoints(object): assert cdp != cdp4 assert cdp != object() + def test_hash(self): + cdp = x509.CRLDistributionPoints([ + x509.DistributionPoint( + [x509.UniformResourceIdentifier(b"ftp://domain")], + None, + frozenset([ + x509.ReasonFlags.key_compromise, + x509.ReasonFlags.ca_compromise, + ]), + [x509.UniformResourceIdentifier(b"uri://thing")], + ), + ]) + cdp2 = x509.CRLDistributionPoints([ + x509.DistributionPoint( + [x509.UniformResourceIdentifier(b"ftp://domain")], + None, + frozenset([ + x509.ReasonFlags.key_compromise, + x509.ReasonFlags.ca_compromise, + ]), + [x509.UniformResourceIdentifier(b"uri://thing")], + ), + ]) + cdp3 = x509.CRLDistributionPoints([ + x509.DistributionPoint( + [x509.UniformResourceIdentifier(b"ftp://domain")], + None, + frozenset([x509.ReasonFlags.key_compromise]), + [x509.UniformResourceIdentifier(b"uri://thing")], + ), + ]) + assert hash(cdp) == hash(cdp2) + assert hash(cdp) != hash(cdp3) + def test_indexing(self): ci = x509.CRLDistributionPoints([ x509.DistributionPoint( -- cgit v1.2.3