summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-05-13 18:20:08 +0200
committerGitHub <noreply@github.com>2022-05-13 12:20:08 -0400
commit45ebb73416a67cb87b7ca0bfcfe7902b4f38250a (patch)
tree0a5e253c0feb791ffc3b2ff7eaeeaa0ef214d460 /tests
parentb31622b369618746e54242ebfcc305154bf0ef59 (diff)
downloadpyopenssl-45ebb73416a67cb87b7ca0bfcfe7902b4f38250a.tar.gz
Handle no expire date in X509.has_expire() (#1083)
get_notAfter() can return None. Instead of raising a NoneType error, raise a ValueError which tells us why it failed.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_crypto.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index ea89f6c..8c19030 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -1968,6 +1968,14 @@ class TestX509(_PKeyInteractionTestsMixin):
cert.gmtime_adj_notAfter(2)
assert not cert.has_expired()
+ def test_has_expired_exception(self):
+ """
+ `X509.has_expired` throws ValueError if not-after time is not set
+ """
+ cert = X509()
+ with pytest.raises(ValueError):
+ cert.has_expired()
+
def test_root_has_not_expired(self):
"""
`X509.has_expired` returns `False` if the certificate's not-after time