aKode fase 2b-1: rimossi plugin remoti e share, bundle download, UI usage/crediti/banner/workspace ChatGPT; fix argomenti MCP (inviati vuoti dopo e4209e2) e overlay TUI; test analytics-upload rimossi; test sicurezza MCP adattati
Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -824,3 +824,35 @@ pub(crate) async fn collect_mcp_server_status_snapshot_from_manager(
|
||||
#[cfg(test)]
|
||||
#[path = "mod_tests.rs"]
|
||||
pub(crate) mod tests;
|
||||
|
||||
/// Test fixture: a generic user-configured streamable HTTP MCP server at `url`.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn test_http_mcp_server_config(url: &str) -> McpServerConfig {
|
||||
McpServerConfig {
|
||||
transport: McpServerTransportConfig::StreamableHttp {
|
||||
url: url.to_string(),
|
||||
bearer_token_env_var: None,
|
||||
http_headers: None,
|
||||
env_http_headers: None,
|
||||
http_headers_helper: None,
|
||||
},
|
||||
auth: McpServerAuth::default(),
|
||||
environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(),
|
||||
enabled: true,
|
||||
required: false,
|
||||
startup_readiness: Default::default(),
|
||||
supports_parallel_tool_calls: false,
|
||||
tool_input_schema_max_bytes: None,
|
||||
omit_tools_from: None,
|
||||
disabled_reason: None,
|
||||
startup_timeout_sec: Some(Duration::from_secs(30)),
|
||||
tool_timeout_sec: None,
|
||||
default_tools_approval_mode: None,
|
||||
enabled_tools: None,
|
||||
disabled_tools: None,
|
||||
scopes: None,
|
||||
oauth: None,
|
||||
oauth_resource: None,
|
||||
tools: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,11 +334,7 @@ fn qualified_mcp_tool_name_prefix_sanitizes_server_names_without_lowercasing() {
|
||||
fn mcp_server_permissions_handle_unattached_and_threadless_servers() {
|
||||
let mut config = test_mcp_config(PathBuf::new());
|
||||
config.permission_profile = PermissionProfile::Disabled;
|
||||
let mut missing_server = codex_apps_mcp_server_config(
|
||||
"https://example.com",
|
||||
/*apps_mcp_product_sku*/ None,
|
||||
/*originator*/ None,
|
||||
);
|
||||
let mut missing_server = test_http_mcp_server_config("https://example.com");
|
||||
missing_server.environment_id = "missing".to_string();
|
||||
let mut selected_server = missing_server.clone();
|
||||
selected_server.environment_id = "unattached".to_string();
|
||||
@@ -445,11 +441,7 @@ fn tool_plugin_context_collects_app_and_mcp_sources() {
|
||||
"alpha".to_string(),
|
||||
McpPluginAttribution::new("alpha@test".to_string(), "alpha-plugin".to_string()),
|
||||
/*plugin_order*/ 0,
|
||||
codex_apps_mcp_server_config(
|
||||
"https://alpha.example",
|
||||
/*apps_mcp_product_sku*/ None,
|
||||
/*originator*/ None,
|
||||
),
|
||||
test_http_mcp_server_config("https://alpha.example"),
|
||||
));
|
||||
config.mcp_server_catalog = catalog.build();
|
||||
config.connector_snapshot =
|
||||
@@ -520,11 +512,7 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
|
||||
),
|
||||
/*selection_order*/ 0,
|
||||
"executor-1",
|
||||
codex_apps_mcp_server_config(
|
||||
"https://github.example",
|
||||
/*apps_mcp_product_sku*/ None,
|
||||
/*originator*/ None,
|
||||
),
|
||||
test_http_mcp_server_config("https://github.example"),
|
||||
));
|
||||
config.mcp_server_catalog = catalog.build();
|
||||
config.connector_snapshot =
|
||||
@@ -559,128 +547,6 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
|
||||
assert!(provenance.is_selected_plugin_mcp_server("github"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_mcp_url_for_base_url_uses_plugin_service_paths() {
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("https://chatgpt.com/backend-api"),
|
||||
"https://chatgpt.com/backend-api/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("https://chat.openai.com"),
|
||||
"https://chat.openai.com/backend-api/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("https://gov.chatgpt.com/backend-api/"),
|
||||
"https://gov.chatgpt.com/backend-api/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("http://localhost:8080/api/codex"),
|
||||
"http://localhost:8080/api/codex/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("http://localhost:8080"),
|
||||
"http://localhost:8080/api/codex/ps/mcp"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_server_config_uses_plugin_service_path() {
|
||||
let config = codex_apps_mcp_server_config(
|
||||
"https://chatgpt.com",
|
||||
/*apps_mcp_product_sku*/ None,
|
||||
/*originator*/ None,
|
||||
);
|
||||
let url = match &config.transport {
|
||||
McpServerTransportConfig::StreamableHttp { url, .. } => url,
|
||||
_ => panic!("expected streamable http transport for codex apps"),
|
||||
};
|
||||
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_server_config_forwards_thread_originator_header() {
|
||||
let config = codex_apps_mcp_server_config(
|
||||
"https://chatgpt.com",
|
||||
/*apps_mcp_product_sku*/ None,
|
||||
Some("thread_originator"),
|
||||
);
|
||||
|
||||
match &config.transport {
|
||||
McpServerTransportConfig::StreamableHttp {
|
||||
http_headers,
|
||||
env_http_headers,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(
|
||||
http_headers,
|
||||
&Some(HashMap::from([
|
||||
("originator".to_string(), "thread_originator".to_string()),
|
||||
("X-OpenAI-Product-Sku".to_string(), "codex".to_string()),
|
||||
]))
|
||||
);
|
||||
assert!(env_http_headers.is_none());
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_server_config_sets_product_sku_header() {
|
||||
for (configured_product_sku, expected_product_sku) in [(None, "codex"), (Some("tpp"), "tpp")] {
|
||||
let config = codex_apps_mcp_server_config(
|
||||
"https://chatgpt.com",
|
||||
configured_product_sku,
|
||||
/*originator*/ None,
|
||||
);
|
||||
|
||||
match &config.transport {
|
||||
McpServerTransportConfig::StreamableHttp {
|
||||
http_headers,
|
||||
env_http_headers,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(
|
||||
http_headers,
|
||||
&Some(HashMap::from([(
|
||||
"X-OpenAI-Product-Sku".to_string(),
|
||||
expected_product_sku.to_string(),
|
||||
)]))
|
||||
);
|
||||
assert!(env_http_headers.is_none());
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_server_config_forwards_originator_and_configured_product_sku_headers() {
|
||||
let config = codex_apps_mcp_server_config(
|
||||
"https://chatgpt.com",
|
||||
Some("tpp"),
|
||||
Some("thread_originator"),
|
||||
);
|
||||
|
||||
match &config.transport {
|
||||
McpServerTransportConfig::StreamableHttp {
|
||||
http_headers,
|
||||
env_http_headers,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(
|
||||
http_headers,
|
||||
&Some(HashMap::from([
|
||||
("originator".to_string(), "thread_originator".to_string()),
|
||||
("X-OpenAI-Product-Sku".to_string(), "tpp".to_string()),
|
||||
]))
|
||||
);
|
||||
assert!(env_http_headers.is_none());
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn effective_mcp_servers_preserve_executor_credential_policy() {
|
||||
let mut config = test_mcp_config(PathBuf::new());
|
||||
@@ -747,9 +613,8 @@ fn effective_mcp_servers_preserve_chatgpt_auth_for_trusted_origins() {
|
||||
] {
|
||||
let mut config = test_mcp_config(PathBuf::new());
|
||||
config.chatgpt_base_url = base_url.to_string();
|
||||
let server = codex_apps_mcp_server_config(
|
||||
server_url, /*apps_mcp_product_sku*/ None, /*originator*/ None,
|
||||
);
|
||||
let mut server = test_http_mcp_server_config(server_url);
|
||||
server.auth = McpServerAuth::ChatGpt;
|
||||
let mut catalog = ResolvedMcpCatalog::builder();
|
||||
catalog.register(McpServerRegistration::from_config(
|
||||
"trusted".to_string(),
|
||||
@@ -780,9 +645,8 @@ fn effective_mcp_servers_reject_untrusted_origins_for_chatgpt_auth() {
|
||||
] {
|
||||
let mut config = test_mcp_config(PathBuf::new());
|
||||
config.chatgpt_base_url = url.to_string();
|
||||
let server = codex_apps_mcp_server_config(
|
||||
url, /*apps_mcp_product_sku*/ None, /*originator*/ None,
|
||||
);
|
||||
let mut server = test_http_mcp_server_config(url);
|
||||
server.auth = McpServerAuth::ChatGpt;
|
||||
let mut catalog = ResolvedMcpCatalog::builder();
|
||||
catalog.register(McpServerRegistration::from_config(
|
||||
"untrusted".to_string(),
|
||||
@@ -870,11 +734,7 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
|
||||
));
|
||||
catalog.register(McpServerRegistration::from_config(
|
||||
CODEX_APPS_MCP_SERVER_NAME.to_string(),
|
||||
codex_apps_mcp_server_config(
|
||||
&config.chatgpt_base_url,
|
||||
config.apps_mcp_product_sku.as_deref(),
|
||||
/*originator*/ None,
|
||||
),
|
||||
test_http_mcp_server_config("https://chatgpt.com/backend-api/ps/mcp"),
|
||||
));
|
||||
config.mcp_server_catalog = catalog.build();
|
||||
|
||||
@@ -884,13 +744,11 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
|
||||
let docs = effective
|
||||
.get("docs")
|
||||
.expect("configured server should exist");
|
||||
let codex_apps = effective
|
||||
.get(CODEX_APPS_MCP_SERVER_NAME)
|
||||
.expect("codex apps server should exist");
|
||||
// aKode never connects to the ChatGPT-hosted apps MCP server.
|
||||
assert!(!effective.contains_key(CODEX_APPS_MCP_SERVER_NAME));
|
||||
|
||||
let sample = sample.config();
|
||||
let docs = docs.config();
|
||||
let codex_apps = codex_apps.config();
|
||||
|
||||
match &sample.transport {
|
||||
McpServerTransportConfig::StreamableHttp { url, .. } => {
|
||||
@@ -904,10 +762,4 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
match &codex_apps.transport {
|
||||
McpServerTransportConfig::StreamableHttp { url, .. } => {
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user