aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT
- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use codex_config::test_support::CloudConfigBundleFixture;
|
||||
use codex_config::test_support::ManagedConfigFixture;
|
||||
use codex_config::types::AuthCredentialsStoreMode;
|
||||
use codex_core::ModelClient;
|
||||
use codex_core::NewThread;
|
||||
@@ -8,7 +8,8 @@ use codex_core::StartThreadOptions;
|
||||
use codex_core::ThreadManager;
|
||||
use codex_core::ThreadStoreBuilder;
|
||||
use codex_core::TurnInputRequest;
|
||||
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::resolve_installation_id;
|
||||
use codex_extension_api::empty_extension_registry;
|
||||
use codex_features::Feature;
|
||||
@@ -17,7 +18,6 @@ use codex_history::RolloutLine;
|
||||
use codex_login::AuthKeyringBackendKind;
|
||||
use codex_login::AuthManager;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_login::auth::AgentIdentityAuthPolicy;
|
||||
use codex_login::auth::BedrockApiKeyAuth;
|
||||
use codex_login::default_client::originator;
|
||||
use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID;
|
||||
@@ -64,7 +64,6 @@ use codex_protocol::protocol::ThreadSettingsOverrides;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use codex_protocol_test_support::uuid_v7_item_id_generator_for_test;
|
||||
use core_test_support::TestCodexResponsesRequestKind;
|
||||
use core_test_support::apps_test_server::AppsTestServer;
|
||||
use core_test_support::load_default_config_for_test;
|
||||
use core_test_support::responses::ResponsesRequest;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -793,7 +792,7 @@ async fn response_item_ids_are_sent_for_all_remote_v2_compaction_requests() -> a
|
||||
)
|
||||
.await;
|
||||
let test = test_codex()
|
||||
.with_auth(CodexAuth::create_dummy_chatgpt_auth_for_testing())
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.build(&server)
|
||||
.await?;
|
||||
|
||||
@@ -1831,7 +1830,6 @@ async fn send_request_with_provider(provider: ModelProviderInfo) {
|
||||
"unused-api-key",
|
||||
))),
|
||||
),
|
||||
AgentIdentityAuthPolicy::JwtOnly,
|
||||
thread_id,
|
||||
uuid_v7_item_id_generator_for_test(),
|
||||
SessionSource::Exec,
|
||||
@@ -1839,7 +1837,6 @@ async fn send_request_with_provider(provider: ModelProviderInfo) {
|
||||
config.model_verbosity,
|
||||
config.features.enabled(Feature::ContentItemKinds),
|
||||
config.features.enabled(Feature::ReasoningEffortOverride),
|
||||
/*enable_request_compression*/ false,
|
||||
/*include_timing_metrics*/ false,
|
||||
/*beta_features_header*/ None,
|
||||
/*concurrent_reasoning_summaries_enabled*/
|
||||
@@ -1847,9 +1844,7 @@ async fn send_request_with_provider(provider: ModelProviderInfo) {
|
||||
.features
|
||||
.enabled(Feature::ConcurrentReasoningSummaries),
|
||||
/*output_token_replay_enabled*/ false,
|
||||
/*attestation_provider*/ None,
|
||||
config.http_client_factory(),
|
||||
config.workspace_routing_context(),
|
||||
Vec::new(),
|
||||
);
|
||||
let responses_metadata = test_turn_responses_metadata(&client, thread_id);
|
||||
@@ -1936,7 +1931,7 @@ async fn includes_base_instructions_override_in_request() {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn chatgpt_auth_sends_correct_request() {
|
||||
async fn stored_auth_sends_correct_request() {
|
||||
skip_if_no_network!();
|
||||
|
||||
// Mock server
|
||||
@@ -1981,17 +1976,14 @@ async fn chatgpt_auth_sends_correct_request() {
|
||||
.header("authorization")
|
||||
.expect("authorization header");
|
||||
let request_originator = request.header("originator").expect("originator header");
|
||||
let request_chatgpt_account_id = request
|
||||
.header("chatgpt-account-id")
|
||||
.expect("chatgpt-account-id header");
|
||||
let request_body = request.body_json();
|
||||
let model = request_body["model"]
|
||||
.as_str()
|
||||
.expect("missing request model");
|
||||
assert_eq!(
|
||||
request.header(X_CODEX_ROUTING_HINT_HEADER),
|
||||
Some(format!("model={model}"))
|
||||
);
|
||||
// ChatGPT-only routing and account headers are never sent.
|
||||
assert!(!model.is_empty());
|
||||
assert_eq!(request.header(X_CODEX_ROUTING_HINT_HEADER), None);
|
||||
assert_eq!(request.header("chatgpt-account-id"), None);
|
||||
|
||||
let request_session_id = request.header("session-id").expect("session-id header");
|
||||
let request_thread_id = request.header("thread-id").expect("thread-id header");
|
||||
@@ -2004,8 +1996,7 @@ async fn chatgpt_auth_sends_correct_request() {
|
||||
assert_eq!(request_thread_id, thread_id_string.as_str());
|
||||
|
||||
assert_eq!(request_originator, originator().value);
|
||||
assert_eq!(request_authorization, "Bearer Access Token");
|
||||
assert_eq!(request_chatgpt_account_id, "account_id");
|
||||
assert_eq!(request_authorization, "Bearer Test API Key");
|
||||
assert_codex_client_metadata(
|
||||
&request_body,
|
||||
installation_id.as_str(),
|
||||
@@ -2066,9 +2057,7 @@ async fn prefers_apikey_when_config_prefers_apikey_even_with_chatgpt_tokens() {
|
||||
let auth = CodexAuth::from_auth_storage(
|
||||
codex_home.path(),
|
||||
AuthCredentialsStoreMode::File,
|
||||
/*chatgpt_base_url*/ None,
|
||||
AuthKeyringBackendKind::default(),
|
||||
&codex_login::test_support::transport_default_auth_route_config(),
|
||||
)
|
||||
.await
|
||||
.expect("Failed to load CodexAuth")
|
||||
@@ -2085,7 +2074,6 @@ async fn prefers_apikey_when_config_prefers_apikey_even_with_chatgpt_tokens() {
|
||||
installation_id,
|
||||
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
|
||||
),
|
||||
codex_core::CodexAppsToolsCache::default(),
|
||||
SessionSource::Exec,
|
||||
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
|
||||
empty_extension_registry(),
|
||||
@@ -2093,7 +2081,6 @@ async fn prefers_apikey_when_config_prefers_apikey_even_with_chatgpt_tokens() {
|
||||
codex_core::passthrough_image_store(),
|
||||
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
|
||||
/*agent_graph_store*/ None,
|
||||
/*attestation_provider*/ None,
|
||||
/*external_time_provider*/ None,
|
||||
);
|
||||
let NewThread { thread: codex, .. } = thread_manager
|
||||
@@ -2187,275 +2174,6 @@ async fn includes_user_instructions_message_in_request() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn includes_apps_guidance_as_developer_message_for_chatgpt_auth() {
|
||||
skip_if_no_network!();
|
||||
let server = MockServer::start().await;
|
||||
let apps_server = AppsTestServer::mount(&server)
|
||||
.await
|
||||
.expect("mount apps MCP mock");
|
||||
let apps_base_url = apps_server.chatgpt_base_url.clone();
|
||||
|
||||
let resp_mock = mount_sse_once(
|
||||
&server,
|
||||
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut builder = test_codex()
|
||||
.with_auth(create_dummy_codex_auth())
|
||||
.with_config(move |config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Apps)
|
||||
.expect("test config should allow feature update");
|
||||
config.chatgpt_base_url = apps_base_url;
|
||||
});
|
||||
let codex = builder
|
||||
.build(&server)
|
||||
.await
|
||||
.expect("create new conversation")
|
||||
.codex;
|
||||
|
||||
codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}]))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let request = resp_mock.single_request();
|
||||
let apps_snippet =
|
||||
"Apps (Connectors) can be explicitly triggered in user messages in the format";
|
||||
|
||||
assert!(
|
||||
message_input_text_contains(&request, "developer", apps_snippet),
|
||||
"expected apps guidance in a developer message, got {:?}",
|
||||
request.body_json()["input"]
|
||||
);
|
||||
|
||||
assert!(
|
||||
!message_input_text_contains(&request, "user", apps_snippet),
|
||||
"did not expect apps guidance in user messages, got {:?}",
|
||||
request.body_json()["input"]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn omits_apps_guidance_for_api_key_auth_even_when_feature_enabled() {
|
||||
skip_if_no_network!();
|
||||
let server = MockServer::start().await;
|
||||
let apps_server = AppsTestServer::mount(&server)
|
||||
.await
|
||||
.expect("mount apps MCP mock");
|
||||
let apps_base_url = apps_server.chatgpt_base_url.clone();
|
||||
|
||||
let resp_mock = mount_sse_once(
|
||||
&server,
|
||||
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut builder = 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 feature update");
|
||||
config.chatgpt_base_url = apps_base_url;
|
||||
});
|
||||
let codex = builder
|
||||
.build(&server)
|
||||
.await
|
||||
.expect("create new conversation")
|
||||
.codex;
|
||||
|
||||
codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}]))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let request = resp_mock.single_request();
|
||||
let apps_snippet =
|
||||
"Apps (Connectors) can be explicitly triggered in user messages in the format";
|
||||
|
||||
assert!(
|
||||
!message_input_text_contains(&request, "developer", apps_snippet)
|
||||
&& !message_input_text_contains(&request, "user", apps_snippet),
|
||||
"did not expect apps guidance for API key auth, got {:?}",
|
||||
request.body_json()["input"]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn omits_apps_guidance_when_configured_off() {
|
||||
skip_if_no_network!();
|
||||
let server = MockServer::start().await;
|
||||
let apps_server = AppsTestServer::mount(&server)
|
||||
.await
|
||||
.expect("mount apps MCP mock");
|
||||
let apps_base_url = apps_server.chatgpt_base_url.clone();
|
||||
|
||||
let resp_mock = mount_sse_once(
|
||||
&server,
|
||||
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut builder = test_codex()
|
||||
.with_auth(create_dummy_codex_auth())
|
||||
.with_config(move |config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Apps)
|
||||
.expect("test config should allow feature update");
|
||||
config.chatgpt_base_url = apps_base_url;
|
||||
config.include_apps_instructions = false;
|
||||
});
|
||||
let codex = builder
|
||||
.build(&server)
|
||||
.await
|
||||
.expect("create new conversation")
|
||||
.codex;
|
||||
|
||||
codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}]))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let request = resp_mock.single_request();
|
||||
assert!(
|
||||
!message_input_text_contains(&request, "developer", "<apps_instructions>"),
|
||||
"did not expect apps instructions when include_apps_instructions = false, got {:?}",
|
||||
request.body_json()["input"]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn omits_apps_guidance_when_orchestrator_mcp_is_disabled() {
|
||||
skip_if_no_network!();
|
||||
let server = MockServer::start().await;
|
||||
let apps_server = AppsTestServer::mount(&server)
|
||||
.await
|
||||
.expect("mount apps MCP mock");
|
||||
let apps_base_url = apps_server.chatgpt_base_url.clone();
|
||||
|
||||
let list_call_id = "list-resources";
|
||||
let read_call_id = "read-resource";
|
||||
let resp_mock = mount_sse_sequence(
|
||||
&server,
|
||||
vec![
|
||||
sse(vec![
|
||||
ev_response_created("resp1"),
|
||||
ev_function_call(list_call_id, "list_mcp_resources", "{}"),
|
||||
ev_completed("resp1"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_response_created("resp2"),
|
||||
ev_function_call(
|
||||
read_call_id,
|
||||
"read_mcp_resource",
|
||||
&json!({
|
||||
"server": "codex_apps",
|
||||
"uri": "skill://demo/SKILL.md",
|
||||
})
|
||||
.to_string(),
|
||||
),
|
||||
ev_completed("resp2"),
|
||||
]),
|
||||
sse(vec![ev_response_created("resp3"), ev_completed("resp3")]),
|
||||
],
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut builder = test_codex()
|
||||
.with_auth(create_dummy_codex_auth())
|
||||
.with_config(move |config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Apps)
|
||||
.expect("test config should allow feature update");
|
||||
config.chatgpt_base_url = apps_base_url;
|
||||
config.orchestrator_mcp_enabled = false;
|
||||
});
|
||||
let codex = builder
|
||||
.build(&server)
|
||||
.await
|
||||
.expect("create new conversation")
|
||||
.codex;
|
||||
|
||||
codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}]))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let requests = resp_mock.requests();
|
||||
assert_eq!(requests.len(), 3);
|
||||
let request = &requests[0];
|
||||
assert!(
|
||||
!message_input_text_contains(request, "developer", "<apps_instructions>"),
|
||||
"did not expect apps instructions when orchestrator MCP is disabled, got {:?}",
|
||||
request.body_json()["input"]
|
||||
);
|
||||
assert!(
|
||||
!request.body_contains_text("mcp__codex_apps"),
|
||||
"did not expect codex_apps MCP tools when orchestrator MCP is disabled, got {:?}",
|
||||
request.body_json()["tools"]
|
||||
);
|
||||
let list_output = requests[1]
|
||||
.function_call_output_text(list_call_id)
|
||||
.expect("resource list output should be sent to the model");
|
||||
assert_eq!(
|
||||
serde_json::from_str::<serde_json::Value>(&list_output)
|
||||
.expect("parse resource list output"),
|
||||
json!({"resources": []})
|
||||
);
|
||||
let read_output = requests[2]
|
||||
.function_call_output_text(read_call_id)
|
||||
.expect("resource read output should be sent to the model");
|
||||
assert!(
|
||||
read_output.contains("disabled by `orchestrator.mcp.enabled`"),
|
||||
"unexpected resource read output: {read_output}"
|
||||
);
|
||||
|
||||
let resource_methods = server
|
||||
.received_requests()
|
||||
.await
|
||||
.expect("read recorded requests")
|
||||
.into_iter()
|
||||
.filter_map(|request| serde_json::from_slice::<serde_json::Value>(&request.body).ok())
|
||||
.filter_map(|body| {
|
||||
body.get("method")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.map(str::to_owned)
|
||||
})
|
||||
.filter(|method| method.starts_with("resources/"))
|
||||
.collect::<Vec<_>>();
|
||||
assert!(
|
||||
resource_methods.is_empty(),
|
||||
"did not expect codex_apps resource calls: {resource_methods:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn omits_environment_context_when_configured_off() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -2794,7 +2512,7 @@ async fn sequential_cutoff_is_omitted_for_non_openai_provider() -> anyhow::Resul
|
||||
)
|
||||
.await;
|
||||
let TestCodex { codex, .. } = test_codex()
|
||||
.with_auth(CodexAuth::create_dummy_chatgpt_auth_for_testing())
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_config(|config| {
|
||||
config.model_provider.name = "mock".to_string();
|
||||
let _ = config
|
||||
@@ -3233,8 +2951,8 @@ async fn includes_managed_developer_instructions_once_per_request() -> anyhow::R
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex()
|
||||
.with_cloud_config_bundle(
|
||||
CloudConfigBundleFixture::loader_with_enterprise_requirement(format!(
|
||||
.with_managed_config(
|
||||
ManagedConfigFixture::requirements(format!(
|
||||
"additional_developer_instructions = {MANAGED_INSTRUCTIONS:?}"
|
||||
)),
|
||||
)
|
||||
@@ -3337,7 +3055,6 @@ async fn azure_responses_request_does_not_store_and_preserves_prefixed_item_ids(
|
||||
|
||||
let client = ModelClient::new(
|
||||
codex_model_provider::create_model_provider(provider.clone(), /*auth_manager*/ None),
|
||||
AgentIdentityAuthPolicy::JwtOnly,
|
||||
thread_id,
|
||||
uuid_v7_item_id_generator_for_test(),
|
||||
SessionSource::Exec,
|
||||
@@ -3345,14 +3062,11 @@ async fn azure_responses_request_does_not_store_and_preserves_prefixed_item_ids(
|
||||
config.model_verbosity,
|
||||
config.features.enabled(Feature::ContentItemKinds),
|
||||
config.features.enabled(Feature::ReasoningEffortOverride),
|
||||
/*enable_request_compression*/ false,
|
||||
/*include_timing_metrics*/ false,
|
||||
/*beta_features_header*/ None,
|
||||
/*concurrent_reasoning_summaries_enabled*/ false,
|
||||
/*output_token_replay_enabled*/ false,
|
||||
/*attestation_provider*/ None,
|
||||
config.http_client_factory(),
|
||||
config.workspace_routing_context(),
|
||||
Vec::new(),
|
||||
);
|
||||
let responses_metadata = test_turn_responses_metadata(&client, thread_id);
|
||||
@@ -4284,7 +3998,7 @@ async fn env_var_overrides_loaded_auth() {
|
||||
}
|
||||
|
||||
fn create_dummy_codex_auth() -> CodexAuth {
|
||||
CodexAuth::create_dummy_chatgpt_auth_for_testing()
|
||||
CodexAuth::from_api_key("Test API Key")
|
||||
}
|
||||
|
||||
/// Scenario:
|
||||
|
||||
Reference in New Issue
Block a user