Merge pull request #9952 from certbot/test-snap-config-nits

suggest snap_config nits
This commit is contained in:
Will Greenberg 2024-06-05 10:33:26 -07:00 committed by GitHub
commit 4f3af45f5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,8 @@ import socket
from typing import Iterable
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
from requests import PreparedRequest, Session
from requests.adapters import HTTPAdapter
@ -100,10 +102,20 @@ class _SnapdConnectionPool(HTTPConnectionPool):
class _SnapdAdapter(HTTPAdapter):
# get_connection is used with versions of requests before 2.32.2 and
# get_connection_with_tls_context is used instead in versions after that. as of
# writing this, Certbot in EPEL 9 is still seeing updates and they have requests 2.25.1 so to
# help out those packagers while ensuring this code works reliably, we offer custom versions of
# both functions for now. when certbot does declare a dependency on requests>=2.32.2 in its
# setup.py files, get_connection can be deleted
def get_connection(self, url: str,
proxies: Optional[Iterable[str]] = None) -> _SnapdConnectionPool:
return _SnapdConnectionPool()
def get_connection_with_tls_context(self, request: PreparedRequest,
verify: bool,
proxies: Optional[Iterable[str]] = None,
cert: Optional[bytes] = None
cert: Optional[Union[str, Tuple[str,str]]] = None
) -> _SnapdConnectionPool:
"""Required method for creating a new connection pool. Simply return our
shim that forces a UNIX socket connection to snapd."""