mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 15:35:06 +00:00
fix(session): pass verify to the rnet client and carry it into download child processes
This commit is contained in:
@@ -19,9 +19,10 @@ from requests import Session
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
from tests.core.test_session_verify import self_signed_url as self_signed_url
|
||||
from unshackle.core.downloaders.requests import build_session_spec, rebuild_session
|
||||
from unshackle.core.service import Service
|
||||
from unshackle.core.session import RnetSession
|
||||
from unshackle.core.session import MaxRetriesError, RnetSession
|
||||
from unshackle.core.session import session as make_session
|
||||
from unshackle.core.utils.sslciphers import SSLCiphers
|
||||
|
||||
@@ -210,6 +211,25 @@ def test_requests_spec_carries_verify() -> None:
|
||||
assert rebuilt.verify is False
|
||||
|
||||
|
||||
def rnet_child(parent: RnetSession) -> RnetSession:
|
||||
"""The HTTP session a spawned child rebuilds from the pickled spec of the parent."""
|
||||
spec = build_session_spec(parent)
|
||||
assert spec is not None
|
||||
return rebuild_session(pickle.loads(pickle.dumps(spec)), 1)
|
||||
|
||||
|
||||
def test_rnet_spec_carries_verify(self_signed_url: str) -> None:
|
||||
assert rnet_child(make_session("Chrome131", verify=False)).get(self_signed_url, max_retries=0).status_code == 200
|
||||
|
||||
|
||||
def test_rnet_spec_takes_verify_from_the_client_of_the_parent(self_signed_url: str) -> None:
|
||||
"""A child never checks less than the client of the parent, which an assignment to verify does not reach."""
|
||||
parent = make_session("Chrome131")
|
||||
parent.verify = False
|
||||
with pytest.raises(MaxRetriesError, match="certificate"):
|
||||
rnet_child(parent).get(self_signed_url, max_retries=0)
|
||||
|
||||
|
||||
def test_requests_spec_carries_trust_env() -> None:
|
||||
"""A proxied session ignores env proxies, so a child must not let HTTPS_PROXY win again."""
|
||||
rs = Session()
|
||||
|
||||
Reference in New Issue
Block a user