WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -15,7 +15,7 @@ use codex_extension_api::ExtensionRegistry;
use codex_extension_api::ExtensionRegistryBuilder;
use codex_features::Feature;
use codex_login::CodexAuth;
use codex_mcp::CODEX_APPS_MCP_SERVER_NAME;
use core_test_support::mcp_test_server::MCP_TEST_SERVER_NAME;
use codex_plugin::PluginId;
use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::ModeKind;
@@ -29,9 +29,8 @@ use codex_protocol::protocol::ThreadSettingsOverrides;
use codex_protocol::user_input::UserInput;
use codex_skills_extension::SkillsExtensionConfig;
use codex_skills_extension::install;
use core_test_support::apps_test_server::AppsTestServer;
use core_test_support::apps_test_server::SEARCH_CALENDAR_CREATE_TOOL;
use core_test_support::apps_test_server::recorded_apps_tool_calls;
use core_test_support::mcp_test_server::CALENDAR_CREATE_EVENT_TOOL_NAME;
use core_test_support::mcp_test_server::recorded_mcp_tool_calls;
use core_test_support::responses::ResponseMock;
use core_test_support::responses::ResponsesRequest;
use core_test_support::responses::ev_assistant_message;
@@ -51,7 +50,6 @@ use core_test_support::skip_if_remote;
use core_test_support::skip_if_target_windows;
use core_test_support::stdio_server_bin;
use core_test_support::submit_thread_settings;
use core_test_support::test_codex::TestCodex;
use core_test_support::test_codex::test_codex;
use core_test_support::test_codex::turn_permission_fields;
use core_test_support::wait_for_event;
@@ -60,15 +58,9 @@ use core_test_support::wait_for_mcp_server;
use pretty_assertions::assert_eq;
use tempfile::TempDir;
use test_case::test_case;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::header;
use wiremock::matchers::method;
use wiremock::matchers::path;
const SAMPLE_PLUGIN_CONFIG_NAME: &str = "sample@test";
const SAMPLE_REMOTE_PLUGIN_CONFIG_NAME: &str = "sample@openai-curated-remote";
const SAMPLE_PLUGIN_DISPLAY_NAME: &str = "sample";
const SAMPLE_PLUGIN_DESCRIPTION: &str = "inspect sample data";
const SAMPLE_PLUGIN_APP_NAMESPACE: &str = "mcp__codex_apps__google_calendar";
@@ -85,7 +77,6 @@ fn skills_extensions() -> Arc<ExtensionRegistry<Config>> {
omit_descriptions: false,
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
cloud_skill_enabled: config.cloud_skill_enabled,
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
});
Arc::new(extensions.build())
@@ -126,7 +117,7 @@ fn write_sample_plugin_manifest_and_config_at_root(
plugin_root
}
fn write_remote_plugin_script_and_config(home: &TempDir) -> std::path::PathBuf {
fn write_legacy_remote_plugin_script_and_config(home: &TempDir) -> std::path::PathBuf {
let plugin_id = PluginId::parse(REMOTE_PLUGIN_CONFIG_NAME).expect("plugin id");
let store = PluginStore::new(home.path().to_path_buf());
let plugin_root = store.plugin_root(&plugin_id, "1.2.3");
@@ -141,9 +132,6 @@ fn write_remote_plugin_script_and_config(home: &TempDir) -> std::path::PathBuf {
)
.expect("write remote plugin manifest");
std::fs::write(&script_path, "echo remote attribution\n").expect("write remote plugin script");
store
.write_remote_plugin_id(&plugin_id, "plugins~Plugin_sample")
.expect("persist remote plugin id");
std::fs::write(
home.path().join("config.toml"),
format!(
@@ -241,45 +229,6 @@ fn block_plugin_mcp_startup(home: &TempDir, command: &str) -> std::path::PathBuf
barrier
}
fn write_plugin_app_plugin(home: &TempDir) {
write_plugin_app_plugin_with_name(home, "sample");
}
fn write_plugin_app_plugin_with_name(home: &TempDir, app_name: &str) {
let plugin_root = write_sample_plugin_manifest_and_config(home);
std::fs::write(
plugin_root.join(".app.json"),
format!(
r#"{{
"apps": {{
"{app_name}": {{
"id": "calendar"
}}
}}
}}"#
),
)
.expect("write plugin app config");
}
async fn build_apps_enabled_plugin_test_codex(
server: &MockServer,
codex_home: Arc<TempDir>,
chatgpt_base_url: String,
) -> Result<TestCodex> {
let mut builder = test_codex()
.with_home(codex_home)
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config
.features
.enable(Feature::Apps)
.expect("test config should allow feature update");
config.chatgpt_base_url = chatgpt_base_url;
});
builder.build_with_remote_and_local_env(server).await
}
async fn mount_plugin_tool_search_turn(server: &MockServer) -> ResponseMock {
mount_sse_sequence(
server,
@@ -322,7 +271,7 @@ fn searched_plugin_tools(
namespace_child_tool(
&app_output,
SAMPLE_PLUGIN_APP_NAMESPACE,
SEARCH_CALENDAR_CREATE_TOOL,
CALENDAR_CREATE_EVENT_TOOL_NAME,
)
.cloned(),
namespace_child_tool(&mcp_output, SAMPLE_PLUGIN_MCP_NAMESPACE, "echo").cloned(),
@@ -330,7 +279,7 @@ fn searched_plugin_tools(
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn persisted_remote_plugin_command_attribution_flows_through_turn_context() -> Result<()> {
async fn legacy_remote_marketplace_plugin_commands_are_not_attributed() -> Result<()> {
skip_if_target_windows!(Ok(()), "executes a POSIX shell script");
skip_if_no_network!(Ok(()));
skip_if_remote!(
@@ -340,7 +289,7 @@ async fn persisted_remote_plugin_command_attribution_flows_through_turn_context(
let server = start_mock_server().await;
let codex_home = Arc::new(TempDir::new()?);
let script_path = write_remote_plugin_script_and_config(codex_home.as_ref());
let script_path = write_legacy_remote_plugin_script_and_config(codex_home.as_ref());
std::fs::write(&script_path, "printf done\n")?;
let builder = test_codex();
let command = shlex::try_join(["/bin/sh", script_path.to_string_lossy().as_ref()])?;
@@ -419,12 +368,13 @@ async fn persisted_remote_plugin_command_attribution_flows_through_turn_context(
);
wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await;
// Cache entries under the legacy remote marketplace name are no longer trusted roots.
for (plugin_id, script_path) in [
(begin.plugin_id.as_deref(), begin.script_path.as_deref()),
(end.plugin_id.as_deref(), end.script_path.as_deref()),
] {
assert_eq!(plugin_id, Some(REMOTE_PLUGIN_CONFIG_NAME));
assert_eq!(script_path, Some("scripts/run.sh"));
assert_eq!(plugin_id, None);
assert_eq!(script_path, None);
}
Ok(())
@@ -435,7 +385,6 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
-> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let apps = AppsTestServer::mount_with_connector_name(&server, "Google Calendar").await?;
let home = Arc::new(TempDir::new()?);
let skill_path = dunce::canonicalize(write_plugin_skill_plugin(home.as_ref()))?;
std::fs::write(
@@ -443,15 +392,10 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
"---\ndescription: inspect sample data\n---\nTHREAD_PLUGIN_SKILL_BODY\n",
)?;
write_plugin_mcp_plugin(home.as_ref(), &stdio_server_bin()?);
write_plugin_app_plugin_with_name(home.as_ref(), "sample_app");
let mut builder = test_codex()
.with_home(home)
.with_extensions(skills_extensions())
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config.features.enable(Feature::Apps).unwrap();
config.chatgpt_base_url = apps.chatgpt_base_url;
});
.with_auth(CodexAuth::from_api_key("Test API Key"));
let test = builder.build_with_remote_and_local_env(&server).await?;
let manager = test.thread_manager.plugins_manager();
let plugins_input = test.config.plugins_config_input();
@@ -462,7 +406,6 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
"echo",
Some(serde_json::json!({"message": "plugin check"})),
),
(CODEX_APPS_MCP_SERVER_NAME, "calendar_list_events", None),
];
for (phase, enabled, injection_count) in [(0, true, 1), (1, false, 1), (2, true, 2)] {
@@ -482,17 +425,12 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
.await?;
}
}
let app_call_id = format!("plugin-app-{phase}");
let mcp_call_id = format!("plugin-mcp-{phase}");
let mock = mount_sse_sequence(
&server,
vec![
sse(vec![
ev_response_created("search"),
ev_tool_search_call(
&app_call_id,
&serde_json::json!({"query": "create calendar event"}),
),
ev_tool_search_call(&mcp_call_id, &serde_json::json!({"query": "echo"})),
ev_completed("search"),
]),
@@ -538,11 +476,6 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
);
}
for (call_id, namespace, tool) in [
(
&app_call_id,
SAMPLE_PLUGIN_APP_NAMESPACE,
SEARCH_CALENDAR_CREATE_TOOL,
),
(&mcp_call_id, SAMPLE_PLUGIN_MCP_NAMESPACE, "echo"),
] {
assert_eq!(
@@ -551,7 +484,7 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
enabled
);
}
let calls_before = recorded_apps_tool_calls(&server).await.len();
let calls_before = recorded_mcp_tool_calls(&server).await.len();
// Direct Apps RPC calls keep their existing behavior outside model tool filtering.
for (server_name, tool, arguments) in &tool_calls {
let result = test
@@ -560,12 +493,12 @@ async fn thread_disabled_plugins_filter_skills_and_tools_without_changing_shared
.await;
assert_eq!(
result.is_ok(),
enabled || *server_name == CODEX_APPS_MCP_SERVER_NAME,
enabled || *server_name == MCP_TEST_SERVER_NAME,
"unexpected {server_name}/{tool} result: {result:?}"
);
}
assert_eq!(
recorded_apps_tool_calls(&server).await.len() - calls_before,
recorded_mcp_tool_calls(&server).await.len() - calls_before,
1
);
assert_eq!(
@@ -770,130 +703,6 @@ async fn legacy_plugin_skill_prompt_remains_complete() -> Result<()> {
Ok(())
}
#[test_case("sites", None, true, true, (true, false); "sites enabled remote supersedes bundled")]
#[test_case("sites", Some("tpp"), true, true, (true, false); "sites configured work sku")]
#[test_case("sites", None, false, true, (false, false); "sites disabled remote does not reactivate bundled")]
#[test_case("sites", None, true, false, (false, true); "sites missing remote bundle preserves bundled")]
#[test_case("visualize", None, true, true, (true, false); "visualize enabled remote supersedes bundled")]
#[test_case("visualize", None, false, true, (false, false); "visualize disabled remote does not reactivate bundled")]
#[test_case("visualize", None, true, false, (false, true); "visualize missing remote bundle preserves bundled")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn bundled_plugin_compatibility_guard_in_agent_turn(
plugin_name: &str,
product_sku: Option<&str>,
remote_enabled: bool,
cache_remote_plugin: bool,
expected_skills: (bool, bool),
) -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let response = mount_sse_once(
&server,
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
)
.await;
Mock::given(method("GET"))
.and(path("/ps/plugins/installed"))
.and(header("OAI-Product-Sku", product_sku.unwrap_or("codex")))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
"plugins": [{
"id": format!("plugins~Plugin_{plugin_name}"),
"name": plugin_name,
"scope": "GLOBAL",
"status": "ENABLED",
"installation_policy": "AVAILABLE",
"authentication_policy": "ON_USE",
"release": {
"version": "local",
"display_name": plugin_name,
"description": plugin_name,
"interface": {},
},
"enabled": remote_enabled,
}],
"pagination": {"next_page_token": null},
})))
.mount(&server)
.await;
let codex_home = Arc::new(TempDir::new()?);
std::fs::write(
codex_home.path().join("config.toml"),
format!(
r#"[features]
plugins = true
remote_plugin = true
[plugins."{plugin_name}@openai-bundled"]
enabled = true
"#
),
)?;
for (marketplace, skill) in [
("openai-bundled", "bundled-skill"),
("openai-curated-remote", "remote-skill"),
] {
if marketplace == "openai-curated-remote" && !cache_remote_plugin {
continue;
}
let root = codex_home
.path()
.join(format!("plugins/cache/{marketplace}/{plugin_name}/local"));
std::fs::create_dir_all(root.join(".codex-plugin"))?;
std::fs::write(
root.join(".codex-plugin/plugin.json"),
format!(r#"{{"name":"{plugin_name}"}}"#),
)?;
let skill_dir = root.join("skills").join(skill);
std::fs::create_dir_all(&skill_dir)?;
std::fs::write(
skill_dir.join("SKILL.md"),
format!("---\nname: {skill}\ndescription: test skill\n---\n\n# body\n"),
)?;
}
let chatgpt_base_url = server.uri();
let product_sku = product_sku.map(str::to_owned);
let mut builder = test_codex()
.with_home(codex_home)
.with_extensions(skills_extensions())
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config.chatgpt_base_url = chatgpt_base_url;
config.apps_mcp_product_sku = product_sku;
});
let test = builder.build_with_auto_env(&server).await?;
let auth = test.thread_manager.auth_manager().auth().await;
test.thread_manager
.plugins_manager()
.reconcile_remote_installed_plugins(&test.config.plugins_config_input(), auth.as_ref())
.await?;
test.codex
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
text: format!("Inspect the available {plugin_name} skills."),
text_elements: Vec::new(),
}]))
.await?;
wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::TurnComplete(_))
})
.await;
let requests = response.requests();
let developer_text = requests[0].message_input_texts("developer").join("\n");
assert_eq!(
(
developer_text.contains(&format!("{plugin_name}:remote-skill")),
developer_text.contains(&format!("{plugin_name}:bundled-skill")),
),
expected_skills,
"unexpected {plugin_name} skills in developer prompt: {developer_text:?}"
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_codex_env_overlay()
-> Result<()> {
@@ -1048,254 +857,6 @@ async fn agent_plugin_root_mcp_stdio_tool_round_trip_expands_reserved_paths_and_
Ok(())
}
#[test_case(true; "apps enabled")]
#[test_case(false; "apps disabled without direct MCP fallback")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn curated_agent_plugin_app_routing_reaches_turns(apps_enabled: bool) -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let apps_server = AppsTestServer::mount_with_connector_name(&server, "Google Calendar").await?;
let mock = mount_plugin_tool_search_turn(&server).await;
let codex_home = Arc::new(TempDir::new()?);
let plugin_root = codex_home
.path()
.join("plugins/cache/openai-curated-remote/sample/local");
std::fs::create_dir_all(&plugin_root)?;
let command_name = format!("test_stdio_server{}", std::env::consts::EXE_SUFFIX);
codex_utils_cargo_bin::copy_executable(
std::path::Path::new(&stdio_server_bin()?),
&plugin_root.join(&command_name),
)?;
std::fs::write(
plugin_root.join("plugin.json"),
r#"{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"sample","extensions":{"com.openai":{"apps":"./.app.json"}}}"#,
)?;
std::fs::write(
plugin_root.join(".app.json"),
r#"{"apps":{"calendar":{"id":"calendar"}}}"#,
)?;
let mcp_server = serde_json::json!({
"type": "stdio",
"command": format!("./{command_name}"),
});
std::fs::write(
plugin_root.join("mcp.json"),
serde_json::json!({
"$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
"mcpServers": {"calendar": mcp_server, "sample": mcp_server},
})
.to_string(),
)?;
std::fs::write(
codex_home.path().join("config.toml"),
format!(
"[features]\nplugins = true\napps = {apps_enabled}\n[plugins.\"{SAMPLE_REMOTE_PLUGIN_CONFIG_NAME}\"]\nenabled = true\n"
),
)?;
let mut builder = test_codex()
.with_home(codex_home)
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config
.features
.set_enabled(Feature::Apps, apps_enabled)
.expect("test config should allow feature update");
config.chatgpt_base_url = apps_server.chatgpt_base_url;
});
let test = builder.build_with_remote_and_local_env(&server).await?;
assert!(test.config.features.enabled(Feature::Plugins));
assert_eq!(test.config.features.enabled(Feature::Apps), apps_enabled);
wait_for_mcp_server(&test.codex, "sample").await?;
test.codex
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Mention {
name: "sample".into(),
path: format!("plugin://{SAMPLE_REMOTE_PLUGIN_CONFIG_NAME}"),
}]))
.await?;
wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::TurnComplete(_))
})
.await;
let requests = mock.requests();
let (calendar_tool, echo_tool) = searched_plugin_tools(&requests[1]);
assert_eq!(calendar_tool.is_some(), apps_enabled);
if let Some(calendar_tool) = calendar_tool {
assert_plugin_provenance(&calendar_tool);
}
assert_plugin_provenance(&echo_tool.expect("unrelated MCP tool remains available"));
// Disabling Apps must not restore the matching direct MCP connection.
assert!(requests[0].tool_by_name("mcp__calendar", "echo").is_none());
let mcp_output = requests[1].tool_search_output(PLUGIN_MCP_SEARCH_CALL_ID);
assert!(namespace_child_tool(&mcp_output, "mcp__calendar", "echo").is_none());
let apps_connected = server
.received_requests()
.await
.expect("recorded app endpoint requests")
.iter()
.any(|request| request.url.path().trim_end_matches('/') == "/api/codex/ps/mcp");
assert_eq!(apps_connected, apps_enabled);
Ok(())
}
#[test_case("[apps.calendar]\nenabled = true", true; "enabled app")]
#[test_case("[apps.calendar]\nenabled = false", false; "disabled app")]
#[test_case("[plugins.\"sample@test\".apps.calendar]\nenabled = false", false; "nested disabled app")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn explicit_plugin_mentions_use_apps_for_chatgpt_dual_surface_plugins(
app_config: &str,
app_enabled: bool,
) -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let apps_server = AppsTestServer::mount_with_connector_name(&server, "Google Calendar").await?;
let mock = mount_plugin_tool_search_turn(&server).await;
let codex_home = Arc::new(TempDir::new()?);
let rmcp_test_server_bin = match stdio_server_bin() {
Ok(bin) => bin,
Err(err) => {
eprintln!("test_stdio_server binary not available, skipping test: {err}");
return Ok(());
}
};
write_plugin_skill_plugin(codex_home.as_ref());
write_plugin_mcp_plugin(codex_home.as_ref(), &rmcp_test_server_bin);
write_plugin_app_plugin(codex_home.as_ref());
let config_path = codex_home.path().join("config.toml");
let config = std::fs::read_to_string(&config_path)?;
std::fs::write(config_path, format!("{config}\n{app_config}\n"))?;
let test_codex =
build_apps_enabled_plugin_test_codex(&server, codex_home, apps_server.chatgpt_base_url)
.await?;
let codex = Arc::clone(&test_codex.codex);
wait_for_mcp_server(&codex, CODEX_APPS_MCP_SERVER_NAME).await?;
codex
.start_or_steer_turn(TurnInputRequest::user_input(vec![
codex_protocol::user_input::UserInput::Mention {
name: "sample".into(),
path: format!("plugin://{SAMPLE_PLUGIN_CONFIG_NAME}"),
},
]))
.await?;
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
let requests = mock.requests();
let request = &requests[0];
let developer_messages = request.message_input_texts("developer");
assert!(
developer_messages
.iter()
.any(|text| text.contains("Skills from this plugin")),
"expected plugin skills guidance: {developer_messages:?}"
);
assert!(
!developer_messages
.iter()
.any(|text| text.contains("MCP servers from this plugin")),
"expected plugin MCP guidance to be suppressed for ChatGPT auth: {developer_messages:?}"
);
assert_eq!(
developer_messages
.iter()
.any(|text| text.contains("Apps from this plugin")),
app_enabled,
"plugin app guidance should match app enablement: {developer_messages:?}"
);
assert_eq!(
developer_messages
.iter()
.any(|text| text.contains("if `tool_search` is available")),
app_enabled,
"plugin app search guidance should match app enablement: {developer_messages:?}"
);
assert!(
request
.tool_by_name(SAMPLE_PLUGIN_MCP_NAMESPACE, "echo")
.is_none(),
"plugin MCP tool should not leak into the request for ChatGPT auth"
);
let (calendar_tool, echo_tool) = searched_plugin_tools(&requests[1]);
assert_eq!(
calendar_tool.is_some(),
app_enabled,
"plugin app tool search should match app enablement"
);
if let Some(calendar_tool) = calendar_tool {
assert_plugin_provenance(&calendar_tool);
}
assert!(
echo_tool.is_none(),
"plugin MCP tool should be suppressed for ChatGPT auth"
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn explicit_plugin_mentions_keep_non_conflicting_mcp_for_chatgpt_auth() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let apps_server = AppsTestServer::mount_with_connector_name(&server, "Google Calendar").await?;
let mock = mount_plugin_tool_search_turn(&server).await;
let codex_home = Arc::new(TempDir::new()?);
let rmcp_test_server_bin = match stdio_server_bin() {
Ok(bin) => bin,
Err(err) => {
eprintln!("test_stdio_server binary not available, skipping test: {err}");
return Ok(());
}
};
write_plugin_skill_plugin(codex_home.as_ref());
write_plugin_mcp_plugin(codex_home.as_ref(), &rmcp_test_server_bin);
write_plugin_app_plugin_with_name(codex_home.as_ref(), "sample_app");
let test_codex =
build_apps_enabled_plugin_test_codex(&server, codex_home, apps_server.chatgpt_base_url)
.await?;
let codex = Arc::clone(&test_codex.codex);
wait_for_mcp_server(&codex, "sample").await?;
codex
.start_or_steer_turn(TurnInputRequest::user_input(vec![
codex_protocol::user_input::UserInput::Mention {
name: "sample".into(),
path: format!("plugin://{SAMPLE_PLUGIN_CONFIG_NAME}"),
},
]))
.await?;
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
let requests = mock.requests();
let request = &requests[0];
let developer_messages = request.message_input_texts("developer");
assert!(
developer_messages
.iter()
.any(|text| text.contains("MCP servers from this plugin")),
"expected plugin MCP guidance to remain visible for non-conflicting app declaration: {developer_messages:?}"
);
assert!(
developer_messages
.iter()
.any(|text| text.contains("Apps from this plugin")),
"expected plugin app guidance: {developer_messages:?}"
);
let (calendar_tool, echo_tool) = searched_plugin_tools(&requests[1]);
assert!(
calendar_tool.is_some(),
"plugin app tool should be searchable"
);
let echo_tool = echo_tool.expect("plugin MCP tool should remain searchable");
assert_plugin_provenance(&echo_tool);
Ok(())
}
#[test_case(TrustLevel::Trusted, true, true, false, &[]; "trusted project disables the plugin")]
#[test_case(TrustLevel::Untrusted, true, true, false, &["echo_tool"]; "untrusted project cannot disable the plugin")]
#[test_case(TrustLevel::Trusted, false, true, true, &["echo"]; "trusted project enables system-disabled server and overrides user tool policy")]
@@ -1439,18 +1000,11 @@ async fn explicitly_requested_mcp_waits_for_startup(request: ExplicitMcpRequest)
};
let skill_path = dunce::canonicalize(write_plugin_skill_plugin(codex_home.as_ref()))?;
write_plugin_mcp_plugin(codex_home.as_ref(), &rmcp_test_server_bin);
write_plugin_app_plugin(codex_home.as_ref());
let initialize_barrier = block_plugin_mcp_startup(codex_home.as_ref(), &rmcp_test_server_bin);
let mut builder = test_codex()
.with_home(codex_home)
.with_auth(CodexAuth::from_api_key("Test API Key"))
.with_config(move |config| {
config
.features
.enable(Feature::Apps)
.expect("test config should allow feature update");
});
.with_auth(CodexAuth::from_api_key("Test API Key"));
let test_codex = builder.build_with_remote_and_local_env(&server).await?;
let codex = Arc::clone(&test_codex.codex);
@@ -1509,23 +1063,7 @@ async fn explicitly_requested_mcp_waits_for_startup(request: ExplicitMcpRequest)
"expected explicitly requested skill instructions: {user_messages:?}"
);
}
assert!(
!developer_messages
.iter()
.any(|text| text.contains("Apps from this plugin")),
"expected plugin app guidance to be suppressed for API-key auth: {developer_messages:?}"
);
assert!(
model_request
.tool_by_name(SAMPLE_PLUGIN_APP_NAMESPACE, SEARCH_CALENDAR_CREATE_TOOL)
.is_none(),
"plugin app tool should not leak into the request for API-key auth"
);
let (calendar_tool, echo_tool) = searched_plugin_tools(&requests[1]);
assert!(
calendar_tool.is_none(),
"plugin app tool should be hidden for API-key auth"
);
let (_, echo_tool) = searched_plugin_tools(&requests[1]);
let echo_tool = echo_tool.expect("plugin MCP tool should be searchable");
assert_plugin_provenance(&echo_tool);