aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-25 16:17:40 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-25 20:19:17 -0600
commit49bb7565120b181752dc2574cd0e3660393c707c (patch)
tree719427d25f47ae295dd44f6707d83cc8333b859d /tests
parent4f76921ad87d71067158625aa0afedbba8ae1314 (diff)
downloadcryptography-49bb7565120b181752dc2574cd0e3660393c707c.tar.gz
cryptography-49bb7565120b181752dc2574cd0e3660393c707c.tar.bz2
cryptography-49bb7565120b181752dc2574cd0e3660393c707c.zip
start switching the CRL entry extensions to be full-fledged classes
first up: CertificateIssuer
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509.py13
-rw-r--r--tests/test_x509_ext.py38
2 files changed, 44 insertions, 7 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 755b65fa..c91f08ba 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -355,12 +355,12 @@ class TestRevokedCertificate(object):
backend
)
- exp_issuer = x509.GeneralNames([
+ exp_issuer = [
x509.DirectoryName(x509.Name([
x509.NameAttribute(x509.OID_COUNTRY_NAME, u"US"),
x509.NameAttribute(x509.OID_COMMON_NAME, u"cryptography.io"),
]))
- ])
+ ]
# First revoked cert doesn't have extensions, test if it is handled
# correctly.
@@ -383,14 +383,13 @@ class TestRevokedCertificate(object):
x509.OID_CRL_REASON).value
assert reason == x509.ReasonFlags.unspecified
- issuer = rev1.extensions.get_extension_for_oid(
- x509.OID_CERTIFICATE_ISSUER).value
- assert issuer == exp_issuer
+ issuer = rev1.extensions.get_extension_for_class(
+ x509.CertificateIssuer).value
+ assert issuer == x509.CertificateIssuer(exp_issuer)
date = rev1.extensions.get_extension_for_oid(
x509.OID_INVALIDITY_DATE).value
- assert isinstance(date, datetime.datetime)
- assert date.isoformat() == "2015-01-01T00:00:00"
+ assert date == datetime.datetime(2015, 1, 1, 0, 0)
# Check if all reason flags can be found in the CRL.
flags = set(x509.ReasonFlags)
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index d9743c8e..f124a286 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -74,6 +74,44 @@ class TestExtension(object):
assert ext1 != object()
+class TestCertificateIssuer(object):
+ def test_iter_names(self):
+ ci = x509.CertificateIssuer([
+ x509.DNSName(u"cryptography.io"),
+ x509.DNSName(u"crypto.local"),
+ ])
+ assert len(ci) == 2
+ assert list(ci) == [
+ x509.DNSName(u"cryptography.io"),
+ x509.DNSName(u"crypto.local"),
+ ]
+
+ def test_eq(self):
+ ci1 = x509.CertificateIssuer([x509.DNSName(u"cryptography.io")])
+ ci2 = x509.CertificateIssuer([x509.DNSName(u"cryptography.io")])
+ assert ci1 == ci2
+
+ def test_ne(self):
+ ci1 = x509.CertificateIssuer([x509.DNSName(u"cryptography.io")])
+ ci2 = x509.CertificateIssuer([x509.DNSName(u"somethingelse.tld")])
+ assert ci1 != ci2
+ assert ci1 != object()
+
+ def test_repr(self):
+ ci = x509.CertificateIssuer([x509.DNSName(u"cryptography.io")])
+ assert repr(ci) == (
+ "<CertificateIssuer(<GeneralNames([<DNSName(value=cryptography.io"
+ ")>])>)>"
+ )
+
+ def test_get_values_for_type(self):
+ ci = x509.CertificateIssuer(
+ [x509.DNSName(u"cryptography.io")]
+ )
+ names = ci.get_values_for_type(x509.DNSName)
+ assert names == [u"cryptography.io"]
+
+
class TestNoticeReference(object):
def test_notice_numbers_not_all_int(self):
with pytest.raises(TypeError):