diff options
-rw-r--r-- | src/cryptography/x509/extensions.py | 3 | ||||
-rw-r--r-- | tests/test_x509_ext.py | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index ed29b54c..7979ccb2 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 8f961b0b..cfca5794 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -845,6 +845,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) |