From 1b0c7b845c14cf39f3b3b44d6bba6c97ea6631ad Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 19 Oct 2021 13:06:16 +0200 Subject: [PATCH] Add test for user-defined extension type. --- tests/x509/test_x509_ext.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index 93e68222259f2..be76bb3cf90f5 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -18,7 +18,10 @@ from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec from cryptography.x509 import DNSName, NameConstraints, SubjectAlternativeName -from cryptography.x509.extensions import _key_identifier_from_public_key +from cryptography.x509.extensions import ( + _key_identifier_from_public_key, + ExtensionType, +) from cryptography.x509.oid import ( AuthorityInformationAccessOID, ExtendedKeyUsageOID, @@ -5719,3 +5722,11 @@ def test_all_extension_oid_members_have_names_defined(): if oid.startswith("__"): continue assert getattr(ExtensionOID, oid) in _OID_NAMES + + +def test_unknown_extension(): + class MyExtension(ExtensionType): + oid = x509.ObjectIdentifier("1.2.3.4") + + with pytest.raises(NotImplementedError): + MyExtension().to_der_string()