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:
@@ -30,7 +30,8 @@ use codex_core::EnvironmentConfig;
|
||||
use codex_core::EnvironmentMcpPolicy;
|
||||
use codex_core::TurnInputRequest;
|
||||
use codex_core::TurnStartOptions;
|
||||
use codex_core::X_CODEX_ROUTING_HINT_HEADER;
|
||||
/// No request may carry the hosted backend routing hint.
|
||||
const X_CODEX_ROUTING_HINT_HEADER: &str = "x-codex-routing-hint";
|
||||
use codex_core::config::Config;
|
||||
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
|
||||
use codex_exec_server::CreateDirectoryOptions;
|
||||
@@ -40,7 +41,7 @@ use codex_exec_server::HttpRequestParams;
|
||||
use codex_features::Feature;
|
||||
use codex_http_client::HttpClientBuilder;
|
||||
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_mcp::MCP_SANDBOX_LAUNCHER_META_KEY;
|
||||
use codex_mcp::MCP_SANDBOX_STATE_CAPABILITY;
|
||||
use codex_mcp::MCP_SANDBOX_STATE_META_CAPABILITY;
|
||||
@@ -94,13 +95,12 @@ use codex_protocol::protocol::TurnSettingsUpdate;
|
||||
use codex_protocol::protocol::TurnSettingsUpdateOutcome;
|
||||
use codex_protocol::request_user_input::RequestUserInputAnswer;
|
||||
use codex_protocol::request_user_input::RequestUserInputResponse;
|
||||
use codex_protocol::turn_input::CyberAccessProgram;
|
||||
use codex_protocol::turn_input::TurnInput;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_cargo_bin::cargo_bin;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use core_test_support::apps_test_server::AppsTestServer;
|
||||
use core_test_support::mcp_test_server::McpTestServer;
|
||||
use core_test_support::assert_regex_match;
|
||||
use core_test_support::is_remote_test_environment;
|
||||
use core_test_support::responses;
|
||||
@@ -119,6 +119,8 @@ use core_test_support::test_codex::turn_permission_fields;
|
||||
use core_test_support::test_docker_container_name;
|
||||
use core_test_support::wait_for_event;
|
||||
use core_test_support::wait_for_mcp_server;
|
||||
use core_test_support::mcp_test_server::configure_mcp_test_server;
|
||||
use core_test_support::mcp_test_server::CALENDAR_NAMESPACE;
|
||||
use http::StatusCode;
|
||||
use image::DynamicImage;
|
||||
use image::GenericImageView;
|
||||
@@ -482,14 +484,12 @@ enum AgentMetadataCase {
|
||||
UserOverride,
|
||||
}
|
||||
|
||||
#[test_case(AgentMetadataCase::ApprovedPlugin, Some(CyberAccessProgram::Standard); "approved plugin")]
|
||||
#[test_case(AgentMetadataCase::ApprovedPlugin, None; "approved plugin without an explicit program")]
|
||||
#[test_case(AgentMetadataCase::UserOverride, Some(CyberAccessProgram::Standard); "same-name user override")]
|
||||
#[test_case(AgentMetadataCase::NoHostOptIn, Some(CyberAccessProgram::Standard); "matching plugin without host opt-in")]
|
||||
#[test_case(AgentMetadataCase::ApprovedPlugin; "approved plugin")]
|
||||
#[test_case(AgentMetadataCase::UserOverride; "same-name user override")]
|
||||
#[test_case(AgentMetadataCase::NoHostOptIn; "matching plugin without host opt-in")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn agent_metadata_is_only_sent_to_the_selected_plugin(
|
||||
case: AgentMetadataCase,
|
||||
cyber_access_program: Option<CyberAccessProgram>,
|
||||
) -> anyhow::Result<()> {
|
||||
skip_if_wine_exec!(
|
||||
Ok(()),
|
||||
@@ -536,7 +536,6 @@ async fn agent_metadata_is_only_sent_to_the_selected_plugin(
|
||||
TurnStartOptions {
|
||||
root_turn_id: Some("original-root".into()),
|
||||
turn_trigger: Some("composer".into()),
|
||||
cyber_access_program,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@@ -548,10 +547,6 @@ async fn agent_metadata_is_only_sent_to_the_selected_plugin(
|
||||
meta.get("x-codex-root-turn-id").cloned(),
|
||||
expect_private_metadata.then(|| json!("original-root"))
|
||||
);
|
||||
assert_eq!(
|
||||
meta.get("x-codex-cyber-access-program").cloned(),
|
||||
expect_private_metadata.then(|| json!(cyber_access_program))
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1722,12 +1717,12 @@ async fn mcp_pagination_preserves_valid_tools_and_rejects_oversized_cursors(
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn apps_enabled_turn_skips_pending_optional_mcp_without_cached_tools() -> anyhow::Result<()> {
|
||||
async fn ready_mcp_turn_skips_pending_optional_mcp_without_cached_tools() -> anyhow::Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let apps_server = AppsTestServer::mount(&server).await?;
|
||||
let apps_base_url = apps_server.chatgpt_base_url.clone();
|
||||
let apps_server = McpTestServer::mount(&server).await?;
|
||||
let apps_base_url = apps_server.base_url.clone();
|
||||
let response_mock = mount_sse_once(
|
||||
&server,
|
||||
responses::sse(vec![
|
||||
@@ -1743,11 +1738,7 @@ async fn apps_enabled_turn_skips_pending_optional_mcp_without_cached_tools() ->
|
||||
let fixture = test_codex()
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_config(move |config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Apps)
|
||||
.expect("test config should allow Apps override");
|
||||
config.chatgpt_base_url = apps_base_url;
|
||||
configure_mcp_test_server(config, &apps_base_url);
|
||||
insert_mcp_server(
|
||||
config,
|
||||
"pending_optional",
|
||||
@@ -1774,9 +1765,9 @@ async fn apps_enabled_turn_skips_pending_optional_mcp_without_cached_tools() ->
|
||||
.codex
|
||||
.next_event()
|
||||
.await
|
||||
.context("event stream ended before Codex Apps became ready")?;
|
||||
.context("event stream ended before the calendar MCP server became ready")?;
|
||||
if let EventMsg::McpStartupUpdate(update) = event.msg
|
||||
&& update.server == CODEX_APPS_MCP_SERVER_NAME
|
||||
&& update.server == MCP_TEST_SERVER_NAME
|
||||
&& matches!(update.status, McpStartupStatus::Ready)
|
||||
{
|
||||
break Ok::<(), anyhow::Error>(());
|
||||
@@ -1784,13 +1775,16 @@ async fn apps_enabled_turn_skips_pending_optional_mcp_without_cached_tools() ->
|
||||
}
|
||||
})
|
||||
.await
|
||||
.context("Codex Apps should finish starting before the first turn")??;
|
||||
.context("the calendar MCP server should finish starting before the first turn")??;
|
||||
|
||||
tokio::time::timeout(Duration::from_secs(5), fixture.submit_turn("hello"))
|
||||
.await
|
||||
.context("a pending optional MCP must not block the first turn")??;
|
||||
let body = response_mock.single_request().body_json();
|
||||
assert!(body["input"].to_string().contains("<apps_instructions>"));
|
||||
assert!(
|
||||
body.to_string().contains(CALENDAR_NAMESPACE),
|
||||
"the ready MCP server's tools should reach the first turn"
|
||||
);
|
||||
let tools = body["tools"].as_array().expect("model request tools");
|
||||
assert!(tools.iter().all(|tool| {
|
||||
tool.get("name")
|
||||
@@ -1974,7 +1968,7 @@ async fn startup_prewarm_connects_before_delayed_mcp_tools_then_reuses_socket(
|
||||
server
|
||||
.single_handshake()
|
||||
.header(X_CODEX_ROUTING_HINT_HEADER),
|
||||
Some(format!("model=gpt-5.4;tier={service_tier}"))
|
||||
None
|
||||
);
|
||||
assert!(
|
||||
server.single_connection().is_empty(),
|
||||
@@ -2346,7 +2340,6 @@ async fn local_stdio_server_uses_runtime_fallback_cwd_when_config_omits_cwd() ->
|
||||
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),
|
||||
}
|
||||
});
|
||||
@@ -3666,7 +3659,6 @@ async fn stdio_image_responses_are_sanitized_for_text_only_model() -> anyhow::Re
|
||||
additional_speed_tiers: Vec::new(),
|
||||
service_tiers: Vec::new(),
|
||||
default_service_tier: None,
|
||||
available_access_programs: None,
|
||||
upgrade: None,
|
||||
model_messages: None,
|
||||
include_skills_usage_instructions: false,
|
||||
@@ -4456,9 +4448,9 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let untrusted_server = MockServer::start().await;
|
||||
let untrusted_apps = AppsTestServer::mount(&untrusted_server).await?;
|
||||
let untrusted_mcp_url = format!("{}/api/codex/ps/mcp", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_chatgpt_base_url = untrusted_apps.chatgpt_base_url;
|
||||
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"))
|
||||
@@ -4489,7 +4481,7 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
.await
|
||||
.expect("mock server should capture MCP startup requests")
|
||||
.into_iter()
|
||||
.filter(|request| request.url.path() == "/api/codex/ps/mcp")
|
||||
.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();
|
||||
@@ -4520,9 +4512,9 @@ async fn configured_chatgpt_base_url_does_not_grant_mcp_chatgpt_auth() -> anyhow
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let untrusted_server = MockServer::start().await;
|
||||
let untrusted_apps = AppsTestServer::mount(&untrusted_server).await?;
|
||||
let untrusted_mcp_url = format!("{}/api/codex/ps/mcp", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_chatgpt_base_url = untrusted_apps.chatgpt_base_url;
|
||||
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"))
|
||||
@@ -4550,7 +4542,7 @@ auth = "chatgpt"
|
||||
.await
|
||||
.expect("mock server should capture MCP startup requests")
|
||||
.into_iter()
|
||||
.filter(|request| request.url.path() == "/api/codex/ps/mcp")
|
||||
.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();
|
||||
|
||||
Reference in New Issue
Block a user