Eliminato chatgpt_base_url (B)

Da 24a3cfe2: via la chiave chatgpt_base_url e l'URL predefinito https://chatgpt.com/backend-api/
(la chiave resta accettata nei config e ignorata); schemi dell'app-server rigenerati.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:39:59 +01:00
parent 7effb5ec86
commit 499ee3a939
63 changed files with 160 additions and 532 deletions

View File

@@ -4450,12 +4450,10 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
let untrusted_server = MockServer::start().await;
let untrusted_apps = McpTestServer::mount(&untrusted_server).await?;
let untrusted_mcp_url = format!("{}/mcp", untrusted_apps.base_url);
let untrusted_chatgpt_base_url = untrusted_apps.base_url;
let fixture = test_codex()
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config.chatgpt_base_url = untrusted_chatgpt_base_url;
insert_mcp_server(
config,
"untrusted_origin",
@@ -4506,67 +4504,6 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn configured_chatgpt_base_url_does_not_grant_mcp_chatgpt_auth() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = responses::start_mock_server().await;
let untrusted_server = MockServer::start().await;
let untrusted_apps = McpTestServer::mount(&untrusted_server).await?;
let untrusted_mcp_url = format!("{}/mcp", untrusted_apps.base_url);
let untrusted_chatgpt_base_url = untrusted_apps.base_url;
let fixture = test_codex()
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_pre_build_hook(move |codex_home| {
fs::write(
codex_home.join("config.toml"),
format!(
r#"
chatgpt_base_url = "{untrusted_chatgpt_base_url}"
[mcp_servers.untrusted_origin]
url = "{untrusted_mcp_url}"
auth = "chatgpt"
"#,
),
)
.expect("write attacker-controlled MCP config");
})
.build(&server)
.await?;
wait_for_mcp_server(&fixture.codex, "untrusted_origin").await?;
let observed_requests = untrusted_server
.received_requests()
.await
.expect("mock server should capture MCP startup requests")
.into_iter()
.filter(|request| request.url.path() == "/mcp")
.filter_map(|request| {
let body: Value = serde_json::from_slice(&request.body).ok()?;
let method = body.get("method")?.as_str()?.to_string();
let authorization = request
.headers
.get("authorization")
.and_then(|value| value.to_str().ok())
.map(str::to_string);
Some((method, authorization))
})
.collect::<Vec<_>>();
assert_eq!(
observed_requests,
vec![
("initialize".to_string(), None),
("notifications/initialized".to_string(), None),
("tools/list".to_string(), None),
],
);
Ok(())
}
/// This test writes to a fallback credentials file in AKODE_HOME.
/// Ideally, we wouldn't need to serialize the test but it's much more cumbersome to wire AKODE_HOME through the code.
#[test]