From ecae981f3a17236caee76bc95c5881db0b0d39b3 Mon Sep 17 00:00:00 2001 From: Phoebe Queen Date: Wed, 12 Aug 2015 05:00:32 +0100 Subject: added test to raise error --- tests/test_x509_ext.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_x509_ext.py') diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index 2d3339c3..040347db 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -832,6 +832,22 @@ class TestExtensions(object): extensions = cert.extensions assert len(extensions) == 0 + def test_no_extensions_get_for_class(self, backend): + cert = _load_cert( + os.path.join( + "x509", "verisign_md2_root.pem" + ), + x509.load_pem_x509_certificate, + backend + ) + ext = cert.extensions + assert len(ext) == 0 + assert list(ext) == [] + with pytest.raises(x509.ExtensionNotFound) as exc: + ext.get_extension_for_class(x509.BasicConstraints) + + assert exc.value.oid == ExtensionOID.BASIC_CONSTRAINTS + def test_one_extension_get_for_class(self, backend): cert = _load_cert( os.path.join( -- cgit v1.2.3