aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-12-27 15:57:57 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-12-27 15:57:57 -0500
commitb25888daba748af45bc96afbd08a25f3820ece52 (patch)
tree53e6907487555181f84f90e3644b5cc56b9b9248
parentb04b67e06ea638e23e06f3fde151a6912c184025 (diff)
parentb39af8d7195757b5025417187376b04e387264a1 (diff)
downloadcryptography-b25888daba748af45bc96afbd08a25f3820ece52.tar.gz
cryptography-b25888daba748af45bc96afbd08a25f3820ece52.tar.bz2
cryptography-b25888daba748af45bc96afbd08a25f3820ece52.zip
Merge pull request #2594 from reaperhulk/hash-bc
implement hash on basicconstraints
-rw-r--r--src/cryptography/x509/extensions.py3
-rw-r--r--tests/test_x509_ext.py7
2 files changed, 10 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..898f9bcf 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -837,6 +837,13 @@ 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)
+ na3 = x509.BasicConstraints(ca=True, path_length=0)
+ assert hash(na) == hash(na2)
+ assert hash(na) != hash(na3)
+
def test_eq(self):
na = x509.BasicConstraints(ca=True, path_length=None)
na2 = x509.BasicConstraints(ca=True, path_length=None)