diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-05-17 13:35:52 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-05-17 13:35:52 -0600 |
commit | 509bacbd475fce046524015ebb5e400e278c73fb (patch) | |
tree | e10d369eabda5e2f737ea6eed9fc7b2bc1c3f728 /tests | |
parent | b0391810fb74bd098592b03ffbb937daeed4561f (diff) | |
parent | 6e721a939f6fff70940ff4272e288f17b193e138 (diff) | |
download | cryptography-509bacbd475fce046524015ebb5e400e278c73fb.tar.gz cryptography-509bacbd475fce046524015ebb5e400e278c73fb.tar.bz2 cryptography-509bacbd475fce046524015ebb5e400e278c73fb.zip |
Merge pull request #1966 from AndreLouisCaron/csr-extensions
Adds support for CSR extensions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_x509.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index 8561f1f4..47c1c647 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -395,6 +395,9 @@ class TestRSACertificate(object): x509.NameAttribute(x509.OID_ORGANIZATION_NAME, 'PyCA'), x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'), ] + extensions = request.extensions + assert isinstance(extensions, x509.Extensions) + assert list(extensions) == [] @pytest.mark.parametrize( "loader_func", @@ -413,6 +416,61 @@ class TestRSACertificate(object): with pytest.raises(UnsupportedAlgorithm): request.signature_hash_algorithm + def test_duplicate_extension(self, backend): + request = _load_cert( + os.path.join( + "x509", "requests", "two_basic_constraints.pem" + ), + x509.load_pem_x509_csr, + backend + ) + with pytest.raises(x509.DuplicateExtension) as exc: + request.extensions + + assert exc.value.oid == x509.OID_BASIC_CONSTRAINTS + + def test_unsupported_critical_extension(self, backend): + request = _load_cert( + os.path.join( + "x509", "requests", "unsupported_extension_critical.pem" + ), + x509.load_pem_x509_csr, + backend + ) + with pytest.raises(x509.UnsupportedExtension) as exc: + request.extensions + + assert exc.value.oid == x509.ObjectIdentifier('1.2.3.4') + + def test_unsupported_extension(self, backend): + request = _load_cert( + os.path.join( + "x509", "requests", "unsupported_extension.pem" + ), + x509.load_pem_x509_csr, + backend + ) + extensions = request.extensions + assert len(extensions) == 0 + + def test_request_basic_constraints(self, backend): + request = _load_cert( + os.path.join( + "x509", "requests", "basic_constraints.pem" + ), + x509.load_pem_x509_csr, + backend + ) + extensions = request.extensions + assert isinstance(extensions, x509.Extensions) + assert list(extensions) == [ + x509.Extension( + x509.OID_BASIC_CONSTRAINTS, + True, + x509.BasicConstraints(True, 1), + ), + ] + @pytest.mark.requires_backend_interface(interface=DSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) |