diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-12-30 10:58:25 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-12-30 10:58:25 -0600 |
commit | 14fd697c5c4a2435b2113e425c95ac9c05702cc2 (patch) | |
tree | 08c194803532e2d49184565a8f7a3cf22b63826f /tests/test_x509_ext.py | |
parent | 42e0c790c5150bec47add345065929ca7df8e6ff (diff) | |
download | cryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.tar.gz cryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.tar.bz2 cryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.zip |
add UnrecognizedExtension class
Diffstat (limited to 'tests/test_x509_ext.py')
-rw-r--r-- | tests/test_x509_ext.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index 7cd24a69..258be12d 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -75,6 +75,57 @@ class TestExtension(object): assert ext1 != object() +class TestUnrecognizedExtension(object): + def test_invalid_oid(self): + with pytest.raises(TypeError): + x509.UnrecognizedExtension("notanoid", b"somedata") + + def test_eq(self): + ext1 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + ext2 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + assert ext1 == ext2 + + def test_ne(self): + ext1 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + ext2 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x02" + ) + ext3 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.5"), b"\x03\x02\x01" + ) + assert ext1 != ext2 + assert ext1 != ext3 + assert ext1 != object() + + def test_repr(self): + ext1 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + assert repr(ext1) == ( + "<UnrecognizedExtension(oid=<ObjectIdentifier(oid=1.2.3.4, name=" + "Unknown OID)>, value='\\x03\\x02\\x01')>" + ) + + def test_hash(self): + ext1 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + ext2 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.4"), b"\x03\x02\x01" + ) + ext3 = x509.UnrecognizedExtension( + x509.ObjectIdentifier("1.2.3.5"), b"\x03\x02\x01" + ) + assert hash(ext1) == hash(ext2) + assert hash(ext1) != hash(ext3) + + class TestCertificateIssuer(object): def test_iter_names(self): ci = x509.CertificateIssuer([ |