aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-01-03 16:17:14 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-01-03 16:17:14 -0600
commit743a213d33ad8b1a2ef0becd0084c3fceebac8dd (patch)
treedfc55e480a2ac9b840038d82d6cab82e4a243715
parentb6a0f24434da2cab3e1bba0eb7ba064ca5aacec7 (diff)
parentd1b5681f6db2bde7a14625538bd7907b08dfb486 (diff)
downloadcryptography-743a213d33ad8b1a2ef0becd0084c3fceebac8dd.tar.gz
cryptography-743a213d33ad8b1a2ef0becd0084c3fceebac8dd.tar.bz2
cryptography-743a213d33ad8b1a2ef0becd0084c3fceebac8dd.zip
Merge pull request #2636 from alex/uri-hash
Implement __hash__ on UniformResourceIdentifier
-rw-r--r--src/cryptography/x509/general_name.py3
-rw-r--r--tests/test_x509_ext.py8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py
index f5bd30fb..049cd21f 100644
--- a/src/cryptography/x509/general_name.py
+++ b/src/cryptography/x509/general_name.py
@@ -155,6 +155,9 @@ class UniformResourceIdentifier(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash(self.value)
+
@utils.register_interface(GeneralName)
class DirectoryName(object):
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 03a3730a..d04ce757 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -1480,6 +1480,14 @@ class TestUniformResourceIdentifier(object):
)
assert gn.value == u"ldap://cryptography:90/path?query=true#somedata"
+ def test_hash(self):
+ g1 = x509.UniformResourceIdentifier(u"http://host.com")
+ g2 = x509.UniformResourceIdentifier(u"http://host.com")
+ g3 = x509.UniformResourceIdentifier(u"http://other.com")
+
+ assert hash(g1) == hash(g2)
+ assert hash(g1) != hash(g3)
+
class TestRegisteredID(object):
def test_not_oid(self):