aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-02-10 17:22:16 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-02-10 17:22:16 -0500
commitcd18ac09b20670a6e448d778a684ecffdf01c3c6 (patch)
treedebc8542d9004686567acc2103274d518f24bb17 /tests/test_x509.py
parent7d93ad6f654313f86320153b797e34a5959c42eb (diff)
parent4bb464995cae1b1f86d383fb668f9c5276b3d059 (diff)
downloadcryptography-cd18ac09b20670a6e448d778a684ecffdf01c3c6.tar.gz
cryptography-cd18ac09b20670a6e448d778a684ecffdf01c3c6.tar.bz2
cryptography-cd18ac09b20670a6e448d778a684ecffdf01c3c6.zip
Merge pull request #1645 from reaperhulk/x509-attrs
add attribute and objectidentifier classes for x509 name
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 5383871a..cf583247 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -248,3 +248,45 @@ class TestECDSACertificate(object):
)
with pytest.raises(NotImplementedError):
cert.public_key()
+
+
+class TestNameAttribute(object):
+ def test_eq(self):
+ assert x509.NameAttribute(
+ x509.ObjectIdentifier('oid'), 'value'
+ ) == x509.NameAttribute(
+ x509.ObjectIdentifier('oid'), 'value'
+ )
+
+ def test_ne(self):
+ assert x509.NameAttribute(
+ x509.ObjectIdentifier('2.5.4.3'), 'value'
+ ) != x509.NameAttribute(
+ x509.ObjectIdentifier('2.5.4.5'), 'value'
+ )
+ assert x509.NameAttribute(
+ x509.ObjectIdentifier('oid'), 'value'
+ ) != x509.NameAttribute(
+ x509.ObjectIdentifier('oid'), 'value2'
+ )
+ assert x509.NameAttribute(
+ x509.ObjectIdentifier('oid'), 'value'
+ ) != object()
+
+
+class TestObjectIdentifier(object):
+ def test_eq(self):
+ oid1 = x509.ObjectIdentifier('oid')
+ oid2 = x509.ObjectIdentifier('oid')
+ assert oid1 == oid2
+
+ def test_ne(self):
+ oid1 = x509.ObjectIdentifier('oid')
+ assert oid1 != x509.ObjectIdentifier('oid1')
+ assert oid1 != object()
+
+ def test_repr(self):
+ oid = x509.ObjectIdentifier("2.5.4.3")
+ assert repr(oid) == "<ObjectIdentifier(oid=2.5.4.3, name=commonName)>"
+ oid = x509.ObjectIdentifier("oid1")
+ assert repr(oid) == "<ObjectIdentifier(oid=oid1, name=Unknown OID)>"