diff options
-rw-r--r-- | src/cryptography/x509/extensions.py | 3 | ||||
-rw-r--r-- | tests/test_x509_ext.py | 26 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index ac70cc18..1cd6a6d0 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -382,6 +382,9 @@ class CRLDistributionPoints(object): def __ne__(self, other): return not self == other + def __getitem__(self, idx): + return self._distribution_points[idx] + class DistributionPoint(object): def __init__(self, full_name, relative_name, reasons, crl_issuer): diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index 92e6e1a2..91833215 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -2964,6 +2964,32 @@ class TestCRLDistributionPoints(object): assert cdp != cdp4 assert cdp != object() + def test_indexing(self): + ci = x509.CRLDistributionPoints([ + x509.DistributionPoint( + None, None, None, + [x509.UniformResourceIdentifier(u"uri://thing")], + ), + x509.DistributionPoint( + None, None, None, + [x509.UniformResourceIdentifier(u"uri://thing2")], + ), + x509.DistributionPoint( + None, None, None, + [x509.UniformResourceIdentifier(u"uri://thing3")], + ), + x509.DistributionPoint( + None, None, None, + [x509.UniformResourceIdentifier(u"uri://thing4")], + ), + x509.DistributionPoint( + None, None, None, + [x509.UniformResourceIdentifier(u"uri://thing5")], + ), + ]) + assert ci[-1] == ci[4] + assert ci[2:6:2] == [ci[2], ci[4]] + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) |