add __hash__ to InvalidityDate
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 22cba68..89172cb 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -1028,4 +1028,7 @@
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash(self.invalidity_date)
+
invalidity_date = utils.read_only_property("_invalidity_date")
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 91a0765..d0f4cac 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -158,6 +158,12 @@
"<InvalidityDate(invalidity_date=2015-01-01 01:01:00)>"
)
+ def test_hash(self):
+ invalid1 = x509.InvalidityDate(datetime.datetime(2015, 1, 1, 1, 1))
+ invalid2 = x509.InvalidityDate(datetime.datetime(2015, 1, 1, 1, 1))
+ invalid3 = x509.InvalidityDate(datetime.datetime(2015, 1, 1, 1, 2))
+ assert hash(invalid1) == hash(invalid2)
+ assert hash(invalid1) != hash(invalid3)
class TestNoticeReference(object):
def test_notice_numbers_not_all_int(self):