1# coding: utf-8 2from __future__ import unicode_literals, division, absolute_import, print_function 3 4import unittest 5import sys 6import os 7 8from asn1crypto import crl 9 10from ._unittest_compat import patch 11 12patch() 13 14if sys.version_info < (3,): 15 byte_cls = str 16 num_cls = long # noqa 17else: 18 byte_cls = bytes 19 num_cls = int 20 21 22tests_root = os.path.dirname(__file__) 23fixtures_dir = os.path.join(tests_root, 'fixtures') 24 25 26class CRLTests(unittest.TestCase): 27 28 def test_parse_crl(self): 29 with open(os.path.join(fixtures_dir, 'eid2011.crl'), 'rb') as f: 30 cert_list = crl.CertificateList.load(f.read()) 31 serial_numbers = [] 32 for revoked_cert in cert_list['tbs_cert_list']['revoked_certificates']: 33 serial_numbers.append(revoked_cert['user_certificate'].native) 34 self.assertEqual( 35 15752, 36 len(serial_numbers) 37 ) 38 for serial_number in serial_numbers: 39 self.assertIsInstance( 40 serial_number, 41 num_cls 42 ) 43