aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-09-14 04:24:20 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-09-13 16:24:20 -0400
commitbdad051b9987951b4838e5c3458f6ba38b4e2ccf (patch)
tree99b6bf66719e9baa79cb1639bd2dadacdac404b8 /tests
parent54024493bd50ea6f27aa094dce2d0ddac43221f0 (diff)
downloadcryptography-bdad051b9987951b4838e5c3458f6ba38b4e2ccf.tar.gz
cryptography-bdad051b9987951b4838e5c3458f6ba38b4e2ccf.tar.bz2
cryptography-bdad051b9987951b4838e5c3458f6ba38b4e2ccf.zip
name constraints __hash__ (#3912)
Diffstat (limited to 'tests')
-rw-r--r--tests/x509/test_x509_ext.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py
index 808b3681..6010e77d 100644
--- a/tests/x509/test_x509_ext.py
+++ b/tests/x509/test_x509_ext.py
@@ -3119,6 +3119,27 @@ class TestNameConstraints(object):
assert nc != nc3
assert nc != object()
+ def test_hash(self):
+ nc = x509.NameConstraints(
+ permitted_subtrees=[x509.DNSName(b"name.local")],
+ excluded_subtrees=[x509.DNSName(b"name2.local")]
+ )
+ nc2 = x509.NameConstraints(
+ permitted_subtrees=[x509.DNSName(b"name.local")],
+ excluded_subtrees=[x509.DNSName(b"name2.local")]
+ )
+ nc3 = x509.NameConstraints(
+ permitted_subtrees=[x509.DNSName(b"name.local")],
+ excluded_subtrees=None
+ )
+ nc4 = x509.NameConstraints(
+ permitted_subtrees=None,
+ excluded_subtrees=[x509.DNSName(b"name.local")]
+ )
+ assert hash(nc) == hash(nc2)
+ assert hash(nc) != hash(nc3)
+ assert hash(nc3) != hash(nc4)
+
@pytest.mark.requires_backend_interface(interface=RSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)