Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions crates/goose-providers/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,35 +796,6 @@ mod tests {
);
}

#[tokio::test]
async fn loopback_transport_does_not_use_environment_proxy() {
let proxy = TcpListener::bind("127.0.0.1:0").await.unwrap();
let proxy_uri = format!("http://{}", proxy.local_addr().unwrap());
let _guard = env_lock::lock_env([
("HTTP_PROXY", Some(proxy_uri.as_str())),
("http_proxy", Some(proxy_uri.as_str())),
("NO_PROXY", Some("")),
("no_proxy", Some("")),
]);
let client = ApiClient::new_with_tls(
"http://127.0.0.1:9".to_string(),
AuthMethod::BearerToken("secret".to_string()),
None,
)
.unwrap()
.with_loopback_http_only()
.unwrap()
.with_header("x-test", "value")
.unwrap();

assert!(client.response_get("models").await.is_err());
assert!(
tokio::time::timeout(Duration::from_millis(100), proxy.accept())
.await
.is_err()
);
}

#[tokio::test]
async fn loopback_transport_rejects_remote_http_redirect() {
for status in ["307 Temporary Redirect", "308 Permanent Redirect"] {
Expand Down
37 changes: 37 additions & 0 deletions crates/goose-providers/tests/loopback_proxy_env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Isolated in its own test binary: this test mutates process-wide proxy
//! environment variables, which would otherwise be observed by unrelated
//! tests in the same process that build HTTP clients.

use std::time::Duration;

use goose_providers::api_client::{ApiClient, AuthMethod};
use tokio::net::TcpListener;

#[tokio::test]
async fn loopback_transport_does_not_use_environment_proxy() {
let proxy = TcpListener::bind("127.0.0.1:0").await.unwrap();
let proxy_uri = format!("http://{}", proxy.local_addr().unwrap());
let _guard = env_lock::lock_env([
("HTTP_PROXY", Some(proxy_uri.as_str())),
("http_proxy", Some(proxy_uri.as_str())),
("NO_PROXY", Some("")),
("no_proxy", Some("")),
]);
let client = ApiClient::new_with_tls(
"http://127.0.0.1:9".to_string(),
AuthMethod::BearerToken("secret".to_string()),
None,
)
.unwrap()
.with_loopback_http_only()
.unwrap()
.with_header("x-test", "value")
.unwrap();

assert!(client.response_get("models").await.is_err());
assert!(
tokio::time::timeout(Duration::from_millis(100), proxy.accept())
.await
.is_err()
);
}