Skip to content

Commit

Permalink
Merge pull request #2705 from eeshangarg/inhibit-any-policy-hash
Browse files Browse the repository at this point in the history
Refs #2578 -- implement __hash__ on InhibitAnyPolicy
  • Loading branch information
reaperhulk committed Feb 1, 2016
2 parents 874e865 + 0a0293e commit 4a00dcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ def __eq__(self, other):
def __ne__(self, other):
return not self == other

def __hash__(self):
return hash(self.skip_certs)

skip_certs = utils.read_only_property("_skip_certs")


Expand Down
7 changes: 7 additions & 0 deletions tests/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,13 @@ def test_ne(self):
assert iap != iap2
assert iap != object()

def test_hash(self):
iap = x509.InhibitAnyPolicy(1)
iap2 = x509.InhibitAnyPolicy(1)
iap3 = x509.InhibitAnyPolicy(4)
assert hash(iap) == hash(iap2)
assert hash(iap) != hash(iap3)


@pytest.mark.requires_backend_interface(interface=RSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)
Expand Down

0 comments on commit 4a00dcd

Please sign in to comment.