aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-12-26 12:05:51 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-12-26 12:05:51 -0500
commitd67d77f666417bff7ea52e2754f7a680c7a83b0c (patch)
tree796e8feff62e053b9a73626402424e322dfe48bd /tests
parent0860ef60adc7974dc26cfdd3c7adeb5e4e6e6448 (diff)
parent7058eced3a27115f721887e836d16ee4fe4c7e9d (diff)
downloadcryptography-d67d77f666417bff7ea52e2754f7a680c7a83b0c.tar.gz
cryptography-d67d77f666417bff7ea52e2754f7a680c7a83b0c.tar.bz2
cryptography-d67d77f666417bff7ea52e2754f7a680c7a83b0c.zip
Merge pull request #2579 from reaperhulk/crlentry-crlreason
switch CRLReason to use a class
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509.py10
-rw-r--r--tests/test_x509_ext.py23
2 files changed, 28 insertions, 5 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index c91f08ba..757df442 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -379,9 +379,9 @@ class TestRevokedCertificate(object):
rev1 = crl[1]
assert isinstance(rev1.extensions, x509.Extensions)
- reason = rev1.extensions.get_extension_for_oid(
- x509.OID_CRL_REASON).value
- assert reason == x509.ReasonFlags.unspecified
+ reason = rev1.extensions.get_extension_for_class(
+ x509.CRLReason).value
+ assert reason == x509.CRLReason(x509.ReasonFlags.unspecified)
issuer = rev1.extensions.get_extension_for_class(
x509.CertificateIssuer).value
@@ -395,12 +395,12 @@ class TestRevokedCertificate(object):
flags = set(x509.ReasonFlags)
for rev in crl:
try:
- r = rev.extensions.get_extension_for_oid(x509.OID_CRL_REASON)
+ r = rev.extensions.get_extension_for_class(x509.CRLReason)
except x509.ExtensionNotFound:
# Not all revoked certs have a reason extension.
pass
else:
- flags.discard(r.value)
+ flags.discard(r.value.reason)
assert len(flags) == 0
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 037512a4..b8105a4b 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -112,6 +112,29 @@ class TestCertificateIssuer(object):
assert names == [u"cryptography.io"]
+class TestCRLReason(object):
+ def test_invalid_reason_flags(self):
+ with pytest.raises(TypeError):
+ x509.CRLReason("notareason")
+
+ def test_eq(self):
+ reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ reason2 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ assert reason1 == reason2
+
+ def test_ne(self):
+ reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ reason2 = x509.CRLReason(x509.ReasonFlags.ca_compromise)
+ assert reason1 != reason2
+ assert reason1 != object()
+
+ def test_repr(self):
+ reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ assert repr(reason1) == (
+ "<CRLReason(reason=ReasonFlags.unspecified)>"
+ )
+
+
class TestNoticeReference(object):
def test_notice_numbers_not_all_int(self):
with pytest.raises(TypeError):