diff options
author | Joshua Tauberer <jt@occams.info> | 2015-07-05 21:44:51 +0000 |
---|---|---|
committer | Joshua Tauberer <jt@occams.info> | 2015-07-06 23:01:22 +0000 |
commit | 18b6fc84fcb671412aaaf453f623a44a30a1a2a3 (patch) | |
tree | 265940ebc04f7e5c198138cd438fbc0390bc5134 /tests | |
parent | 2ee5e3c6240721120146d6d81c70e1b900029ee0 (diff) | |
download | cryptography-18b6fc84fcb671412aaaf453f623a44a30a1a2a3.tar.gz cryptography-18b6fc84fcb671412aaaf453f623a44a30a1a2a3.tar.bz2 cryptography-18b6fc84fcb671412aaaf453f623a44a30a1a2a3.zip |
additional tests and doc spelling error fix for OtherName
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_x509_ext.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index 06adaa37..e6ee7d66 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -1147,6 +1147,55 @@ class TestIPAddress(object): assert gn != object() +class TestOtherName(object): + def test_invalid_args(self): + with pytest.raises(TypeError): + x509.OtherName(b"notanobjectidentifier", b"derdata") + + with pytest.raises(TypeError): + x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), u"notderdata") + + def test_repr(self): + gn = x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), b"derdata") + if six.PY3: + assert repr(gn) == ( + "<OtherName(type_id=<ObjectIdentifier(oid=1.2.3.4, " + "name=Unknown OID)>, value=b'derdata')>" + ) + else: + assert repr(gn) == ( + "<OtherName(type_id=<ObjectIdentifier(oid=1.2.3.4, " + "name=Unknown OID)>, value='derdata')>" + ) + + gn = x509.OtherName(x509.ObjectIdentifier("2.5.4.65"), b"derdata") + if six.PY3: + assert repr(gn) == ( + "<OtherName(type_id=<ObjectIdentifier(oid=2.5.4.65, " + "name=pseudonym)>, value=b'derdata')>" + ) + else: + assert repr(gn) == ( + "<OtherName(type_id=<ObjectIdentifier(oid=2.5.4.65, " + "name=pseudonym)>, value='derdata')>" + ) + + def test_eq(self): + gn = x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), b"derdata") + gn2 = x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), b"derdata") + assert gn == gn2 + + def test_ne(self): + gn = x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), b"derdata") + assert gn != object() + + gn2 = x509.OtherName(x509.ObjectIdentifier("1.2.3.4"), b"derdata2") + assert gn != gn2 + + gn2 = x509.OtherName(x509.ObjectIdentifier("1.2.3.5"), b"derdata") + assert gn != gn2 + + class TestGeneralNames(object): def test_get_values_for_type(self): gns = x509.GeneralNames( |