diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-02-10 17:22:16 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-02-10 17:22:16 -0500 |
commit | cd18ac09b20670a6e448d778a684ecffdf01c3c6 (patch) | |
tree | debc8542d9004686567acc2103274d518f24bb17 /tests | |
parent | 7d93ad6f654313f86320153b797e34a5959c42eb (diff) | |
parent | 4bb464995cae1b1f86d383fb668f9c5276b3d059 (diff) | |
download | cryptography-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')
-rw-r--r-- | tests/test_x509.py | 42 |
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)>" |