aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-11-26 10:59:03 -1000
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-15 15:49:48 -0600
commita9d78c13ea2996c896d3dfda8b7e887c444ec4cb (patch)
treebeebfb298c44439855ef12192c466f080e2c9ffe /tests
parent016e08abddf9fdc507da4f6c6f548c3dfee1b389 (diff)
downloadcryptography-a9d78c13ea2996c896d3dfda8b7e887c444ec4cb.tar.gz
cryptography-a9d78c13ea2996c896d3dfda8b7e887c444ec4cb.tar.bz2
cryptography-a9d78c13ea2996c896d3dfda8b7e887c444ec4cb.zip
update docs, test invalid x509 version
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 97102946..eac8a307 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -12,10 +12,11 @@ import textwrap
import pytest
from cryptography import x509
+from cryptography.exceptions import InvalidX509Version
from cryptography.hazmat.backends.interfaces import RSABackend, X509Backend
from cryptography.hazmat.primitives import interfaces
-from .hazmat.primitives.utils import load_vectors_from_file
+from .utils import load_vectors_from_file
def _der_to_pem(data):
@@ -83,3 +84,13 @@ class TestX509Certificate(object):
assert cert.not_before == datetime.datetime(2010, 1, 1, 8, 30)
assert cert.not_after == datetime.datetime(2050, 1, 1, 12, 1)
assert cert.version == x509.X509Version.v3
+
+ def test_invalid_version_cert(self, backend):
+ cert = load_vectors_from_file(
+ os.path.join("x509", "custom", "invalid_version.pem"),
+ lambda pemfile: x509.load_pem_x509_certificate(
+ pemfile.read(), backend
+ )
+ )
+ with pytest.raises(InvalidX509Version):
+ cert.version