aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-09-14 11:15:58 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-09-13 23:15:58 -0400
commit409a0c8d66a074033f7c6359c4f1578c9f479245 (patch)
treeba9c22a27dc773d66d4266cbaec904d3f8d1021e /tests
parent5e9eeefe201e15f559f51953c8002a966cb9af1e (diff)
downloadcryptography-409a0c8d66a074033f7c6359c4f1578c9f479245.tar.gz
cryptography-409a0c8d66a074033f7c6359c4f1578c9f479245.tar.bz2
cryptography-409a0c8d66a074033f7c6359c4f1578c9f479245.zip
implement __hash__ on DistributionPoint and CRLDistributionPoints (#3915)
Diffstat (limited to 'tests')
-rw-r--r--tests/x509/test_x509_ext.py74
1 files changed, 74 insertions, 0 deletions
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(