aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-24 12:51:14 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-24 12:51:14 -0600
commit1e63b8470ceb4abdada68b8fce03365fbcd37a2a (patch)
tree51b05a9d2e050be14db885020ac73c230fe4d3db /tests/test_x509.py
parentb9d9021b9961c8616b6ed4ec987d76dead284059 (diff)
parentde85d5a3e790dde1da669bbb49a17aadc1ad7122 (diff)
downloadcryptography-1e63b8470ceb4abdada68b8fce03365fbcd37a2a.tar.gz
cryptography-1e63b8470ceb4abdada68b8fce03365fbcd37a2a.tar.bz2
cryptography-1e63b8470ceb4abdada68b8fce03365fbcd37a2a.zip
Merge pull request #2564 from alex/crl-index-perf
Make indexing a CRL O(1) instead of O(n).
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index ab4d6660..755b65fa 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -332,7 +332,6 @@ class TestCertificateRevocationList(object):
@pytest.mark.requires_backend_interface(interface=X509Backend)
class TestRevokedCertificate(object):
-
def test_revoked_basics(self, backend):
crl = _load_cert(
os.path.join("x509", "custom", "crl_all_reasons.pem"),
@@ -460,6 +459,23 @@ class TestRevokedCertificate(object):
with pytest.raises(ValueError):
crl[0].extensions
+ def test_indexing(self, backend):
+ crl = _load_cert(
+ os.path.join("x509", "custom", "crl_all_reasons.pem"),
+ x509.load_pem_x509_crl,
+ backend
+ )
+
+ with pytest.raises(IndexError):
+ crl[-13]
+ with pytest.raises(IndexError):
+ crl[12]
+
+ assert crl[-1].serial_number == crl[11].serial_number
+ assert len(crl[2:4]) == 2
+ assert crl[2:4][0].serial_number == crl[2].serial_number
+ assert crl[2:4][1].serial_number == crl[3].serial_number
+
@pytest.mark.requires_backend_interface(interface=RSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)