Accepting request 1176152 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/1176152
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-elastic-transport?expand=0&rev=9
This commit is contained in:
Ana Guerrero 2024-05-24 17:50:02 +00:00 committed by Git OBS Bridge
commit c17d0d9585
5 changed files with 112 additions and 9 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:604bd1cc5f7161596dac3ca0ace70c2510c8bd21ca3f631b8ac422316deb3bfa
size 72207

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:56f52c45254bb73f64336a4b59e097702517f0603036559ac56b5a92782e0fda
size 75950

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Thu May 23 08:17:35 UTC 2024 - Markéta Machová <mmachova@suse.com>
- Add requests232.patch to fix compatibility with new requests
-------------------------------------------------------------------
Fri May 17 13:29:03 UTC 2024 - Markéta Machová <mmachova@suse.com>
- update to 8.13.0
* Support the HTTPX client with asyncio
* Added optional orjson serializer support
------------------------------------------------------------------- -------------------------------------------------------------------
Sat Jan 20 14:03:15 UTC 2024 - Dirk Müller <dmueller@suse.com> Sat Jan 20 14:03:15 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@ -18,12 +18,14 @@
%{?sle15_python_module_pythons} %{?sle15_python_module_pythons}
Name: python-elastic-transport Name: python-elastic-transport
Version: 8.12.0 Version: 8.13.0
Release: 0 Release: 0
Summary: Transport classes and utilities shared among Python Elastic client libraries Summary: Transport classes and utilities shared among Python Elastic client libraries
License: Apache-2.0 License: Apache-2.0
URL: https://github.com/elastic/elastic-transport-python URL: https://github.com/elastic/elastic-transport-python
Source: https://github.com/elastic/elastic-transport-python/archive/refs/tags/v%{version}.tar.gz#/elastic-transport-python-%{version}.tar.gz Source: https://github.com/elastic/elastic-transport-python/archive/refs/tags/v%{version}.tar.gz#/elastic-transport-python-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/elastic/elastic-transport-python/pull/164 Fix requests 2.32 compatibility
Patch: requests232.patch
BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
@ -31,18 +33,19 @@ BuildRequires: python-rpm-macros
Requires: python-certifi Requires: python-certifi
Requires: python-urllib3 Requires: python-urllib3
BuildArch: noarch BuildArch: noarch
%if 0%{python_version_nodots} < 37
Requires: python-dataclasses
%endif
# SECTION test requirements # SECTION test requirements
BuildRequires: %{python_module aiohttp} BuildRequires: %{python_module aiohttp}
BuildRequires: %{python_module certifi} BuildRequires: %{python_module certifi}
BuildRequires: %{python_module dataclasses if %python-base < 3.7} BuildRequires: %{python_module httpx}
BuildRequires: %{python_module opentelemetry-api}
BuildRequires: %{python_module opentelemetry-sdk}
BuildRequires: %{python_module orjson}
BuildRequires: %{python_module pytest-asyncio} BuildRequires: %{python_module pytest-asyncio}
BuildRequires: %{python_module pytest-httpserver} BuildRequires: %{python_module pytest-httpserver}
BuildRequires: %{python_module pytest-mock} BuildRequires: %{python_module pytest-mock}
BuildRequires: %{python_module pytest} BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests} BuildRequires: %{python_module requests}
BuildRequires: %{python_module respx}
BuildRequires: %{python_module trustme} BuildRequires: %{python_module trustme}
BuildRequires: %{python_module urllib3} BuildRequires: %{python_module urllib3}
# /SECTION # /SECTION
@ -52,7 +55,7 @@ BuildRequires: %{python_module urllib3}
Transport classes and utilities shared among Python Elastic client libraries Transport classes and utilities shared among Python Elastic client libraries
%prep %prep
%setup -q -n elastic-transport-python-%{version} %autosetup -p1 -n elastic-transport-python-%{version}
sed -i '/addopts/d' setup.cfg sed -i '/addopts/d' setup.cfg
sed -i 's/from mock/from unittest.mock/' tests/node/test_http_*.py sed -i 's/from mock/from unittest.mock/' tests/node/test_http_*.py
@ -68,6 +71,7 @@ sed -i 's/from mock/from unittest.mock/' tests/node/test_http_*.py
donttest="(test_http_aiohttp and not TestAiohttpHttpNode)" donttest="(test_http_aiohttp and not TestAiohttpHttpNode)"
donttest="$donttest or test_tls_versions" donttest="$donttest or test_tls_versions"
donttest="$donttest or test_assert_fingerprint_in_cert_chain" donttest="$donttest or test_assert_fingerprint_in_cert_chain"
donttest="$donttest or (test_ssl_assert_fingerprint and httpx)"
# gh#elastic/elastic-transport-python#96 # gh#elastic/elastic-transport-python#96
donttest="$donttest or test_url_to_node_config[https://[::1]:0/-https://[::1]:0-]" donttest="$donttest or test_url_to_node_config[https://[::1]:0/-https://[::1]:0-]"
%pytest -k "not ($donttest)" %pytest -k "not ($donttest)"

87
requests232.patch Normal file
View File

@ -0,0 +1,87 @@
From d49d5dda344f0a458c020a8a3c0032480e6b57d5 Mon Sep 17 00:00:00 2001
From: Quentin Pradet <quentin.pradet@elastic.co>
Date: Thu, 23 May 2024 11:48:10 +0400
Subject: [PATCH 1/3] Fix requests 2.32 compatibility
---
elastic_transport/_node/_http_requests.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/elastic_transport/_node/_http_requests.py b/elastic_transport/_node/_http_requests.py
index 19cec37..e439865 100644
--- a/elastic_transport/_node/_http_requests.py
+++ b/elastic_transport/_node/_http_requests.py
@@ -169,7 +169,16 @@ def __init__(self, config: NodeConfig):
)
# Preload the HTTPConnectionPool so initialization issues
# are raised here instead of in perform_request()
- adapter.get_connection(self.base_url) # type: ignore[no-untyped-call]
+ if hasattr(adapter, "get_connection_with_tls_context"):
+ adapter.get_connection_with_tls_context(
+ requests.Request(url=self.base_url), verify=self.session.verify
+ )
+ else:
+ # elastic-transport is not vulnerable to CVE-2024-35195 because it uses
+ # requests.Session and an SSLContext without using the verify parameter.
+ # We should remove this branch when requiring requests 2.32 or later.
+ adapter.get_connection(self.base_url) # type: ignore [no-untyped-call]
+
self.session.mount(prefix=f"{self.scheme}://", adapter=adapter)
def perform_request(
From 56d1e6832d0b438ee7cee3ab0f8dea6a14a89eb8 Mon Sep 17 00:00:00 2001
From: Quentin Pradet <quentin.pradet@elastic.co>
Date: Thu, 23 May 2024 11:59:42 +0400
Subject: [PATCH 2/3] Fix lint
---
elastic_transport/_node/_http_requests.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/elastic_transport/_node/_http_requests.py b/elastic_transport/_node/_http_requests.py
index e439865..4b2d502 100644
--- a/elastic_transport/_node/_http_requests.py
+++ b/elastic_transport/_node/_http_requests.py
@@ -170,14 +170,16 @@ def __init__(self, config: NodeConfig):
# Preload the HTTPConnectionPool so initialization issues
# are raised here instead of in perform_request()
if hasattr(adapter, "get_connection_with_tls_context"):
+ request = requests.Request(url=self.base_url)
+ prepared_request = self.session.prepare_request(request)
adapter.get_connection_with_tls_context(
- requests.Request(url=self.base_url), verify=self.session.verify
+ prepared_request, verify=self.session.verify
)
else:
# elastic-transport is not vulnerable to CVE-2024-35195 because it uses
# requests.Session and an SSLContext without using the verify parameter.
# We should remove this branch when requiring requests 2.32 or later.
- adapter.get_connection(self.base_url) # type: ignore [no-untyped-call]
+ adapter.get_connection(self.base_url)
self.session.mount(prefix=f"{self.scheme}://", adapter=adapter)
From 8a222e2c9b81dc9f7a1e4583de59ecc0d4c4d803 Mon Sep 17 00:00:00 2001
From: Quentin Pradet <quentin.pradet@elastic.co>
Date: Thu, 23 May 2024 12:02:53 +0400
Subject: [PATCH 3/3] Fix prepared request
---
elastic_transport/_node/_http_requests.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elastic_transport/_node/_http_requests.py b/elastic_transport/_node/_http_requests.py
index 4b2d502..941e3cc 100644
--- a/elastic_transport/_node/_http_requests.py
+++ b/elastic_transport/_node/_http_requests.py
@@ -170,7 +170,7 @@ def __init__(self, config: NodeConfig):
# Preload the HTTPConnectionPool so initialization issues
# are raised here instead of in perform_request()
if hasattr(adapter, "get_connection_with_tls_context"):
- request = requests.Request(url=self.base_url)
+ request = requests.Request(method="GET", url=self.base_url)
prepared_request = self.session.prepare_request(request)
adapter.get_connection_with_tls_context(
prepared_request, verify=self.session.verify