From 9f71bf79971d5365a4a89cfbc6b29197a57e9042 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 24 Dec 2015 11:04:21 -0500 Subject: tests on indexing --- tests/test_x509.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/test_x509.py') diff --git a/tests/test_x509.py b/tests/test_x509.py index ab4d6660..099dfd5f 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,18 @@ class TestRevokedCertificate(object): with pytest.raises(ValueError): crl[0].extensions + def test_indexing(self, backend): + crl = _load_cert( + os.path.join("x509", "custom", "crl_empty.pem"), + x509.load_pem_x509_crl, + backend + ) + + with pytest.raises(IndexError): + crl[-1] + with pytest.raises(IndexError): + crl[0] + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) -- cgit v1.2.3 From a3fa8d6872d32005e6e600e27a48343d2f21d13d Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 24 Dec 2015 11:34:24 -0500 Subject: full indexing support + testsg --- tests/test_x509.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/test_x509.py') diff --git a/tests/test_x509.py b/tests/test_x509.py index 099dfd5f..755b65fa 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -461,15 +461,20 @@ class TestRevokedCertificate(object): def test_indexing(self, backend): crl = _load_cert( - os.path.join("x509", "custom", "crl_empty.pem"), + os.path.join("x509", "custom", "crl_all_reasons.pem"), x509.load_pem_x509_crl, backend ) with pytest.raises(IndexError): - crl[-1] + crl[-13] with pytest.raises(IndexError): - crl[0] + 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) -- cgit v1.2.3