test(gateway): keep the runner's system proxy out of the media-retry connect guard
test_blocks_private_dns_answer_at_connect_time clears the six proxy env
vars, but httpx resolves environment proxies through
urllib.request.getproxies(), which on macOS falls back to the System
Configuration (scutil --proxy) when no proxy env var is set. On a runner
with a system-wide proxy the request dials the proxy rather than the
rebinding host, and the test fails with:
AssertionError: TCP connect attempted for 127.0.0.1:7890
httpx binds that name at import time (httpx/_utils.py does
``from urllib.request import getproxies``), so patching
urllib.request.getproxies has no effect; patch the httpx-side binding.
Test-only change: production proxy semantics are untouched, and the
mutation check still holds (removing the connect-time guard in
tools/url_safety.py turns this test red again).
One of the test-isolation gaps reported in #110728 (the system-proxy one).
This commit is contained in:
@@ -170,6 +170,11 @@ class TestCacheImageFromUrlConnectGuard:
|
||||
"all_proxy",
|
||||
):
|
||||
monkeypatch.delenv(proxy_var, raising=False)
|
||||
# Clearing the variables above is not enough: httpx resolves environment proxies
|
||||
# through ``urllib.request.getproxies``, which on macOS falls back to the System
|
||||
# Configuration (``scutil --proxy``) when no proxy env var is set — so on a runner
|
||||
# with a system-wide proxy the request would dial the proxy, not the rebinding host.
|
||||
monkeypatch.setattr("httpx._utils.getproxies", lambda: {})
|
||||
|
||||
answers = [
|
||||
[(socket.AF_INET, socket.SOCK_STREAM, 6, "", ("93.184.216.34", 80))],
|
||||
|
||||
Reference in New Issue
Block a user