aboutsummaryrefslogtreecommitdiffstats
path: root/tests/x509/test_x509.py
diff options
context:
space:
mode:
authorJoshua Crowgey <jcrowgey@u.washington.edu>2018-04-03 16:24:06 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2018-04-03 19:24:06 -0400
commit25f2b4e2edc9a162d3d9ecbd9f26e25da4848735 (patch)
treeefebb0ad2c1e46dd104e786325d09e5145d1fd33 /tests/x509/test_x509.py
parent2920a310f29c6a61c0fffccec5bf794abc422b5f (diff)
downloadcryptography-25f2b4e2edc9a162d3d9ecbd9f26e25da4848735.tar.gz
cryptography-25f2b4e2edc9a162d3d9ecbd9f26e25da4848735.tar.bz2
cryptography-25f2b4e2edc9a162d3d9ecbd9f26e25da4848735.zip
Raise ve on bad gt (#4180)
* Raise a ValueError when conversion to generalizedtime fails * added test for badasn1time value error * pep8 compliance * Addressing code review + VE now raises with ```{!r}``` formatting + Test now checks that the bad string made it into the VE message * using ValueError.match
Diffstat (limited to 'tests/x509/test_x509.py')
-rw-r--r--tests/x509/test_x509.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py
index 4a34d4a9..720db78e 100644
--- a/tests/x509/test_x509.py
+++ b/tests/x509/test_x509.py
@@ -3752,6 +3752,18 @@ class TestOtherCertificate(object):
with pytest.raises(ValueError):
cert.public_key()
+ def test_bad_time_in_validity(self, backend):
+ cert = _load_cert(
+ os.path.join(
+ "x509", "badasn1time.pem"
+ ),
+ x509.load_pem_x509_certificate,
+ backend,
+ )
+
+ with pytest.raises(ValueError, match='19020701025736Z'):
+ cert.not_valid_after
+
class TestNameAttribute(object):
EXPECTED_TYPES = [