refactor: update authentication handling to use aiohttp.encode_basic_auth and adjust request options + fix other pytest warnings

This commit is contained in:
grossmj committed 2026-10-31 22:00:21 +07:00
1 parent 1608a65a01
commit ac65698eea
9 files changed
+50 -33

No files matched your search

+9 -2
View File
@@ -59,11 +59,18 @@ class HTTPClient:
basic_auth = None
if user:
try:
basic_auth = aiohttp.BasicAuth(user, password.get_secret_value() if password else "", "utf-8")
basic_auth = aiohttp.encode_basic_auth(
user, password.get_secret_value() if password else "", encoding="utf-8"
)
except ValueError as e:
log.error(f"Basic authentication set-up error: {e}")
return client.request(method, url, auth=basic_auth, **kwargs)
headers = kwargs.pop("headers", None)
if basic_auth is not None:
headers = {key: value for key, value in (headers or {}).items() if key.lower() != "authorization"}
headers["Authorization"] = basic_auth
kwargs["headers"] = headers
return client.request(method, url, **kwargs)
@classmethod
def get(cls, path, **kwargs):