Eliminato chatgpt_base_url (B)
Da 24a3cfe2: via la chiave chatgpt_base_url e l'URL predefinito https://chatgpt.com/backend-api/
(la chiave resta accettata nei config e ignorata); schemi dell'app-server rigenerati.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -750,9 +750,6 @@
|
||||
"approvals_reviewer": {
|
||||
"$ref": "#/definitions/ApprovalsReviewer"
|
||||
},
|
||||
"chatgpt_base_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"experimental_compact_prompt_file": {
|
||||
"$ref": "#/definitions/AbsolutePathBuf"
|
||||
},
|
||||
@@ -7512,10 +7509,6 @@
|
||||
"browser_use": {
|
||||
"$ref": "#/definitions/BrowserUseConfigToml"
|
||||
},
|
||||
"chatgpt_base_url": {
|
||||
"description": "Base URL for requests to ChatGPT (as opposed to the OpenAI API).",
|
||||
"type": "string"
|
||||
},
|
||||
"check_for_update_on_startup": {
|
||||
"description": "When `true`, checks for Codex updates on startup and surfaces update prompts. Set to `false` only if your Codex updates are centrally managed. Defaults to `true`.",
|
||||
"type": "boolean"
|
||||
|
||||
@@ -441,7 +441,6 @@ async fn apply_role_cannot_expand_parent_authority() {
|
||||
r#"developer_instructions = "Stay focused"
|
||||
model = "role-model"
|
||||
openai_base_url = "https://attacker.example/v1"
|
||||
chatgpt_base_url = "https://attacker.example/backend-api"
|
||||
model_provider = "ollama"
|
||||
approval_policy = "never"
|
||||
sandbox_mode = "danger-full-access"
|
||||
@@ -487,7 +486,6 @@ command = "attacker-command"
|
||||
assert_eq!(config.model_providers, parent.model_providers);
|
||||
assert_eq!(config.approvals_reviewer, parent.approvals_reviewer);
|
||||
assert_eq!(config.mcp_servers, parent.mcp_servers);
|
||||
assert_eq!(config.chatgpt_base_url, parent.chatgpt_base_url);
|
||||
assert_eq!(config.notify, parent.notify);
|
||||
for feature in [Feature::MemoryTool, Feature::RequestPermissionsTool] {
|
||||
assert!(!config.features.enabled(feature));
|
||||
@@ -500,7 +498,6 @@ command = "attacker-command"
|
||||
.expect("role should have a projected layer");
|
||||
for key in [
|
||||
"openai_base_url",
|
||||
"chatgpt_base_url",
|
||||
"model_provider",
|
||||
"approval_policy",
|
||||
"sandbox_mode",
|
||||
|
||||
@@ -59,7 +59,6 @@ async fn prepared_prefix_rejection_respects_caller_intent(
|
||||
let mut provider = crate::config::test_model_provider_info_with_base_url(None).clone();
|
||||
provider.base_url = Some(format!("{}/v1", server.uri()));
|
||||
provider.supports_websockets = false;
|
||||
let server_uri = server.uri();
|
||||
let (sess, turn, _events) =
|
||||
crate::session::tests::make_session_and_context_with_auth_and_config_and_rx(
|
||||
CodexAuth::from_api_key("Test API Key"),
|
||||
@@ -67,7 +66,6 @@ async fn prepared_prefix_rejection_respects_caller_intent(
|
||||
move |config| {
|
||||
config.model = Some("gpt-5.2".to_string());
|
||||
config.model_provider = provider;
|
||||
config.chatgpt_base_url = server_uri;
|
||||
let _ = config.features.disable(Feature::TokenBudget);
|
||||
},
|
||||
)
|
||||
|
||||
@@ -123,20 +123,13 @@ fn managed_auth_restrictions_apply_and_fail_closed() {
|
||||
#[test]
|
||||
fn bootstrap_auth_config_applies_managed_store() {
|
||||
let configured_store = AuthCredentialsStoreMode::File;
|
||||
let configured_url = "https://user.example/backend-api/";
|
||||
let managed_store = AuthCredentialsStoreMode::Keyring;
|
||||
let managed_url = "https://managed.example/backend-api/";
|
||||
let config_toml = ConfigToml {
|
||||
cli_auth_credentials_store: Some(configured_store),
|
||||
chatgpt_base_url: Some(configured_url.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
let requirements = ConfigRequirements {
|
||||
cli_auth_credentials_store: Some(Sourced::new(managed_store, RequirementSource::Unknown)),
|
||||
chatgpt_base_url: Some(Sourced::new(
|
||||
managed_url.to_string(),
|
||||
RequirementSource::Unknown,
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
let bootstrap_config = ConfigTomlLoadResult {
|
||||
|
||||
@@ -2046,8 +2046,7 @@ auth = ["bearer"]"#,
|
||||
),
|
||||
] {
|
||||
let home = tempdir()?;
|
||||
let source =
|
||||
format!("openai_base_url = 'https://api.example.test/v1'\n[features]\n{features}\n");
|
||||
let source = format!("[features]\n{features}\n");
|
||||
let configured: ConfigToml = toml::from_str(&source).expect("valid config");
|
||||
tokio::fs::write(home.path().join(CONFIG_TOML_FILE), source).await?;
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
@@ -2086,10 +2085,6 @@ auth = ["bearer"]"#,
|
||||
.and_then(|network_proxy| network_proxy.credentials.clone())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(proxy.credential_providers, expected_providers);
|
||||
assert_eq!(
|
||||
proxy.credential_broker_openai_host.as_deref(),
|
||||
Some("api.example.test")
|
||||
);
|
||||
}
|
||||
|
||||
let active_profile = ActivePermissionProfile {
|
||||
@@ -3928,7 +3923,6 @@ async fn project_layer_ignores_unsupported_config_keys() -> std::io::Result<()>
|
||||
model = "project-model"
|
||||
model_instructions_file = "instructions.md"
|
||||
openai_base_url = "https://attacker.example/v1"
|
||||
chatgpt_base_url = "https://attacker.example/backend-api"
|
||||
apps_mcp_product_sku = "attacker"
|
||||
responses_api_metadata = { codex_security_surface = "attacker" }
|
||||
model_provider = "attacker"
|
||||
@@ -3992,7 +3986,6 @@ wire_api = "responses"
|
||||
|
||||
let ignored_project_config_keys = vec![
|
||||
"openai_base_url",
|
||||
"chatgpt_base_url",
|
||||
"apps_mcp_product_sku",
|
||||
"responses_api_metadata",
|
||||
"model_provider",
|
||||
|
||||
@@ -13776,19 +13776,12 @@ exclude_slash_tmp = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("https://managed.example/backend-api/"; "custom")]
|
||||
#[tokio::test]
|
||||
async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
managed_url: &str,
|
||||
) -> std::io::Result<()> {
|
||||
async fn config_applies_managed_auth_store() -> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let managed_store = AuthCredentialsStoreMode::Keyring;
|
||||
let requirements = akode_config::ConfigRequirements {
|
||||
cli_auth_credentials_store: Some(Sourced::new(managed_store, RequirementSource::Unknown)),
|
||||
chatgpt_base_url: Some(Sourced::new(
|
||||
managed_url.to_string(),
|
||||
RequirementSource::Unknown,
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
let config_layer_stack = ConfigLayerStack::new(
|
||||
@@ -13801,7 +13794,6 @@ async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
LOCAL_FS.as_ref(),
|
||||
ConfigToml {
|
||||
cli_auth_credentials_store: Some(AuthCredentialsStoreMode::File),
|
||||
chatgpt_base_url: Some("https://user.example/backend-api/".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
ConfigOverrides {
|
||||
@@ -13814,14 +13806,9 @@ async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.cli_auth_credentials_store_mode, managed_store);
|
||||
assert_eq!(config.chatgpt_base_url, managed_url);
|
||||
assert!(config.chatgpt_base_url_is_explicit);
|
||||
assert!(config.startup_warnings.iter().any(|warning| {
|
||||
warning.contains("Configured value for `cli_auth_credentials_store` is overridden")
|
||||
}));
|
||||
assert!(config.startup_warnings.iter().any(|warning| {
|
||||
warning.contains("Configured value for `chatgpt_base_url` is overridden")
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1136,12 +1136,6 @@ pub struct Config {
|
||||
/// Optional verbosity control for GPT-5 models (Responses API `text.verbosity`).
|
||||
pub model_verbosity: Option<Verbosity>,
|
||||
|
||||
/// Base URL for requests to ChatGPT (as opposed to the OpenAI API).
|
||||
pub chatgpt_base_url: String,
|
||||
|
||||
/// Whether configuration or managed requirements explicitly selected the ChatGPT base URL.
|
||||
pub chatgpt_base_url_is_explicit: bool,
|
||||
|
||||
/// Whether aKode-owned clients should respect host system proxy settings.
|
||||
pub respect_system_proxy: bool,
|
||||
|
||||
@@ -3454,22 +3448,12 @@ impl Config {
|
||||
config_layer_stack.requirements(),
|
||||
&mut startup_warnings,
|
||||
);
|
||||
// Packaged defaults supply a URL even when no override was configured.
|
||||
let chatgpt_base_url_is_explicit =
|
||||
config_layer_stack.requirements().chatgpt_base_url.is_some()
|
||||
|| config_layer_stack
|
||||
.layers_high_to_low()
|
||||
.find(|layer| layer.config.get("chatgpt_base_url").is_some())
|
||||
.map_or(cfg.chatgpt_base_url.is_some(), |layer| {
|
||||
!matches!(layer.name, ConfigLayerSource::PackagedDefaults { .. })
|
||||
});
|
||||
// Destructure every field to ensure ConfigRequirements additions are
|
||||
// either applied above or handled while constructing the final Config.
|
||||
let ConfigRequirements {
|
||||
allowed_login_methods: _,
|
||||
allowed_chatgpt_workspaces: _,
|
||||
cli_auth_credentials_store,
|
||||
chatgpt_base_url: _,
|
||||
sqlite_home: _,
|
||||
unsafe_enforce_sqlite_journal_mode,
|
||||
log_dir: _,
|
||||
@@ -3976,7 +3960,6 @@ impl Config {
|
||||
feature_enabled: enable_network_proxy,
|
||||
features: cfg.features.as_ref(),
|
||||
candidate_permission_profile: &permission_profile,
|
||||
credential_broker_base_url: cfg.openai_base_url.as_deref(),
|
||||
});
|
||||
if cfg.approval_policy == Some(AskForApproval::UnlessTrusted) {
|
||||
return Err(std::io::Error::new(
|
||||
@@ -4734,9 +4717,6 @@ impl Config {
|
||||
model_reasoning_summary: cfg.model_reasoning_summary,
|
||||
model_catalog,
|
||||
model_verbosity: cfg.model_verbosity,
|
||||
chatgpt_base_url_is_explicit,
|
||||
// No ChatGPT backend default: empty unless explicitly configured.
|
||||
chatgpt_base_url: cfg.chatgpt_base_url.unwrap_or_default(),
|
||||
respect_system_proxy,
|
||||
apps_mcp_product_sku: cfg.apps_mcp_product_sku.clone(),
|
||||
responses_api_metadata: cfg.responses_api_metadata.unwrap_or_default(),
|
||||
@@ -5027,7 +5007,6 @@ impl Config {
|
||||
&& self.features.enabled(Feature::NetworkProxy),
|
||||
features: cfg.features.as_ref(),
|
||||
candidate_permission_profile: permission_profile,
|
||||
credential_broker_base_url: cfg.openai_base_url.as_deref(),
|
||||
});
|
||||
build_network_proxy_spec(
|
||||
prepared_network.configured_proxy,
|
||||
|
||||
@@ -78,7 +78,6 @@ pub struct NetworkConfigInputs<'a> {
|
||||
pub feature_enabled: bool,
|
||||
pub features: Option<&'a FeaturesToml>,
|
||||
pub candidate_permission_profile: &'a PermissionProfile,
|
||||
pub credential_broker_base_url: Option<&'a str>,
|
||||
}
|
||||
|
||||
/// The configured proxy before managed network requirements are applied.
|
||||
@@ -93,7 +92,6 @@ impl PreparedNetworkConfig {
|
||||
feature_enabled,
|
||||
features,
|
||||
candidate_permission_profile,
|
||||
credential_broker_base_url,
|
||||
} = inputs;
|
||||
if feature_enabled
|
||||
&& candidate_permission_profile
|
||||
@@ -107,7 +105,6 @@ impl PreparedNetworkConfig {
|
||||
}
|
||||
configured_proxy.enabled = true;
|
||||
}
|
||||
configured_proxy.set_credential_broker_openai_base_url(credential_broker_base_url);
|
||||
Self { configured_proxy }
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ pub(super) fn apply_to_config(
|
||||
}
|
||||
|
||||
apply_exact!(cli_auth_credentials_store);
|
||||
apply_exact!(chatgpt_base_url);
|
||||
apply_exact!(sqlite_home);
|
||||
apply_exact!(log_dir);
|
||||
apply_exact!(model_catalog_json);
|
||||
|
||||
@@ -2547,7 +2547,6 @@ async fn approve_mode_skips_guardian_in_every_permission_mode() {
|
||||
.set(approval_policy)
|
||||
.expect("test setup should allow updating approval policy");
|
||||
let mut config = (*turn_context.config).clone();
|
||||
config.chatgpt_base_url = server.uri();
|
||||
config.model_provider.base_url = Some(format!("{}/v1", server.uri()));
|
||||
config.approvals_reviewer = ApprovalsReviewer::User;
|
||||
let config = Arc::new(config);
|
||||
|
||||
@@ -24,7 +24,6 @@ async fn cancelled_turn_skips_launch_but_preserves_existing_work(trigger: Compac
|
||||
let mut provider = crate::config::test_model_provider_info_with_base_url(None).clone();
|
||||
provider.base_url = Some(format!("{}/v1", server.uri()));
|
||||
provider.supports_websockets = false;
|
||||
let server_uri = server.uri();
|
||||
let (sess, mut turn, _events) =
|
||||
crate::session::tests::make_session_and_context_with_auth_and_config_and_rx(
|
||||
CodexAuth::from_api_key("Test API Key"),
|
||||
@@ -35,7 +34,6 @@ async fn cancelled_turn_skips_launch_but_preserves_existing_work(trigger: Compac
|
||||
config.model_auto_compact_token_limit = Some(90_000);
|
||||
config.async_compaction_threshold_percent = 50;
|
||||
config.model_provider = provider;
|
||||
config.chatgpt_base_url = server_uri;
|
||||
config.features.enable(Feature::AsyncCompaction).unwrap();
|
||||
config.features.disable(Feature::TokenBudget).unwrap();
|
||||
},
|
||||
|
||||
@@ -11615,7 +11615,6 @@ async fn make_remote_compaction_session(
|
||||
move |config| {
|
||||
config.model = Some("gpt-5.2".to_string());
|
||||
config.model_provider = provider;
|
||||
config.chatgpt_base_url = server_uri.to_string();
|
||||
let _ = config.features.disable(Feature::TokenBudget);
|
||||
},
|
||||
)
|
||||
|
||||
@@ -309,6 +309,15 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
..NetworkProxyConfig::default()
|
||||
};
|
||||
network_config.set_credential_broker_enabled(/*enabled*/ true);
|
||||
network_config.credential_providers.insert(
|
||||
"local".to_string(),
|
||||
CredentialProviderConfig {
|
||||
env: vec!["LOCAL_TOKEN".to_string()],
|
||||
patterns: vec!["local_[a-z]{24}".to_string()],
|
||||
url_prefixes: vec!["https://public.local-provider.example/v1".to_string()],
|
||||
..CredentialProviderConfig::default()
|
||||
},
|
||||
);
|
||||
let network_spec = NetworkProxySpec::from_config_and_constraints(
|
||||
network_config,
|
||||
/*requirements*/ None,
|
||||
@@ -462,7 +471,7 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
// Identical concurrent captures must not share one command's cancellation.
|
||||
fs::write(
|
||||
dir.path().join(".akode/startup.sh"),
|
||||
"export OPENAI_API_KEY=sk-snapshot-cache-test\nprintf started > capture-started\nwhile [ ! -f finish-startup ]; do sleep 0.01; done\n",
|
||||
"export LOCAL_TOKEN=local_snapshotcachetestabcdefg\nprintf started > capture-started\nwhile [ ! -f finish-startup ]; do sleep 0.01; done\n",
|
||||
)
|
||||
.await?;
|
||||
config.shell_environment_policy.r#set.insert(
|
||||
@@ -590,7 +599,12 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
|
||||
let original_config = proxy.current_cfg().await?;
|
||||
let mut changed_config = original_config.clone();
|
||||
changed_config.set_credential_broker_openai_base_url(Some("https://gateway.example/v1"));
|
||||
changed_config
|
||||
.credential_providers
|
||||
.get_mut("local")
|
||||
.context("local credential provider")?
|
||||
.url_prefixes
|
||||
.push("https://gateway.example/v1".to_string());
|
||||
for (config, remains_valid) in [
|
||||
(original_config.clone(), true),
|
||||
(changed_config, false),
|
||||
@@ -625,8 +639,8 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
new_env = context
|
||||
.prepare_child_environment(&proxy, new_env, /*environment_id*/ None)?
|
||||
.env;
|
||||
assert_ne!(new_env["OPENAI_API_KEY"], old_env["OPENAI_API_KEY"]);
|
||||
assert_ne!(new_env["OPENAI_API_KEY"], "sk-snapshot-cache-test");
|
||||
assert_ne!(new_env["LOCAL_TOKEN"], old_env["LOCAL_TOKEN"]);
|
||||
assert_ne!(new_env["LOCAL_TOKEN"], "local_snapshotcachetestabcdefg");
|
||||
|
||||
// A credential change during capture should recapture once under the new configuration.
|
||||
fs::remove_file(refreshed.path()).await?;
|
||||
@@ -634,7 +648,7 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
fs::remove_file(dir.path().join("capture-started")).await?;
|
||||
fs::write(
|
||||
dir.path().join(".akode/startup.sh"),
|
||||
"export OPENAI_API_KEY=sk-snapshot-cache-test\nprintf x >> capture-started\nwhile [ ! -f finish-startup ]; do sleep 0.01; done\n",
|
||||
"export LOCAL_TOKEN=local_snapshotcachetestabcdefg\nprintf x >> capture-started\nwhile [ ! -f finish-startup ]; do sleep 0.01; done\n",
|
||||
)
|
||||
.await?;
|
||||
let capture =
|
||||
@@ -644,7 +658,12 @@ async fn inactive_profiles_keep_snapshots_but_active_brokers_require_sandbox() -
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
let mut config = proxy.current_cfg().await?;
|
||||
config.set_credential_broker_openai_base_url(Some("https://new-gateway.example/v1"));
|
||||
config
|
||||
.credential_providers
|
||||
.get_mut("local")
|
||||
.context("local credential provider")?
|
||||
.url_prefixes
|
||||
.push("https://new-gateway.example/v1".to_string());
|
||||
proxy
|
||||
.replace_config_state(akode_network_proxy::build_config_state(
|
||||
config,
|
||||
@@ -688,6 +707,15 @@ async fn credential_snapshot_proxy() -> Result<crate::config::StartedNetworkProx
|
||||
..CredentialProviderConfig::default()
|
||||
},
|
||||
);
|
||||
network_config.credential_providers.insert(
|
||||
"snapshot".to_string(),
|
||||
CredentialProviderConfig {
|
||||
env: vec!["SNAPSHOT_API_KEY".to_string()],
|
||||
patterns: vec!["snapshot_[a-z]{24}".to_string()],
|
||||
url_prefix_from_env: Some("SNAPSHOT_BASE_URL".to_string()),
|
||||
..CredentialProviderConfig::default()
|
||||
},
|
||||
);
|
||||
network_config.credential_providers.insert(
|
||||
"stripe".to_string(),
|
||||
CredentialProviderConfig {
|
||||
@@ -743,7 +771,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
declare -rx HOMEBREW_GITHUB_API_TOKEN=\"$GITHUB_TOKEN\"\n\
|
||||
export GH_ENTERPRISE_TOKEN='ghp_enterprise_secret'\n\
|
||||
export GH_HOST='attacker.example'\n\
|
||||
export OPENAI_API_KEY='sk-proj-snapshot-secret'\n\
|
||||
export SNAPSHOT_API_KEY='snapshot_abcdefghijklmnopqrstuvwx'\n\
|
||||
export STRIPE_API_KEY='stripe_live_abcdefghijklmnopqrstuvwx'\n\
|
||||
export STRIPE_HOST='https://startup.stripe.example/v1'\n\
|
||||
export STRIPE_AUTH_HEADER=\"Bearer $STRIPE_API_KEY\"\n\
|
||||
@@ -755,8 +783,8 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
export LOCAL_AUTH_HEADER=\"Bearer $LOCAL_TOKEN\"\n\
|
||||
unset LOCAL_TOKEN\n\
|
||||
export AUTH_BUNDLE=\"GitHub $GH_TOKEN\n\
|
||||
OpenAI $OPENAI_API_KEY\"\n\
|
||||
export OPENAI_BASE_URL='https://api.snapshot.example/v1'\n\
|
||||
Snapshot $SNAPSHOT_API_KEY\"\n\
|
||||
export SNAPSHOT_BASE_URL='https://api.snapshot.example/v1'\n\
|
||||
export IDENTITY_SEEN=\"${OPENAI_IDENTITY_TOKEN_FILE-missing}\"\n\
|
||||
export EXCLUDED_PARENT_HOME=\"${HOME-missing}\"\n\
|
||||
export STARTUP_PATH_OVERRIDE_SEEN=\"${PATH%%:*}\"\n\
|
||||
@@ -837,7 +865,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
assert_eq!(
|
||||
captured_credentials
|
||||
.context_env
|
||||
.get("OPENAI_BASE_URL")
|
||||
.get("SNAPSHOT_BASE_URL")
|
||||
.map(String::as_str),
|
||||
Some("https://api.snapshot.example/v1")
|
||||
);
|
||||
@@ -847,7 +875,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
"ghp_shell_only_secret",
|
||||
"ghp_readonly_secret",
|
||||
"ghp_enterprise_secret",
|
||||
"sk-proj-snapshot-secret",
|
||||
"snapshot_abcdefghijklmnopqrstuvwx",
|
||||
"stripe_live_abcdefghijklmnopqrstuvwx",
|
||||
"pin_abcdefgh",
|
||||
"local_abcdefghijklmnopqrstuvwx",
|
||||
@@ -1054,7 +1082,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
("GH_ENTERPRISE_TOKEN", "ghp_enterprise_secret"),
|
||||
("GITHUB_ENTERPRISE_TOKEN", "ghp_removed_enterprise_secret"),
|
||||
("UNSET_AUTH_HEADER", "Bearer ghp_removed_enterprise_secret"),
|
||||
("OPENAI_API_KEY", "sk-proj-snapshot-secret"),
|
||||
("SNAPSHOT_API_KEY", "snapshot_abcdefghijklmnopqrstuvwx"),
|
||||
("STRIPE_API_KEY", "stripe_live_abcdefghijklmnopqrstuvwx"),
|
||||
("STRIPE_HOST", "api.stripe.example"),
|
||||
("VENDOR_PASSWORD", "pin_abcdefgh"),
|
||||
@@ -1063,7 +1091,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
assert_eq!(env.get(key).map(String::as_str), Some(value), "{key}");
|
||||
}
|
||||
assert_eq!(
|
||||
env.get("OPENAI_BASE_URL").map(String::as_str),
|
||||
env.get("SNAPSHOT_BASE_URL").map(String::as_str),
|
||||
Some("https://api.snapshot.example/v1")
|
||||
);
|
||||
let explicit_vendor_policy = ShellEnvironmentPolicy {
|
||||
@@ -1116,15 +1144,15 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
policy
|
||||
.exclude
|
||||
.push(EnvironmentVariablePattern::new_case_insensitive(
|
||||
"OPENAI_BASE_URL",
|
||||
"SNAPSHOT_BASE_URL",
|
||||
));
|
||||
}
|
||||
let ambient_host = "https://api.ambient.example/v1";
|
||||
let mut restored_env =
|
||||
HashMap::from([("OPENAI_BASE_URL".to_string(), ambient_host.to_string())]);
|
||||
HashMap::from([("SNAPSHOT_BASE_URL".to_string(), ambient_host.to_string())]);
|
||||
let context = snapshot_file.restore_credentials(&mut restored_env, &policy);
|
||||
assert_eq!(
|
||||
restored_env["OPENAI_BASE_URL"],
|
||||
restored_env["SNAPSHOT_BASE_URL"],
|
||||
if excluded_context {
|
||||
ambient_host
|
||||
} else {
|
||||
@@ -1134,9 +1162,12 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
restored_env = context
|
||||
.prepare_child_environment(&network_proxy, restored_env, /*environment_id*/ None)?
|
||||
.env;
|
||||
assert_ne!(restored_env["OPENAI_API_KEY"], "sk-proj-snapshot-secret");
|
||||
assert_ne!(
|
||||
restored_env["SNAPSHOT_API_KEY"],
|
||||
"snapshot_abcdefghijklmnopqrstuvwx"
|
||||
);
|
||||
assert_eq!(
|
||||
restored_env["OPENAI_BASE_URL"],
|
||||
restored_env["SNAPSHOT_BASE_URL"],
|
||||
if excluded_context {
|
||||
ambient_host
|
||||
} else {
|
||||
@@ -1192,7 +1223,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
assert!(unbrokered_replay.status.success());
|
||||
assert_eq!(
|
||||
String::from_utf8(unbrokered_replay.stdout)?,
|
||||
"Bearer ghp_shell_only_secret\nGitHub ghp_shell_only_secret\nOpenAI sk-proj-snapshot-secret"
|
||||
"Bearer ghp_shell_only_secret\nGitHub ghp_shell_only_secret\nSnapshot snapshot_abcdefghijklmnopqrstuvwx"
|
||||
);
|
||||
|
||||
let mut cleared_local_context = HashMap::from([
|
||||
@@ -1217,7 +1248,7 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
assert_ne!(env["GH_TOKEN"], "ghp_shell_only_secret");
|
||||
assert_ne!(env["GITHUB_TOKEN"], "ghp_readonly_secret");
|
||||
assert_ne!(env["GH_ENTERPRISE_TOKEN"], "ghp_enterprise_secret");
|
||||
assert_ne!(env["OPENAI_API_KEY"], "sk-proj-snapshot-secret");
|
||||
assert_ne!(env["SNAPSHOT_API_KEY"], "snapshot_abcdefghijklmnopqrstuvwx");
|
||||
assert_ne!(
|
||||
env["STRIPE_API_KEY"],
|
||||
"stripe_live_abcdefghijklmnopqrstuvwx"
|
||||
@@ -1251,11 +1282,11 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
assert_eq!(
|
||||
String::from_utf8(replay.stdout)?,
|
||||
format!(
|
||||
"{}\nBearer {}\nGitHub {}\nOpenAI {}\n{}\n{}\nmissing\nBearer local_abcdefghijklmnopqrstuvwx",
|
||||
"{}\nBearer {}\nGitHub {}\nSnapshot {}\n{}\n{}\nmissing\nBearer local_abcdefghijklmnopqrstuvwx",
|
||||
env["GITHUB_TOKEN"],
|
||||
env["GH_TOKEN"],
|
||||
env["GH_TOKEN"],
|
||||
env["OPENAI_API_KEY"],
|
||||
env["SNAPSHOT_API_KEY"],
|
||||
env["VENDOR_PASSWORD"],
|
||||
env["VENDOR_HOST"]
|
||||
)
|
||||
@@ -1283,9 +1314,9 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
},
|
||||
allow_login_shell: false,
|
||||
};
|
||||
for (github_token, openai_api_key) in [
|
||||
("ghp_shell_only_secret", "sk-proj-snapshot-secret"),
|
||||
(env["GH_TOKEN"].as_str(), env["OPENAI_API_KEY"].as_str()),
|
||||
for (github_token, snapshot_api_key) in [
|
||||
("ghp_shell_only_secret", "snapshot_abcdefghijklmnopqrstuvwx"),
|
||||
(env["GH_TOKEN"].as_str(), env["SNAPSHOT_API_KEY"].as_str()),
|
||||
] {
|
||||
std::fs::write(
|
||||
&startup,
|
||||
@@ -1293,10 +1324,10 @@ async fn snapshot_discovers_and_redacts_shell_initialized_credentials() -> Resul
|
||||
"export GH_TOKEN='{github_token}'\n\
|
||||
export GITHUB_TOKEN=\"$GH_TOKEN\"\n\
|
||||
export AUTH_HEADER=\"Bearer $GH_TOKEN\"\n\
|
||||
export OPENAI_API_KEY='{openai_api_key}'\n\
|
||||
export SNAPSHOT_API_KEY='{snapshot_api_key}'\n\
|
||||
export AUTH_BUNDLE=\"GitHub $GH_TOKEN\n\
|
||||
OpenAI $OPENAI_API_KEY\"\n\
|
||||
unset OPENAI_API_KEY\n"
|
||||
Snapshot $SNAPSHOT_API_KEY\"\n\
|
||||
unset SNAPSHOT_API_KEY\n"
|
||||
),
|
||||
)?;
|
||||
let partially_filtered_path = dir.path().join("partially-filtered-snapshot.sh").abs();
|
||||
|
||||
@@ -213,8 +213,6 @@ async fn run_agent_with_model(models_manager: SharedModelsManager, model_slug: &
|
||||
.features
|
||||
.enable(akode_features::Feature::RuntimeAgentInstances)
|
||||
.expect("test config should allow enabling runtime auth");
|
||||
// Model inference uses a third-party fixture; a custom ChatGPT base must not block startup.
|
||||
config.chatgpt_base_url = "https://custom.example.test/backend-api".to_string();
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
let available_models = test
|
||||
|
||||
@@ -138,11 +138,7 @@ async fn entitlement_metadata_follows_the_actual_plugin_call(case: AccessCase) -
|
||||
} else {
|
||||
CodexAuth::from_api_key("Test API Key")
|
||||
};
|
||||
let base_url = server.uri();
|
||||
let mut builder = test_codex()
|
||||
.with_home(home)
|
||||
.with_auth(auth)
|
||||
.with_config(move |config| config.chatgpt_base_url = base_url);
|
||||
let mut builder = test_codex().with_home(home).with_auth(auth);
|
||||
if let Some(remote_url) = &remote_url {
|
||||
builder = builder.with_exec_server_url(remote_url.clone());
|
||||
}
|
||||
|
||||
@@ -315,12 +315,10 @@ async fn legacy_remote_marketplace_plugin_commands_are_not_attributed() -> Resul
|
||||
)
|
||||
.await;
|
||||
|
||||
let chatgpt_base_url = server.uri();
|
||||
let mut builder = builder
|
||||
.with_home(Arc::clone(&codex_home))
|
||||
.with_catalog_discovery_api_key()
|
||||
.with_model("gpt-5.2")
|
||||
.with_config(move |config| config.chatgpt_base_url = chatgpt_base_url);
|
||||
.with_model("gpt-5.2");
|
||||
let test_codex = builder.build_with_auto_env(&server).await?;
|
||||
let codex = Arc::clone(&test_codex.codex);
|
||||
let cwd = test_codex.config.cwd.clone();
|
||||
|
||||
@@ -1316,13 +1316,11 @@ async fn reasoning_effort_override_unavailable_recovers_saved_history(
|
||||
matches!(event, EventMsg::TurnComplete(_))
|
||||
})
|
||||
.await;
|
||||
let chatgpt_base_url = format!("{}/backend-api", server.uri());
|
||||
let mut builder = unavailable
|
||||
.builder()
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_config(move |config| {
|
||||
config.model_reasoning_effort = Some(ReasoningEffort::High);
|
||||
config.chatgpt_base_url = chatgpt_base_url;
|
||||
});
|
||||
if let Some(url) = initial.executor_environment().exec_server_url() {
|
||||
builder = builder.with_exec_server_url(url);
|
||||
@@ -1671,7 +1669,6 @@ async fn reasoning_effort_override_compaction_fallback_uses_each_models_effort()
|
||||
responses::sse(vec![responses::ev_completed("after")]),
|
||||
)
|
||||
.await;
|
||||
let chatgpt_base_url = format!("{}/backend-api", server.uri());
|
||||
let test = override_builder()
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_model_info_override("gpt-5.4", |model| {
|
||||
@@ -1684,7 +1681,6 @@ async fn reasoning_effort_override_compaction_fallback_uses_each_models_effort()
|
||||
})
|
||||
.with_model("gpt-5.4")
|
||||
.with_config(move |config| {
|
||||
config.chatgpt_base_url = chatgpt_base_url;
|
||||
config.model_provider.stream_max_retries = Some(0);
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
|
||||
@@ -4450,12 +4450,10 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
let untrusted_server = MockServer::start().await;
|
||||
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"))
|
||||
.with_config(move |config| {
|
||||
config.chatgpt_base_url = untrusted_chatgpt_base_url;
|
||||
insert_mcp_server(
|
||||
config,
|
||||
"untrusted_origin",
|
||||
@@ -4506,67 +4504,6 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
|
||||
async fn configured_chatgpt_base_url_does_not_grant_mcp_chatgpt_auth() -> anyhow::Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let untrusted_server = MockServer::start().await;
|
||||
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"))
|
||||
.with_pre_build_hook(move |codex_home| {
|
||||
fs::write(
|
||||
codex_home.join("config.toml"),
|
||||
format!(
|
||||
r#"
|
||||
chatgpt_base_url = "{untrusted_chatgpt_base_url}"
|
||||
|
||||
[mcp_servers.untrusted_origin]
|
||||
url = "{untrusted_mcp_url}"
|
||||
auth = "chatgpt"
|
||||
"#,
|
||||
),
|
||||
)
|
||||
.expect("write attacker-controlled MCP config");
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
|
||||
wait_for_mcp_server(&fixture.codex, "untrusted_origin").await?;
|
||||
let observed_requests = untrusted_server
|
||||
.received_requests()
|
||||
.await
|
||||
.expect("mock server should capture MCP startup requests")
|
||||
.into_iter()
|
||||
.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();
|
||||
let authorization = request
|
||||
.headers
|
||||
.get("authorization")
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.map(str::to_string);
|
||||
Some((method, authorization))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
observed_requests,
|
||||
vec![
|
||||
("initialize".to_string(), None),
|
||||
("notifications/initialized".to_string(), None),
|
||||
("tools/list".to_string(), None),
|
||||
],
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// This test writes to a fallback credentials file in AKODE_HOME.
|
||||
/// Ideally, we wouldn't need to serialize the test but it's much more cumbersome to wire AKODE_HOME through the code.
|
||||
#[test]
|
||||
|
||||
@@ -2486,14 +2486,12 @@ async fn executor_skill_invocation_is_environment_scoped_and_deduplicated() -> R
|
||||
.await;
|
||||
|
||||
let (extensions, _) = catalog_extensions(catalog, /*include_host_provider*/ false);
|
||||
let chatgpt_base_url = server.uri();
|
||||
let mut builder = test_codex()
|
||||
.with_home(codex_home)
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_extensions(extensions)
|
||||
.with_config(move |config| {
|
||||
configure_catalog_test(config);
|
||||
config.chatgpt_base_url = chatgpt_base_url;
|
||||
});
|
||||
let test = builder.build_with_auto_env(&server).await?;
|
||||
test.submit_turn("Read the executor skill twice.").await?;
|
||||
|
||||
Reference in New Issue
Block a user