aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-03-30 22:12:46 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-03-30 22:12:46 -0400
commit33bf83fbba6e3a0e2d308160d46865a0ffeb5a8b (patch)
treed549a53d61b314f9b024c9a76e9f2803802b35ef /tests/test_x509.py
parentd10e1ab8bb4630eb8e0902b37e9e4ea2013bd349 (diff)
parent1effb6e11ef4248c65b37a97dfe9dd0c2710882e (diff)
downloadcryptography-33bf83fbba6e3a0e2d308160d46865a0ffeb5a8b.tar.gz
cryptography-33bf83fbba6e3a0e2d308160d46865a0ffeb5a8b.tar.bz2
cryptography-33bf83fbba6e3a0e2d308160d46865a0ffeb5a8b.zip
Merge pull request #1801 from reaperhulk/x509-request-der
X509 request DER parsing
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py71
1 files changed, 51 insertions, 20 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 22b93f61..dc148d9d 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -340,12 +340,21 @@ class TestRSACertificate(object):
with pytest.raises(UnsupportedAlgorithm):
cert.signature_hash_algorithm
- def test_load_rsa_certificate_request(self, backend):
- request = _load_cert(
- os.path.join("x509", "requests", "rsa_sha1.pem"),
- x509.load_pem_x509_csr,
- backend
- )
+ @pytest.mark.parametrize(
+ ("path", "loader_func"),
+ [
+ [
+ os.path.join("x509", "requests", "rsa_sha1.pem"),
+ x509.load_pem_x509_csr
+ ],
+ [
+ os.path.join("x509", "requests", "rsa_sha1.der"),
+ x509.load_der_x509_csr
+ ],
+ ]
+ )
+ def test_load_rsa_certificate_request(self, path, loader_func, backend):
+ request = _load_cert(path, loader_func, backend)
assert isinstance(request.signature_hash_algorithm, hashes.SHA1)
public_key = request.public_key()
assert isinstance(public_key, rsa.RSAPublicKey)
@@ -359,9 +368,13 @@ class TestRSACertificate(object):
x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'),
]
- def test_invalid_certificate_request_pem(self, backend):
+ @pytest.mark.parametrize(
+ "loader_func",
+ [x509.load_pem_x509_csr, x509.load_der_x509_csr]
+ )
+ def test_invalid_certificate_request(self, loader_func, backend):
with pytest.raises(ValueError):
- x509.load_pem_x509_csr(b"notacsr", backend)
+ loader_func(b"notacsr", backend)
def test_unsupported_signature_hash_algorithm_request(self, backend):
request = _load_cert(
@@ -424,12 +437,21 @@ class TestDSACertificate(object):
"822ff5d234e073b901cf5941f58e1f538e71d40d", 16
)
- def test_load_dsa_request(self, backend):
- request = _load_cert(
- os.path.join("x509", "requests", "dsa_sha1.pem"),
- x509.load_pem_x509_csr,
- backend
- )
+ @pytest.mark.parametrize(
+ ("path", "loader_func"),
+ [
+ [
+ os.path.join("x509", "requests", "dsa_sha1.pem"),
+ x509.load_pem_x509_csr
+ ],
+ [
+ os.path.join("x509", "requests", "dsa_sha1.der"),
+ x509.load_der_x509_csr
+ ],
+ ]
+ )
+ def test_load_dsa_request(self, path, loader_func, backend):
+ request = _load_cert(path, loader_func, backend)
assert isinstance(request.signature_hash_algorithm, hashes.SHA1)
public_key = request.public_key()
assert isinstance(public_key, dsa.DSAPublicKey)
@@ -479,13 +501,22 @@ class TestECDSACertificate(object):
with pytest.raises(NotImplementedError):
cert.public_key()
- def test_load_ecdsa_certificate_request(self, backend):
+ @pytest.mark.parametrize(
+ ("path", "loader_func"),
+ [
+ [
+ os.path.join("x509", "requests", "ec_sha256.pem"),
+ x509.load_pem_x509_csr
+ ],
+ [
+ os.path.join("x509", "requests", "ec_sha256.der"),
+ x509.load_der_x509_csr
+ ],
+ ]
+ )
+ def test_load_ecdsa_certificate_request(self, path, loader_func, backend):
_skip_curve_unsupported(backend, ec.SECP384R1())
- request = _load_cert(
- os.path.join("x509", "requests", "ec_sha256.pem"),
- x509.load_pem_x509_csr,
- backend
- )
+ request = _load_cert(path, loader_func, backend)
assert isinstance(request.signature_hash_algorithm, hashes.SHA256)
public_key = request.public_key()
assert isinstance(public_key, ec.EllipticCurvePublicKey)