From 2fe638af2632424b826843675311f9a258a57b71 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Mon, 12 Feb 2024 13:56:49 +0100 Subject: [PATCH] support/testing: add python-asn1crypto runtime test Signed-off-by: Marcus Hoffmann Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 2 ++ .../tests/package/sample_python_asn1crypto.py | 11 +++++++++++ .../testing/tests/package/test_python_asn1crypto.py | 13 +++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 support/testing/tests/package/sample_python_asn1crypto.py create mode 100644 support/testing/tests/package/test_python_asn1crypto.py diff --git a/DEVELOPERS b/DEVELOPERS index 22867fea07..4a22b74779 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -2180,6 +2180,8 @@ F: package/libselinux/ F: package/libsemanage/ F: package/libsepol/ F: package/selinux-python/ +F: support/testing/tests/package/sample_python_asn1crypto.py +F: support/testing/tests/package/test_python_asn1crypto.py F: utils/config F: utils/diffconfig diff --git a/support/testing/tests/package/sample_python_asn1crypto.py b/support/testing/tests/package/sample_python_asn1crypto.py new file mode 100644 index 0000000000..0b10487572 --- /dev/null +++ b/support/testing/tests/package/sample_python_asn1crypto.py @@ -0,0 +1,11 @@ +from asn1crypto import pem, x509 + + +with open('/etc/ssl/certs/ISRG_Root_X2.pem', 'rb') as f: + der_bytes = f.read() + if pem.detect(der_bytes): + type_name, headers, der_bytes = pem.unarmor(der_bytes) + +cert = x509.Certificate.load(der_bytes) + +assert cert.subject.native["common_name"] == "ISRG Root X2" diff --git a/support/testing/tests/package/test_python_asn1crypto.py b/support/testing/tests/package/test_python_asn1crypto.py new file mode 100644 index 0000000000..97df3d3ac8 --- /dev/null +++ b/support/testing/tests/package/test_python_asn1crypto.py @@ -0,0 +1,13 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3Asn1Crypto(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_CA_CERTIFICATES=y + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_ASN1CRYPTO=y + """ + sample_scripts = ["tests/package/sample_python_asn1crypto.py"] + timeout = 40