From 2eb69f6cf88d15e2c6c2383335d96f2a81fd8ffe Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 27 Dec 2015 11:46:11 -0600 Subject: implement hash on basicconstraints --- src/cryptography/x509/extensions.py | 3 +++ tests/test_x509_ext.py | 5 +++++ 2 files changed, 8 insertions(+) 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): "" ) + 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) -- cgit v1.2.3