WIP fase 2b-2: rimosso login ChatGPT/OAuth/device code, agent/workload identity, backend-client; resta solo chiave API (test non tutti verdi)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,56 +62,43 @@ impl ModelsTransportBuilder for CaptureModelsUrl {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn api_key_discovery_respects_provider_routing() {
|
||||
let client_version = codex_models_manager::client_version_to_whole();
|
||||
for (api_key, name, base_url, models_url, inference_url) in [
|
||||
(
|
||||
"test-api-key",
|
||||
"OpenAI",
|
||||
None,
|
||||
Some("https://chatgpt.com/backend-api/codex/models"),
|
||||
"https://api.openai.com/v1",
|
||||
),
|
||||
async fn api_key_discovery_respects_provider_routing_and_never_uses_codex_backend() {
|
||||
for (api_key, name, base_url, inference_url) in [
|
||||
("test-api-key", "OpenAI", None, "https://api.openai.com/v1"),
|
||||
(
|
||||
"test-api-key",
|
||||
"OpenAI",
|
||||
Some("https://example.com/codex"),
|
||||
None,
|
||||
"https://example.com/codex",
|
||||
),
|
||||
(
|
||||
"test-api-key",
|
||||
"Azure",
|
||||
Some("https://example.openai.azure.com/openai/v1"),
|
||||
None,
|
||||
"https://example.openai.azure.com/openai/v1",
|
||||
),
|
||||
(
|
||||
"sk-proj-fedramp-synthetic-test-key",
|
||||
"OpenAI",
|
||||
None,
|
||||
Some("https://gov.chatgpt.com/backend-api/codex/models"),
|
||||
"https://gov.api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"sk-svcacct-fedramp-synthetic-test-key",
|
||||
"OpenAI",
|
||||
None,
|
||||
Some("https://gov.chatgpt.com/backend-api/codex/models"),
|
||||
"https://gov.api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"sk-proj-fedramp-synthetic-test-key",
|
||||
"OpenAI",
|
||||
Some("https://example.com/codex"),
|
||||
None,
|
||||
"https://example.com/codex",
|
||||
),
|
||||
(
|
||||
"sk-svcacct-fedramp-synthetic-test-key",
|
||||
"Azure",
|
||||
None,
|
||||
None,
|
||||
"https://api.openai.com/v1",
|
||||
),
|
||||
] {
|
||||
@@ -124,7 +111,6 @@ async fn api_key_discovery_respects_provider_routing() {
|
||||
},
|
||||
auth_manager: Some(auth.clone()),
|
||||
gateway_auth_manager: None,
|
||||
runtime_auth: None,
|
||||
transport_builder: capture.clone(),
|
||||
});
|
||||
let provider = crate::provider::create_model_provider(
|
||||
@@ -139,10 +125,8 @@ async fn api_key_discovery_respects_provider_routing() {
|
||||
HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
*capture.0.lock().unwrap(),
|
||||
models_url.map(|url| format!("{url}?client_version={client_version}"))
|
||||
);
|
||||
// The default OpenAI provider never fetches a catalog from the Codex backend.
|
||||
assert_eq!(*capture.0.lock().unwrap(), None);
|
||||
assert_eq!(
|
||||
provider.api_provider().await.unwrap().base_url,
|
||||
inference_url
|
||||
@@ -151,42 +135,22 @@ async fn api_key_discovery_respects_provider_routing() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn provider_api_key_without_endpoint_overrides_uses_codex_backend() {
|
||||
for (api_key, auth, models_base_url, inference_url) in [
|
||||
(
|
||||
"provider-key",
|
||||
None,
|
||||
CHATGPT_CODEX_BASE_URL,
|
||||
"https://api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"provider-key",
|
||||
Some(CodexAuth::create_dummy_chatgpt_auth_for_testing()),
|
||||
CHATGPT_CODEX_BASE_URL,
|
||||
CHATGPT_CODEX_BASE_URL,
|
||||
),
|
||||
async fn provider_api_key_without_endpoint_overrides_never_contacts_codex_backend() {
|
||||
for (api_key, auth, inference_url) in [
|
||||
("provider-key", None, "https://api.openai.com/v1"),
|
||||
(
|
||||
"provider-key",
|
||||
Some(CodexAuth::from_api_key("sk-proj-fedramp-ambient-key")),
|
||||
CHATGPT_CODEX_BASE_URL,
|
||||
"https://api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"sk-proj-fedramp-provider-key",
|
||||
None,
|
||||
"https://gov.chatgpt.com/backend-api/codex",
|
||||
"https://gov.api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"sk-svcacct-fedramp-provider-key",
|
||||
Some(CodexAuth::from_api_key("legacy-ambient-key")),
|
||||
"https://gov.chatgpt.com/backend-api/codex",
|
||||
"https://gov.api.openai.com/v1",
|
||||
),
|
||||
(
|
||||
"sk-proj-fedramp-provider-key",
|
||||
Some(CodexAuth::create_dummy_chatgpt_auth_for_testing()),
|
||||
"https://gov.chatgpt.com/backend-api/codex",
|
||||
"https://gov.api.openai.com/v1",
|
||||
),
|
||||
] {
|
||||
@@ -199,7 +163,6 @@ async fn provider_api_key_without_endpoint_overrides_uses_codex_backend() {
|
||||
},
|
||||
auth_manager: auth_manager.clone(),
|
||||
gateway_auth_manager: None,
|
||||
runtime_auth: None,
|
||||
transport_builder: capture.clone(),
|
||||
});
|
||||
let provider = crate::provider::create_model_provider(
|
||||
@@ -214,13 +177,7 @@ async fn provider_api_key_without_endpoint_overrides_uses_codex_backend() {
|
||||
HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
*capture.0.lock().unwrap(),
|
||||
Some(format!(
|
||||
"{models_base_url}/models?client_version={}",
|
||||
codex_models_manager::client_version_to_whole(),
|
||||
))
|
||||
);
|
||||
assert_eq!(*capture.0.lock().unwrap(), None);
|
||||
assert_eq!(
|
||||
provider.api_provider().await.unwrap().base_url,
|
||||
inference_url
|
||||
@@ -292,7 +249,6 @@ async fn model_request_uses_request_time_proxy_policy_and_exact_url() {
|
||||
provider_info: ModelProviderInfo::create_openai_provider(Some(server.uri())),
|
||||
auth_manager: None,
|
||||
gateway_auth_manager: None,
|
||||
runtime_auth: None,
|
||||
transport_builder: Arc::new(RecordingTransportBuilder {
|
||||
observed_request: Arc::clone(&observed_request),
|
||||
}),
|
||||
@@ -339,7 +295,6 @@ async fn model_discovery_enforces_managed_residency_over_provider_headers() {
|
||||
provider_info,
|
||||
auth_manager: None,
|
||||
gateway_auth_manager: None,
|
||||
runtime_auth: None,
|
||||
transport_builder: Arc::new(RecordingTransportBuilder {
|
||||
observed_request: Arc::new(Mutex::new(None)),
|
||||
}),
|
||||
@@ -484,7 +439,6 @@ async fn command_auth_refresh_fetches_a_catalog_for_the_current_credentials() {
|
||||
#[tokio::test]
|
||||
async fn explicit_catalog_reuses_auth_headers_and_query_parameters() {
|
||||
for auth in [
|
||||
CodexAuth::create_dummy_chatgpt_auth_for_testing(),
|
||||
CodexAuth::from_api_key("test-key"),
|
||||
CodexAuth::from_api_key("sk-proj-fedramp-synthetic-test-key"),
|
||||
CodexAuth::from_api_key("sk-svcacct-fedramp-synthetic-test-key"),
|
||||
|
||||
Reference in New Issue
Block a user