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:
andrea.difonzo
2026-11-17 12:39:59 +01:00
parent 7effb5ec86
commit 499ee3a939
63 changed files with 160 additions and 532 deletions

View File

@@ -228,16 +228,6 @@ pub fn write_mock_responses_config_toml(
config.write(codex_home)
}
pub fn write_mock_responses_config_toml_with_chatgpt_base_url(
codex_home: &Path,
server_uri: &str,
chatgpt_base_url: &str,
) -> std::io::Result<()> {
MockResponsesConfig::new(server_uri)
.with_root_config(&format!("chatgpt_base_url = \"{chatgpt_base_url}\""))
.write(codex_home)
}
#[cfg(test)]
#[path = "config_tests.rs"]
mod tests;

View File

@@ -13,7 +13,7 @@ fn mock_responses_config_composes_model_provider_features_and_extra_tables() {
.with_sandbox_mode("workspace-write")
.enable_feature(Feature::FastMode)
.disable_feature(Feature::ShellSnapshot)
.with_root_config("chatgpt_base_url = \"http://127.0.0.1:1234\"")
.with_root_config("check_for_update_on_startup = false")
.with_provider_config("requires_openai_auth = true")
.with_extra_config("[extra]\nenabled = true")
.write(home.path())
@@ -25,7 +25,7 @@ fn mock_responses_config_composes_model_provider_features_and_extra_tables() {
"model = \"custom-model\"",
"approval_policy = \"on-request\"",
"sandbox_mode = \"workspace-write\"",
"chatgpt_base_url = \"http://127.0.0.1:1234\"",
"check_for_update_on_startup = false",
"model_provider = \"openai-custom\"",
"shell_snapshot = false",
"fast_mode = true",

View File

@@ -14,7 +14,6 @@ use akode_app_server_protocol::JSONRPCResponse;
pub use config::MockResponsesConfig;
pub use config::bundled_model_catalog_config;
pub use config::write_mock_responses_config_toml;
pub use config::write_mock_responses_config_toml_with_chatgpt_base_url;
pub use core_test_support::PathBufExt;
pub use core_test_support::format_with_current_shell;
pub use core_test_support::format_with_current_shell_display;

View File

@@ -131,11 +131,6 @@ use core_test_support::test_codex::test_env;
use serde::de::DeserializeOwned;
use tempfile::TempDir;
use tokio::process::Command;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
use crate::json_logging::JsonLogCapture;
use crate::local_websocket_exec_server::LocalWebsocketExecServer;
@@ -156,7 +151,6 @@ pub struct TestAppServer {
// Fields drop in declaration order. Tear down the delayed child before
// removing an owned AKODE_HOME that may still be its cwd on Windows.
_delayed_exec_server: Option<(LocalWebsocketExecServer, WebsocketDelayInterposer)>,
_attribution_settings_server: Option<MockServer>,
_owned_install_dir: Option<TempDir>,
_owned_codex_home: Option<TempDir>,
}
@@ -180,7 +174,6 @@ impl TestAppServer {
env_overrides: Vec::new(),
args: vec![DISABLE_PLUGIN_STARTUP_TASKS_ARG.to_string()],
exec_server_delay: None,
mock_chatgpt_backend: false,
}
}
@@ -344,7 +337,6 @@ impl TestAppServer {
auto_env: None,
json_logs,
_delayed_exec_server: None,
_attribution_settings_server: None,
_owned_install_dir: None,
_owned_codex_home: None,
})
@@ -1804,7 +1796,6 @@ pub struct TestAppServerBuilder {
env_overrides: Vec<(String, Option<String>)>,
args: Vec<String>,
exec_server_delay: Option<Duration>,
mock_chatgpt_backend: bool,
}
enum TestAppServerEnvironment {
@@ -1813,11 +1804,6 @@ enum TestAppServerEnvironment {
}
impl TestAppServerBuilder {
pub fn with_mock_chatgpt_backend(mut self) -> Self {
self.mock_chatgpt_backend = true;
self
}
/// Uses this existing AKODE_HOME instead of a temporary one.
pub fn with_codex_home(mut self, codex_home: &Path) -> Self {
self.codex_home = Some(codex_home.to_path_buf());
@@ -1913,7 +1899,6 @@ impl TestAppServerBuilder {
mut env_overrides,
args,
exec_server_delay,
mock_chatgpt_backend,
} = self;
let (codex_home, owned_codex_home) = match codex_home {
Some(codex_home) => (codex_home, None),
@@ -1925,42 +1910,6 @@ impl TestAppServerBuilder {
)
}
};
let attribution_settings_server = if mock_chatgpt_backend
|| codex_home.join("auth.json").is_file()
{
let config_path = codex_home.join("config.toml");
let config = std::fs::read_to_string(&config_path)?;
if config
.lines()
.any(|line| line.trim_start().starts_with("chatgpt_base_url"))
{
None
} else {
let settings_server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/backend-api/wham/config/bundle"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
.mount(&settings_server)
.await;
Mock::given(method("GET"))
.and(path("/backend-api/wham/settings/user"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
"commit_attribution_enabled": false,
})))
.mount(&settings_server)
.await;
std::fs::write(
&config_path,
format!(
"chatgpt_base_url = \"{}/backend-api\"\n{config}",
settings_server.uri()
),
)?;
Some(settings_server)
}
} else {
None
};
let (auto_env, delayed_exec_server) = match environment {
TestAppServerEnvironment::Auto => {
let environments_toml = codex_home.join("environments.toml");
@@ -2090,7 +2039,6 @@ impl TestAppServerBuilder {
app_server._owned_install_dir = owned_install_dir;
app_server._owned_codex_home = owned_codex_home;
app_server._delayed_exec_server = delayed_exec_server;
app_server._attribution_settings_server = attribution_settings_server;
Ok(app_server)
}
}