aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorAndre Caron <andre.l.caron@gmail.com>2015-05-18 21:04:15 -0400
committerAndre Caron <andre.l.caron@gmail.com>2015-05-18 21:04:15 -0400
commitacb18976be0b7d23f63ab4242801eb8d8b11cba2 (patch)
tree85495368f058e4cc13d3b36bb910fe3b848b8a02 /tests/test_x509.py
parentf27e4f4f1a3c3ecebc6075e16f9b56eba1914303 (diff)
downloadcryptography-acb18976be0b7d23f63ab4242801eb8d8b11cba2.tar.gz
cryptography-acb18976be0b7d23f63ab4242801eb8d8b11cba2.tar.bz2
cryptography-acb18976be0b7d23f63ab4242801eb8d8b11cba2.zip
Adds public bytes comparison test.
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 70d5d646..72fc9d40 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -535,6 +535,30 @@ class TestRSACertificate(object):
with pytest.raises(TypeError):
request.public_bytes('NotAnEncoding')
+ @pytest.mark.parametrize(
+ ("request_path", "loader_func", "encoding"),
+ [
+ (
+ os.path.join("x509", "requests", "rsa_sha1.pem"),
+ x509.load_pem_x509_csr,
+ serialization.Encoding.PEM,
+ ),
+ (
+ os.path.join("x509", "requests", "rsa_sha1.der"),
+ x509.load_der_x509_csr,
+ serialization.Encoding.DER,
+ ),
+ ]
+ )
+ def test_public_bytes_match(self, request_path, loader_func, encoding,
+ backend):
+ request_bytes = load_vectors_from_file(
+ request_path, lambda pemfile: pemfile.read(), mode="rb"
+ )
+ request = loader_func(request_bytes, backend)
+ serialized = request.public_bytes(encoding)
+ assert serialized == request_bytes
+
@pytest.mark.requires_backend_interface(interface=DSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)