mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
add x509-crl parser tests
This commit is contained in:
1
tests/fixtures/generic/x509-crl-der.json
vendored
Normal file
1
tests/fixtures/generic/x509-crl-der.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
tests/fixtures/generic/x509-crl.der
vendored
Normal file
BIN
tests/fixtures/generic/x509-crl.der
vendored
Normal file
Binary file not shown.
1
tests/fixtures/generic/x509-crl.json
vendored
Normal file
1
tests/fixtures/generic/x509-crl.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"tbs_cert_list":{"version":"v2","signature":{"algorithm":"sha1_rsa","parameters":null},"issuer":{"organization_name":"Sample Signer Organization","organizational_unit_name":"Sample Signer Unit","common_name":"Sample Signer Cert"},"this_update":1361183520,"next_update":1361184120,"revoked_certificates":[{"user_certificate":1341767,"revocation_date":1361182932,"crl_entry_extensions":[{"extn_id":"crl_reason","critical":false,"extn_value":"affiliation_changed"},{"extn_id":"invalidity_date","critical":false,"extn_value":1361182920,"extn_value_iso":"2013-02-18T10:22:00+00:00"}],"revocation_date_iso":"2013-02-18T10:22:12+00:00"},{"user_certificate":1341768,"revocation_date":1361182942,"crl_entry_extensions":[{"extn_id":"crl_reason","critical":false,"extn_value":"certificate_hold"},{"extn_id":"invalidity_date","critical":false,"extn_value":1361182920,"extn_value_iso":"2013-02-18T10:22:00+00:00"}],"revocation_date_iso":"2013-02-18T10:22:22+00:00"},{"user_certificate":1341769,"revocation_date":1361182952,"crl_entry_extensions":[{"extn_id":"crl_reason","critical":false,"extn_value":"superseded"},{"extn_id":"invalidity_date","critical":false,"extn_value":1361182920,"extn_value_iso":"2013-02-18T10:22:00+00:00"}],"revocation_date_iso":"2013-02-18T10:22:32+00:00"},{"user_certificate":1341770,"revocation_date":1361182962,"crl_entry_extensions":[{"extn_id":"crl_reason","critical":false,"extn_value":"key_compromise"},{"extn_id":"invalidity_date","critical":false,"extn_value":1361182920,"extn_value_iso":"2013-02-18T10:22:00+00:00"}],"revocation_date_iso":"2013-02-18T10:22:42+00:00"},{"user_certificate":1341771,"revocation_date":1361182971,"crl_entry_extensions":[{"extn_id":"crl_reason","critical":false,"extn_value":"cessation_of_operation"},{"extn_id":"invalidity_date","critical":false,"extn_value":1361182920,"extn_value_iso":"2013-02-18T10:22:00+00:00"}],"revocation_date_iso":"2013-02-18T10:22:51+00:00"}],"crl_extensions":[{"extn_id":"authority_key_identifier","critical":false,"extn_value":{"key_identifier":"be:12:01:cc:aa:ea:11:80:da:2e:ad:b2:ea:c7:b5:fb:9f:f9:ad:34","authority_cert_issuer":null,"authority_cert_serial_number":null}},{"extn_id":"crl_number","critical":false,"extn_value":3}],"this_update_iso":"2013-02-18T10:32:00+00:00","next_update_iso":"2013-02-18T10:42:00+00:00"},"signature_algorithm":{"algorithm":"sha1_rsa","parameters":null},"signature":"42:21:be:81:f1:c3:79:76:66:5b:ce:21:13:8a:68:a8:b4:3c:be:16:c3:af:4b:dd:cb:78:35:92:90:d8:d7:4c:6f:fe:6c:68:27:ae:6d:da:42:98:01:ee:17:93:f0:bd:a8:ee:cd:90:b6:35:f6:0d:a4:ce:49:82:f7:9d:9f:c8:6e:7f:d1:f1:2d:20:f8:46:cd:43:17:64:e7:f9:5a:e8:21:11:c6:24:69:f8:4d:93:50:6f:0b:0d:bd:78:61:53:21:44:62:af:0a:0b:92:23:25:06:d0:cc:06:5b:ac:1a:a9:5b:5d:e8:ae:f5:bb:bb:e1:21:4f:d3:89:d7:fa:65:27:6c:4c:c8:69:3c:f1:6e:3d:48:9d:e2:3d:bd:53:7a:b5:d1:21:85:17:a7:02:b7:50:f3:8e:f5:1c:0b:01:c6:84:70:34:d8:c7:a7:ef:41:20:64:50:03:3c:b5:a6:2e:0d:07:82:52:94:87:58:99:59:c0:46:b5:eb:ff:f1:5b:14:8a:3c:a3:b0:cd:3b:d8:2e:94:b7:94:f0:37:2a:eb:b6:16:fd:e7:6f:9e:2a:59:b1:2c:d8:13:d2:8e:61:55:8c:63:5e:1b:70:2d:0b:0b:ed:06:61:af:2a:40:33:50:cb:62:a4:23:92:20:c8:ee:19:6f:b7:b4:2e:0c:64:c9"}
|
19
tests/fixtures/generic/x509-crl.pem
vendored
Normal file
19
tests/fixtures/generic/x509-crl.pem
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
-----BEGIN X509 CRL-----
|
||||
MIIDFDCCAfwCAQEwDQYJKoZIhvcNAQEFBQAwXzEjMCEGA1UEChMaU2FtcGxlIFNp
|
||||
Z25lciBPcmdhbml6YXRpb24xGzAZBgNVBAsTElNhbXBsZSBTaWduZXIgVW5pdDEb
|
||||
MBkGA1UEAxMSU2FtcGxlIFNpZ25lciBDZXJ0Fw0xMzAyMTgxMDMyMDBaFw0xMzAy
|
||||
MTgxMDQyMDBaMIIBNjA8AgMUeUcXDTEzMDIxODEwMjIxMlowJjAKBgNVHRUEAwoB
|
||||
AzAYBgNVHRgEERgPMjAxMzAyMTgxMDIyMDBaMDwCAxR5SBcNMTMwMjE4MTAyMjIy
|
||||
WjAmMAoGA1UdFQQDCgEGMBgGA1UdGAQRGA8yMDEzMDIxODEwMjIwMFowPAIDFHlJ
|
||||
Fw0xMzAyMTgxMDIyMzJaMCYwCgYDVR0VBAMKAQQwGAYDVR0YBBEYDzIwMTMwMjE4
|
||||
MTAyMjAwWjA8AgMUeUoXDTEzMDIxODEwMjI0MlowJjAKBgNVHRUEAwoBATAYBgNV
|
||||
HRgEERgPMjAxMzAyMTgxMDIyMDBaMDwCAxR5SxcNMTMwMjE4MTAyMjUxWjAmMAoG
|
||||
A1UdFQQDCgEFMBgGA1UdGAQRGA8yMDEzMDIxODEwMjIwMFqgLzAtMB8GA1UdIwQY
|
||||
MBaAFL4SAcyq6hGA2i6tsurHtfuf+a00MAoGA1UdFAQDAgEDMA0GCSqGSIb3DQEB
|
||||
BQUAA4IBAQBCIb6B8cN5dmZbziETimiotDy+FsOvS93LeDWSkNjXTG/+bGgnrm3a
|
||||
QpgB7heT8L2o7s2QtjX2DaTOSYL3nZ/Ibn/R8S0g+EbNQxdk5/la6CERxiRp+E2T
|
||||
UG8LDb14YVMhRGKvCguSIyUG0MwGW6waqVtd6K71u7vhIU/Tidf6ZSdsTMhpPPFu
|
||||
PUid4j29U3q10SGFF6cCt1DzjvUcCwHGhHA02Men70EgZFADPLWmLg0HglKUh1iZ
|
||||
WcBGtev/8VsUijyjsM072C6Ut5TwNyrrthb952+eKlmxLNgT0o5hVYxjXhtwLQsL
|
||||
7QZhrypAM1DLYqQjkiDI7hlvt7QuDGTJ
|
||||
-----END X509 CRL-----
|
46
tests/test_x509_crl.py
Normal file
46
tests/test_x509_crl.py
Normal file
@ -0,0 +1,46 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
import jc.parsers.x509_crl
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
# input
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/x509-crl.der'), 'rb') as f:
|
||||
x509_crl_der = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/x509-crl.pem'), 'r', encoding='utf-8') as f:
|
||||
x509_crl_pem = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/x509-crl-der.json'), 'r', encoding='utf-8') as f:
|
||||
x509_crl_der_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/x509-crl.json'), 'r', encoding='utf-8') as f:
|
||||
x509_crl_pem_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_x509_crl_nodata(self):
|
||||
"""
|
||||
Test 'x509_crl' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.x509_crl.parse('', quiet=True), {})
|
||||
|
||||
def test_x509_crl_der(self):
|
||||
"""
|
||||
Test crl file in DER format
|
||||
"""
|
||||
self.assertEqual(jc.parsers.x509_crl.parse(self.x509_crl_der, quiet=True), self.x509_crl_der_json)
|
||||
|
||||
def test_x509_crl_pem(self):
|
||||
"""
|
||||
Test crl file in PEM format
|
||||
"""
|
||||
self.assertEqual(jc.parsers.x509_crl.parse(self.x509_crl_pem, quiet=True), self.x509_crl_pem_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user