WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use codex_agent_graph_store::AgentGraphStore;
|
||||
use codex_attachment_store::AttachmentStore;
|
||||
use codex_config::CloudConfigBundleLoader;
|
||||
use codex_config::test_support::ManagedConfigFixture;
|
||||
use codex_core::CodexThread;
|
||||
pub use codex_core::StartThreadOptions;
|
||||
use codex_core::ThreadManager;
|
||||
@@ -84,7 +84,7 @@ use wiremock::MockServer;
|
||||
use crate::TempDirExt;
|
||||
use crate::TestEnvironment;
|
||||
use crate::load_default_config_for_test;
|
||||
use crate::load_default_config_for_test_with_cloud_config_bundle;
|
||||
use crate::load_default_config_for_test_with_managed_config;
|
||||
use crate::responses::WebSocketTestServer;
|
||||
use crate::responses::output_value_to_text;
|
||||
use crate::responses::start_mock_server;
|
||||
@@ -405,15 +405,20 @@ impl TestAuth {
|
||||
}
|
||||
}
|
||||
|
||||
/// Host-supplied header auth without credentials, for tests that exercise the merged
|
||||
/// provider catalog refresh path.
|
||||
pub fn header_auth_for_testing() -> CodexAuth {
|
||||
CodexAuth::Headers(codex_login::AuthHeaders::new(Default::default()))
|
||||
}
|
||||
|
||||
pub struct TestCodexBuilder {
|
||||
apps_tools_cache: codex_core::CodexAppsToolsCache,
|
||||
config_mutators: Vec<Box<ConfigMutator>>,
|
||||
thread_manager_configurer: Option<Box<dyn FnOnce(ThreadManager) -> ThreadManager + Send>>,
|
||||
auth: TestAuth,
|
||||
pre_build_hooks: Vec<Box<PreBuildHook>>,
|
||||
workspace_setups: Vec<Box<WorkspaceSetup>>,
|
||||
home: Option<Arc<TempDir>>,
|
||||
cloud_config_bundle: Option<CloudConfigBundleLoader>,
|
||||
managed_config: Option<ManagedConfigFixture>,
|
||||
user_shell_override: Option<Shell>,
|
||||
exec_server_url: Option<String>,
|
||||
extensions: Arc<ExtensionRegistry<Config>>,
|
||||
@@ -440,8 +445,10 @@ impl TestCodexBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_apps_tools_cache(mut self, cache: codex_core::CodexAppsToolsCache) -> Self {
|
||||
self.apps_tools_cache = cache;
|
||||
/// Authenticate with host-supplied (empty) request headers. Header auth refreshes the
|
||||
/// provider catalog from the provider base URL and merges it over the bundled catalog.
|
||||
pub fn with_header_auth(mut self) -> Self {
|
||||
self.auth = TestAuth::Cached(header_auth_for_testing());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -565,11 +572,9 @@ impl TestCodexBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_cloud_config_bundle(
|
||||
mut self,
|
||||
cloud_config_bundle: CloudConfigBundleLoader,
|
||||
) -> Self {
|
||||
self.cloud_config_bundle = Some(cloud_config_bundle);
|
||||
/// Loads the fixture as local managed requirements / config (system files).
|
||||
pub fn with_managed_config(mut self, managed_config: ManagedConfigFixture) -> Self {
|
||||
self.managed_config = Some(managed_config);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -905,7 +910,6 @@ impl TestCodexBuilder {
|
||||
let thread_manager = ThreadManager::new(
|
||||
&config,
|
||||
startup,
|
||||
self.apps_tools_cache.clone(),
|
||||
SessionSource::Exec,
|
||||
Arc::clone(&environment_manager),
|
||||
Arc::new(extensions.build()),
|
||||
@@ -915,7 +919,6 @@ impl TestCodexBuilder {
|
||||
self.agent_graph_store.clone().or_else(|| {
|
||||
codex_core::local_agent_graph_store_from_state_db(state_db.as_ref())
|
||||
}),
|
||||
/*attestation_provider*/ None,
|
||||
/*external_time_provider*/ self.external_time_provider.clone(),
|
||||
);
|
||||
let thread_manager = match self.thread_manager_configurer.take() {
|
||||
@@ -1032,8 +1035,8 @@ impl TestCodexBuilder {
|
||||
for hook in self.pre_build_hooks.drain(..) {
|
||||
hook(home.path());
|
||||
}
|
||||
let mut config = if let Some(cloud_config_bundle) = self.cloud_config_bundle.take() {
|
||||
load_default_config_for_test_with_cloud_config_bundle(home, cloud_config_bundle).await
|
||||
let mut config = if let Some(managed_config) = self.managed_config.take() {
|
||||
load_default_config_for_test_with_managed_config(home, managed_config).await
|
||||
} else {
|
||||
load_default_config_for_test(home).await
|
||||
};
|
||||
@@ -1041,18 +1044,7 @@ impl TestCodexBuilder {
|
||||
// specific model can still override this with a config mutator.
|
||||
config.model = Some("gpt-5.5".to_string());
|
||||
config.cwd = cwd_override;
|
||||
if self.catalog_discovery {
|
||||
let catalog_url = model_provider
|
||||
.base_url
|
||||
.as_deref()
|
||||
.map(|base_url| format!("{}/models", base_url.trim_end_matches('/')));
|
||||
config.model_provider = ModelProviderInfo {
|
||||
model_catalog_url: catalog_url.map(Into::into),
|
||||
..model_provider
|
||||
};
|
||||
} else {
|
||||
config.model_provider = model_provider;
|
||||
}
|
||||
config.model_provider = model_provider;
|
||||
if let Ok(path) = codex_utils_cargo_bin::cargo_bin("codex") {
|
||||
config.codex_self_exe = Some(path);
|
||||
} else if let Ok(path) = codex_utils_cargo_bin::cargo_bin("codex-exec") {
|
||||
@@ -1076,6 +1068,15 @@ impl TestCodexBuilder {
|
||||
for mutator in mutators {
|
||||
mutator(&mut config);
|
||||
}
|
||||
// Apply after config mutators so tests that replace the provider still get catalog
|
||||
// discovery from the provider they selected.
|
||||
if self.catalog_discovery && config.model_provider.model_catalog_url.is_none() {
|
||||
config.model_provider.model_catalog_url = config
|
||||
.model_provider
|
||||
.base_url
|
||||
.as_deref()
|
||||
.map(|base_url| format!("{}/models", base_url.trim_end_matches('/')).into());
|
||||
}
|
||||
ensure_test_model_catalog(&mut config)?;
|
||||
|
||||
Ok((config, cwd))
|
||||
@@ -1575,7 +1576,6 @@ fn function_call_output<'a>(bodies: &'a [Value], call_id: &str) -> &'a Value {
|
||||
|
||||
pub fn test_codex() -> TestCodexBuilder {
|
||||
TestCodexBuilder {
|
||||
apps_tools_cache: Default::default(),
|
||||
thread_manager_configurer: None,
|
||||
config_mutators: vec![Box::new(|config| {
|
||||
config
|
||||
@@ -1592,7 +1592,7 @@ pub fn test_codex() -> TestCodexBuilder {
|
||||
pre_build_hooks: vec![],
|
||||
workspace_setups: vec![],
|
||||
home: None,
|
||||
cloud_config_bundle: None,
|
||||
managed_config: None,
|
||||
user_shell_override: None,
|
||||
exec_server_url: None,
|
||||
extensions: empty_extension_registry(),
|
||||
|
||||
Reference in New Issue
Block a user