mirror of
https://github.com/openai/codex.git
synced 2026-10-20 00:18:49 +00:00
Strengthen Agent Plugin MCP environment overlay tests (#40410)
## What changed - Cover forwarding a legacy `env_vars` entry when the portable MCP server has no `env` map. - Use the test workspace variable instead of `PATH` in the stdio round-trip test, keeping overlay forwarding distinct from portable environment expansion. GitOrigin-RevId: c5cfb333e553581fc856d43a04e5be0abd9f65ef
This commit is contained in:
@@ -116,7 +116,7 @@ async fn agent_plugin_codex_mcp_overlay_only_forwards_matching_stdio_server_env_
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn agent_plugin_codex_mcp_overlay_supports_inline_legacy_servers() {
|
||||
async fn agent_plugin_codex_mcp_overlay_supports_inline_legacy_servers_without_portable_env() {
|
||||
let temp_dir = TempDir::new().expect("tempdir");
|
||||
let plugin_root = temp_dir.path().join("plugin");
|
||||
write_file(
|
||||
@@ -130,8 +130,7 @@ async fn agent_plugin_codex_mcp_overlay_supports_inline_legacy_servers() {
|
||||
"mcpServers": {
|
||||
"shared": {
|
||||
"type": "stdio",
|
||||
"command": "portable-server",
|
||||
"env": {"TOKEN": "${TOKEN}"}
|
||||
"command": "portable-server"
|
||||
}
|
||||
}
|
||||
}"#,
|
||||
@@ -139,13 +138,12 @@ async fn agent_plugin_codex_mcp_overlay_supports_inline_legacy_servers() {
|
||||
|
||||
let mut expected = load_plugin_mcp_servers(&plugin_root, /*auth_mode*/ None).await;
|
||||
let Some(McpServerConfig {
|
||||
transport: McpServerTransportConfig::Stdio { env, env_vars, .. },
|
||||
transport: McpServerTransportConfig::Stdio { env_vars, .. },
|
||||
..
|
||||
}) = expected.get_mut("shared")
|
||||
else {
|
||||
panic!("expected portable stdio server");
|
||||
};
|
||||
env.as_mut().expect("portable environment").remove("TOKEN");
|
||||
env_vars.push("TOKEN".into());
|
||||
|
||||
write_file(
|
||||
|
||||
@@ -716,7 +716,7 @@ async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_
|
||||
overlay_call_id,
|
||||
"mcp__agent",
|
||||
"echo",
|
||||
r#"{"message":"ping","env_var":"PATH"}"#,
|
||||
r#"{"message":"ping","env_var":"INSTA_WORKSPACE_ROOT"}"#,
|
||||
),
|
||||
ev_completed("resp-3"),
|
||||
]),
|
||||
@@ -748,10 +748,7 @@ async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_
|
||||
"agent": {
|
||||
"type": "stdio",
|
||||
"command": format!("./{stdio_server_name}"),
|
||||
"env": {
|
||||
"MCP_TEST_VALUE": "${PLUGIN_ROOT}|${PLUGIN_DATA}",
|
||||
"PATH": "${PATH}"
|
||||
}
|
||||
"env": {"MCP_TEST_VALUE": "${PLUGIN_ROOT}|${PLUGIN_DATA}"}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -762,7 +759,7 @@ async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_
|
||||
std::fs::create_dir_all(plugin_root.join(".codex-plugin"))?;
|
||||
std::fs::write(
|
||||
plugin_root.join(".codex-plugin/plugin.json"),
|
||||
r#"{"name":"acme.tools","mcpServers":{"agent":{"command":"ignored","env_vars":["PATH"]}}}"#,
|
||||
r#"{"name":"acme.tools","mcpServers":{"agent":{"command":"ignored","env_vars":["INSTA_WORKSPACE_ROOT"]}}}"#,
|
||||
)?;
|
||||
let mut builder = test_codex().with_home(Arc::clone(&codex_home));
|
||||
let test_codex = builder.build_with_remote_and_local_env(&server).await?;
|
||||
@@ -824,7 +821,7 @@ async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_
|
||||
.as_ref()
|
||||
.and_then(|content| content.get("env"))
|
||||
.and_then(serde_json::Value::as_str),
|
||||
Some(std::env::var("PATH")?.as_str())
|
||||
Some(std::env::var("INSTA_WORKSPACE_ROOT")?.as_str())
|
||||
);
|
||||
let requests = mock.requests();
|
||||
let search_output = requests[1].tool_search_output(search_call_id);
|
||||
|
||||
Reference in New Issue
Block a user