From 1bd77e2f4ee2fcdd9233ea36ed74edeee02817c5 Mon Sep 17 00:00:00 2001 From: Joern Heissler Date: Wed, 13 Jan 2016 22:51:37 +0100 Subject: Add verify method on CertificateSigningRequest --- tests/test_x509.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_x509.py b/tests/test_x509.py index 6145edb1..fde0755e 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -18,7 +18,7 @@ import pytest import six from cryptography import utils, x509 -from cryptography.exceptions import UnsupportedAlgorithm +from cryptography.exceptions import UnsupportedAlgorithm, InvalidSignature from cryptography.hazmat.backends.interfaces import ( DSABackend, EllipticCurveBackend, RSABackend, X509Backend ) @@ -1241,6 +1241,24 @@ class TestRSACertificateRequest(object): with pytest.raises(TypeError): request.public_bytes('NotAnEncoding') + def test_verify_bad(self, backend): + request = _load_cert( + os.path.join("x509", "requests", "invalid_signature.pem"), + x509.load_pem_x509_csr, + backend + ) + + with pytest.raises(InvalidSignature): + request.verify() + + def test_verify_good(self, backend): + request = _load_cert( + os.path.join("x509", "requests", "rsa_sha256.pem"), + x509.load_pem_x509_csr, + backend + ) + request.verify() + @pytest.mark.parametrize( ("request_path", "loader_func", "encoding"), [ -- cgit v1.2.3