From 9fcef185a9b0bb9897e81da5f6927ff24b6f3612 Mon Sep 17 00:00:00 2001 From: Lstarsky0 <59827030+Lstarsky0@users.noreply.github.com> Date: Tue, 13 Oct 2026 16:11:43 +0800 Subject: [PATCH] test(mcp): two loopback checks no longer fail behind an HTTP proxy configured_local_same_origin_redirect_and_connection_reuse_work and event_stream_shares_the_client_and_other_bodies_keep_the_read_deadline set NO_PROXY=* so an ambient HTTP(S)_PROXY cannot take their 127.0.0.1 fixture. The proxy matcher configured_mcp_proxy uses (hyper-util's, the one reqwest uses too) checks `*` against host names only: for an IP literal it looks at the address entries alone. With HTTP_PROXY exported both requests are proxied, and since the guard replaces the developer's own NO_PROXY, listing 127.0.0.1 there does not help. Both tests assert what only the direct path gives: the redirect arrives on the same socket, and the event stream and its POST share one cached client (a proxied client is never cached). So they fail on any machine that exports HTTP_PROXY, with assertion failed: String::from_utf8_lossy(&buf[..size]).starts_with("GET /mcp/v2 ") and assertion `left == right` failed left: 0 right: 1 The guard now names the address the fixtures bind. Signed-off-by: Lstarsky0 <59827030+Lstarsky0@users.noreply.github.com> --- crates/tui/src/mcp/http_client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tui/src/mcp/http_client.rs b/crates/tui/src/mcp/http_client.rs index f25591ec30..d4ead66f45 100644 --- a/crates/tui/src/mcp/http_client.rs +++ b/crates/tui/src/mcp/http_client.rs @@ -1100,7 +1100,7 @@ mod tests { #[tokio::test] async fn configured_local_same_origin_redirect_and_connection_reuse_work() { let _env = crate::test_support::lock_test_env(); - let _proxy = crate::test_support::EnvVarGuard::set("NO_PROXY", "*"); + let _proxy = crate::test_support::EnvVarGuard::set("NO_PROXY", "127.0.0.1"); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let url = format!("http://{}/mcp", listener.local_addr().unwrap()); let server = tokio::spawn(async move { @@ -1277,7 +1277,7 @@ mod tests { #[tokio::test] async fn event_stream_shares_the_client_and_other_bodies_keep_the_read_deadline() { let _env = crate::test_support::lock_test_env(); - let _no_proxy = crate::test_support::EnvVarGuard::set("NO_PROXY", "*"); + let _no_proxy = crate::test_support::EnvVarGuard::set("NO_PROXY", "127.0.0.1"); crate::tls::ensure_rustls_crypto_provider(); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let url = format!("http://{}/mcp", listener.local_addr().unwrap());