X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=tests%2Ftest_crl.py;h=70692303726d28af6bb5b38292c49f146dabf75b;hb=71e8cd567991a1ea9d32f86739a5183aef0677f6;hp=7368d7fc707550bfe57643c87ae39ba2cf88602d;hpb=ec180a333b81b220e5325bdba75dcbc44b4311c6;p=pyderasn.git diff --git a/tests/test_crl.py b/tests/test_crl.py index 7368d7f..7069230 100644 --- a/tests/test_crl.py +++ b/tests/test_crl.py @@ -14,10 +14,19 @@ # You should have received a copy of the GNU Lesser General Public # License along with this program. If not, see # . -"""CRL related schemes, just to test the performance with them +"""CRL related schemas, just to test the performance with them """ +from os.path import exists +from time import time +from unittest import skipIf +from unittest import TestCase + +from six import PY2 + from pyderasn import BitString +from pyderasn import encode_cer +from pyderasn import file_mmaped from pyderasn import Sequence from pyderasn import SequenceOf from pyderasn import tag_ctxc @@ -60,3 +69,31 @@ class CertificateList(Sequence): ("signatureAlgorithm", AlgorithmIdentifier()), ("signatureValue", BitString()), ) + +@skipIf(not exists("revoke.crl"), "CACert's revoke.crl not found") +class TestCACert(TestCase): + def test_cer(self): + with open("revoke.crl", "rb") as fd: + raw = fd.read() + print("DER read") + start = time() + crl1 = CertificateList().decod(raw) + print("DER decoded", time() - start) + start = time() + cer_raw = encode_cer(crl1) + print("CER encoded", time() - start) + start = time() + crl2 = CertificateList().decod(cer_raw, ctx={"bered": True}) + print("CER decoded", time() - start) + self.assertEqual(crl2, crl1) + start = time() + der_raw = crl2.encode() + print("DER encoded", time() - start) + self.assertSequenceEqual(der_raw, raw) + + @skipIf(PY2, "Py27 mmap does not implement buffer protocol") + def test_mmaped(self): + fd = open("revoke.crl", "rb") + start = time() + CertificateList().decod(file_mmaped(fd)) + print("DER decoded", time() - start)