aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-27 11:46:11 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-27 13:05:37 -0600
commit2eb69f6cf88d15e2c6c2383335d96f2a81fd8ffe (patch)
treef8201391695bf1fcb51a636ad102ab7643f8aba2
parentd5d0a3102b609907f2dfadad8e0da10374475697 (diff)
downloadcryptography-2eb69f6cf88d15e2c6c2383335d96f2a81fd8ffe.tar.gz
cryptography-2eb69f6cf88d15e2c6c2383335d96f2a81fd8ffe.tar.bz2
cryptography-2eb69f6cf88d15e2c6c2383335d96f2a81fd8ffe.zip
implement hash on basicconstraints
-rw-r--r--src/cryptography/x509/extensions.py3
-rw-r--r--tests/test_x509_ext.py5
2 files changed, 8 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 4dee72f0..ca323a3b 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -342,6 +342,9 @@ class BasicConstraints(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash((self.ca, self.path_length))
+
@utils.register_interface(ExtensionType)
class CRLDistributionPoints(object):
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 67081b23..20d44c59 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -837,6 +837,11 @@ class TestBasicConstraints(object):
"<BasicConstraints(ca=True, path_length=None)>"
)
+ def test_hash(self):
+ na = x509.BasicConstraints(ca=True, path_length=None)
+ na2 = x509.BasicConstraints(ca=True, path_length=None)
+ assert hash(na) == hash(na2)
+
def test_eq(self):
na = x509.BasicConstraints(ca=True, path_length=None)
na2 = x509.BasicConstraints(ca=True, path_length=None)