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:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -38,14 +38,10 @@ use std::time::Duration;
use tempfile::TempDir;
use test_case::test_case;
use tokio::time::timeout;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::path;
const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);
// Helper to create a minimal config.toml for the app server
#[derive(Default)]
struct CreateConfigTomlParams {
@@ -156,9 +152,7 @@ region = "us-west-2"
}
async fn read_account(mcp: &mut TestAppServer) -> Result<GetAccountResponse> {
let request_id = mcp
.send_get_account_request(GetAccountParams {})
.await?;
let request_id = mcp.send_get_account_request(GetAccountParams {}).await?;
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(request_id)).await?
}
@@ -171,10 +165,7 @@ async fn assert_account_updated(
mcp.read_notification("account/updated"),
)
.await??;
assert_eq!(
payload,
AccountUpdatedNotification { auth_mode }
);
assert_eq!(payload, AccountUpdatedNotification { auth_mode });
Ok(())
}
@@ -219,9 +210,7 @@ async fn logout_account_removes_auth_and_notifies() -> Result<()> {
"auth.json should be deleted"
);
let get_id = mcp
.send_get_account_request(GetAccountParams {})
.await?;
let get_id = mcp.send_get_account_request(GetAccountParams {}).await?;
let account: GetAccountResponse =
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(get_id)).await??;
assert_eq!(account.account, None);
@@ -296,30 +285,15 @@ async fn logout_account_succeeds_when_config_reload_fails() -> Result<()> {
Ok(())
}
#[test_case(false, false; "local_auth_before_cloud")]
#[test_case(true, false; "local_mxc_after_cloud_selection")]
#[test_case(false, true; "cloud_mxc_without_default_recovery")]
#[test_case(false; "local_auth_requirements")]
#[test_case(true; "local_mxc_requirement")]
#[tokio::test]
async fn startup_enforces_requirements_at_the_correct_load_stage(
async fn startup_enforces_local_requirements_without_contacting_the_backend(
local_mxc: bool,
cloud_mxc: bool,
) -> Result<()> {
let codex_home = TempDir::new()?;
let mock_server = MockServer::start().await;
let require_mxc = "[windows]\nrequire_mxc = true\n";
let fetch_cloud = local_mxc || cloud_mxc;
if fetch_cloud {
let bundle = codex_config::test_support::CloudConfigBundleFixture::enterprise_requirement(
if cloud_mxc { require_mxc } else { "" },
)
.add_enterprise_config(format!("[features]\nprefer_mxc = {local_mxc}\n"))
.into_bundle();
Mock::given(path("/backend-api/wham/config/bundle"))
.respond_with(ResponseTemplate::new(200).set_body_json(bundle))
.expect(1..)
.mount(&mock_server)
.await;
}
create_config_toml(
codex_home.path(),
CreateConfigTomlParams {
@@ -331,8 +305,6 @@ async fn startup_enforces_requirements_at_the_correct_load_stage(
codex_home.path().join("requirements.toml"),
if local_mxc {
require_mxc
} else if cloud_mxc {
""
} else {
"allowed_login_methods = [\"api\"]\n"
},
@@ -345,7 +317,7 @@ async fn startup_enforces_requirements_at_the_correct_load_stage(
.build()
.await?;
if cfg!(windows) && fetch_cloud && (!local_mxc || !codex_sandboxing::windows_mxc_available()) {
if cfg!(windows) && local_mxc && !codex_sandboxing::windows_mxc_available() {
assert!(
!timeout(DEFAULT_READ_TIMEOUT, mcp.wait_for_exit())
.await??
@@ -353,17 +325,17 @@ async fn startup_enforces_requirements_at_the_correct_load_stage(
);
} else {
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
if !fetch_cloud {
if !local_mxc {
assert_eq!(read_account(&mut mcp).await?.account, None);
}
}
assert_eq!(
// Managed configuration is never fetched from the backend.
assert!(
mock_server
.received_requests()
.await
.expect("recorded requests")
.is_empty(),
!fetch_cloud,
.is_empty()
);
Ok(())
@@ -1483,9 +1455,7 @@ async fn get_account_with_managed_bedrock_provider() -> Result<()> {
.build_initialized_with_timeout(DEFAULT_READ_TIMEOUT)
.await?;
let request_id = mcp
.send_get_account_request(GetAccountParams {})
.await?;
let request_id = mcp.send_get_account_request(GetAccountParams {}).await?;
let received: GetAccountResponse =
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(request_id)).await??;
@@ -1500,4 +1470,3 @@ async fn get_account_with_managed_bedrock_provider() -> Result<()> {
);
Ok(())
}