diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-01-03 16:25:26 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-01-03 16:25:26 -0600 |
commit | 9d8390caabc8abe74825e8012aad210d60caa439 (patch) | |
tree | 98036b3a65a8494b529b26d06253528c6f5b756b | |
parent | 743a213d33ad8b1a2ef0becd0084c3fceebac8dd (diff) | |
parent | b642deed88a8696e5f01ce6855ccf89985fc35d0 (diff) | |
download | cryptography-9d8390caabc8abe74825e8012aad210d60caa439.tar.gz cryptography-9d8390caabc8abe74825e8012aad210d60caa439.tar.bz2 cryptography-9d8390caabc8abe74825e8012aad210d60caa439.zip |
Merge pull request #2635 from alex/rfc-hash
Implement __hash__ on RFC822Name
-rw-r--r-- | src/cryptography/x509/general_name.py | 3 | ||||
-rw-r--r-- | tests/test_x509_ext.py | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py index 049cd21f..6745243a 100644 --- a/src/cryptography/x509/general_name.py +++ b/src/cryptography/x509/general_name.py @@ -85,6 +85,9 @@ class RFC822Name(object): def __ne__(self, other): return not self == other + def __hash__(self): + return hash(self.value) + @utils.register_interface(GeneralName) class DNSName(object): diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index d04ce757..9ac1d2ba 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -1448,6 +1448,14 @@ class TestRFC822Name(object): assert gn.value == u"email@em\xe5\xefl.com" assert gn._encoded == b"email@xn--eml-vla4c.com" + def test_hash(self): + g1 = x509.RFC822Name(u"email@host.com") + g2 = x509.RFC822Name(u"email@host.com") + g3 = x509.RFC822Name(u"admin@host.com") + + assert hash(g1) == hash(g2) + assert hash(g1) != hash(g3) + class TestUniformResourceIdentifier(object): def test_no_parsed_hostname(self): |