diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-05-12 07:10:13 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-05-12 07:10:13 -0400 |
commit | cb599d3be59d05ef102759d02069c50466db869c (patch) | |
tree | fec5a629729f72d8373b2a3aa14618c84a62d608 /tests/test_x509_ext.py | |
parent | c6f6a247bf281d4307bcb76be873a743660d0438 (diff) | |
parent | c56ab62c5bce544948825051cdcbf039093d1da4 (diff) | |
download | cryptography-cb599d3be59d05ef102759d02069c50466db869c.tar.gz cryptography-cb599d3be59d05ef102759d02069c50466db869c.tar.bz2 cryptography-cb599d3be59d05ef102759d02069c50466db869c.zip |
Merge pull request #1928 from reaperhulk/cp-eq
add eq/ne methods for all certificate policies classes
Diffstat (limited to 'tests/test_x509_ext.py')
-rw-r--r-- | tests/test_x509_ext.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index ae69f5fc..f07792d5 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -63,6 +63,19 @@ class TestNoticeReference(object): "4])>" ) + def test_eq(self): + nr = x509.NoticeReference("org", [1, 2]) + nr2 = x509.NoticeReference("org", [1, 2]) + assert nr == nr2 + + def test_ne(self): + nr = x509.NoticeReference("org", [1, 2]) + nr2 = x509.NoticeReference("org", [1]) + nr3 = x509.NoticeReference(None, [1, 2]) + assert nr != nr2 + assert nr != nr3 + assert nr != object() + class TestUserNotice(object): def test_notice_reference_invalid(self): @@ -87,6 +100,23 @@ class TestUserNotice(object): "'org', notice_numbers=None)>, explicit_text=u'text')>" ) + def test_eq(self): + nr = x509.NoticeReference("org", [1, 2]) + nr2 = x509.NoticeReference("org", [1, 2]) + un = x509.UserNotice(nr, "text") + un2 = x509.UserNotice(nr2, "text") + assert un == un2 + + def test_ne(self): + nr = x509.NoticeReference("org", [1, 2]) + nr2 = x509.NoticeReference("org", [1]) + un = x509.UserNotice(nr, "text") + un2 = x509.UserNotice(nr2, "text") + un3 = x509.UserNotice(nr, "text3") + assert un != un2 + assert un != un3 + assert un != object() + class TestPolicyInformation(object): def test_invalid_policy_identifier(self): @@ -124,6 +154,31 @@ class TestPolicyInformation(object): "otice(notice_reference=None, explicit_text=u'hi')>])>" ) + def test_eq(self): + pi = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), + [u"string", x509.UserNotice(None, u"hi")] + ) + pi2 = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), + [u"string", x509.UserNotice(None, u"hi")] + ) + assert pi == pi2 + + def test_ne(self): + pi = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string"] + ) + pi2 = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string2"] + ) + pi3 = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3.4"), [u"string"] + ) + assert pi != pi2 + assert pi != pi3 + assert pi != object() + class TestCertificatePolicies(object): def test_invalid_policies(self): @@ -157,6 +212,29 @@ class TestCertificatePolicies(object): "ers=[u'string'])>])>" ) + def test_eq(self): + pi = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string"] + ) + cp = x509.CertificatePolicies([pi]) + pi2 = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string"] + ) + cp2 = x509.CertificatePolicies([pi2]) + assert cp == cp2 + + def test_ne(self): + pi = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string"] + ) + cp = x509.CertificatePolicies([pi]) + pi2 = x509.PolicyInformation( + x509.ObjectIdentifier("1.2.3"), [u"string2"] + ) + cp2 = x509.CertificatePolicies([pi2]) + assert cp != cp2 + assert cp != object() + class TestKeyUsage(object): def test_key_agreement_false_encipher_decipher_true(self): |