From 2c91858de5fca63ee56b342d44fee73ed220d547 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 21 Dec 2015 09:25:36 -0600 Subject: add test for byte matching --- tests/test_x509.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/test_x509.py') diff --git a/tests/test_x509.py b/tests/test_x509.py index fecafecc..27ce21e2 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -254,6 +254,30 @@ class TestCertificateRevocationList(object): assert crl.last_update == datetime.datetime(2015, 1, 1, 0, 0, 0) assert crl.next_update == datetime.datetime(2016, 1, 1, 0, 0, 0) + @pytest.mark.parametrize( + ("cert_path", "loader_func", "encoding"), + [ + ( + os.path.join("x509", "custom", "crl_all_reasons.pem"), + x509.load_pem_x509_crl, + serialization.Encoding.PEM, + ), + ( + os.path.join("x509", "PKITS_data", "crls", "GoodCACRL.crl"), + x509.load_der_x509_crl, + serialization.Encoding.DER, + ), + ] + ) + def test_public_bytes_match(self, cert_path, loader_func, encoding, + backend): + crl_bytes = load_vectors_from_file( + cert_path, lambda pemfile: pemfile.read(), mode="rb" + ) + crl = loader_func(crl_bytes, backend) + serialized = crl.public_bytes(encoding) + assert serialized == crl_bytes + def test_public_bytes_invalid_encoding(self, backend): crl = _load_cert( os.path.join("x509", "custom", "crl_empty.pem"), -- cgit v1.2.3