Skip to content

Commit

Permalink
Add test for user-defined extension type.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Oct 19, 2021
1 parent 91d7e66 commit 1b0c7b8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/x509/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

0 comments on commit 1b0c7b8

Please sign in to comment.