diff --git a/python-certifi-shipped-requests-cabundle.patch b/python-certifi-shipped-requests-cabundle.patch index e4f0800..8f7e172 100644 --- a/python-certifi-shipped-requests-cabundle.patch +++ b/python-certifi-shipped-requests-cabundle.patch @@ -1,21 +1,28 @@ -diff -Nru certifi-2022.9.24.orig/certifi/core.py certifi-2022.9.24/certifi/core.py ---- certifi-2022.9.24.orig/certifi/core.py 2022-09-13 22:15:32.000000000 +0200 -+++ certifi-2022.9.24/certifi/core.py 2022-11-15 12:56:32.415823730 +0100 -@@ -3,106 +3,18 @@ +Index: certifi-2024.7.4/certifi/core.py +=================================================================== +--- certifi-2024.7.4.orig/certifi/core.py ++++ certifi-2024.7.4/certifi/core.py +@@ -3,112 +3,19 @@ certifi.py ~~~~~~~~~~ This module returns the installation location of cacert.pem or its contents. --""" --import sys -- - --if sys.version_info >= (3, 11): +Patched by openSUSE: return the system bundle -+""" - -- from importlib.resources import as_file, files + """ +-import sys +-import atexit +import io +-def exit_cacert_ctx() -> None: +- _CACERT_CTX.__exit__(None, None, None) # type: ignore[union-attr] + ++def read_text(_module=None, _path=None, encoding="ascii"): ++ with io.open(where(), "r", encoding=encoding) as data: ++ return data.read() + +-if sys.version_info >= (3, 11): + +- from importlib.resources import as_file, files +- - _CACERT_CTX = None - _CACERT_PATH = None - @@ -40,6 +47,7 @@ diff -Nru certifi-2022.9.24.orig/certifi/core.py certifi-2022.9.24/certifi/core. - # we will also store that at the global level as well. - _CACERT_CTX = as_file(files("certifi").joinpath("cacert.pem")) - _CACERT_PATH = str(_CACERT_CTX.__enter__()) +- atexit.register(exit_cacert_ctx) - - return _CACERT_PATH - @@ -75,6 +83,7 @@ diff -Nru certifi-2022.9.24.orig/certifi/core.py certifi-2022.9.24/certifi/core. - # we will also store that at the global level as well. - _CACERT_CTX = get_path("certifi", "cacert.pem") - _CACERT_PATH = str(_CACERT_CTX.__enter__()) +- atexit.register(exit_cacert_ctx) - - return _CACERT_PATH - @@ -106,14 +115,11 @@ diff -Nru certifi-2022.9.24.orig/certifi/core.py certifi-2022.9.24/certifi/core. - # of assuming we're on the filesystem and munge the path directly. - def where() -> str: - f = os.path.dirname(__file__) -+def read_text(_module=None, _path=None, encoding="ascii"): -+ with io.open(where(), "r", encoding=encoding) as data: -+ return data.read() - -- return os.path.join(f, "cacert.pem") +def where(): + return "/etc/ssl/ca-bundle.pem" +- return os.path.join(f, "cacert.pem") + - def contents() -> str: - return read_text("certifi", "cacert.pem", encoding="ascii") +def contents() -> str: diff --git a/python-certifi.spec b/python-certifi.spec index ea79c37..4f46d2f 100644 --- a/python-certifi.spec +++ b/python-certifi.spec @@ -56,8 +56,7 @@ Note that on SUSE packages the used CA bundle is actually the system bundle %install %python_install -%{python_expand chmod +x %{buildroot}%{$python_sitelib}/certifi/core.py - sed -i "s|#!%{_bindir}/env python|#!%__$python|" %{buildroot}/%{$python_sitelib}/certifi/core.py +%{python_expand # rm %{buildroot}%{$python_sitelib}/certifi/cacert.pem } diff --git a/two-basic-unit-tests.patch b/two-basic-unit-tests.patch index b39bc06..3e33f60 100644 --- a/two-basic-unit-tests.patch +++ b/two-basic-unit-tests.patch @@ -11,14 +11,18 @@ Subject: [PATCH 1/2] add 2 basic unit tests create mode 100644 certifi/tests/__init__.py create mode 100755 certifi/tests/test_certifi.py +Index: certifi-2024.7.4/certifi/tests/__init__.py +=================================================================== --- /dev/null -+++ b/certifi/tests/__init__.py ++++ certifi-2024.7.4/certifi/tests/__init__.py @@ -0,0 +1,2 @@ +# certifi.tests module + +Index: certifi-2024.7.4/certifi/tests/test_certifi.py +=================================================================== --- /dev/null -+++ b/certifi/tests/test_certifi.py -@@ -0,0 +1,19 @@ ++++ certifi-2024.7.4/certifi/tests/test_certifi.py +@@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +""" +unit tests to make sure everything behaves as expected @@ -31,15 +35,21 @@ Subject: [PATCH 1/2] add 2 basic unit tests + + +class TestCertifi(unittest.TestCase): -+ def test_cabundle_exists(self): -+ """Check that the reported bundle exists""" -+ self.assertTrue(os.path.exists(certifi.where())) ++ def test_cabundle_exists(self) -> None: ++ assert os.path.exists(certifi.where()) + -+ def test_read_contents(self): -+ """Check that the returned contents contain a certificate""" -+ self.assertIn("-----BEGIN CERTIFICATE-----", certifi.contents()) ++ def test_read_contents(self) -> None: ++ content = certifi.contents() ++ assert "-----BEGIN CERTIFICATE-----" in content ++ ++ def test_py_typed_exists(self) -> None: ++ assert os.path.exists( ++ os.path.join(os.path.dirname(certifi.__file__), 'py.typed') ++ ) +Index: certifi-2024.7.4/.github/workflows/python-package.yml +=================================================================== --- /dev/null -+++ b/.github/workflows/python-package.yml ++++ certifi-2024.7.4/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions