Files
imeai-aKode/akode-rs/app-server/tests/suite/v2/application_network.rs
andrea.difonzo 24a3cfe2f4 aKode: eliminato chatgpt_base_url ormai inutilizzato
- La chiave è ancora accettata nei file di configurazione ma ignorata.
- Schemi JSON e TypeScript dell'app-server rigenerati; i bundle ora si
  chiamano akode_app_server_protocol*.schemas.json, come produce il
  generatore.
- app-server: niente più avviso unused_mut nella build release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:40:27 +01:00

56 lines
2.2 KiB
Rust

//! Application policy is enforced through public thread and turn RPCs.
use akode_app_server_protocol::ThreadStartParams;
use akode_app_server_protocol::TurnCompletedNotification;
use akode_app_server_protocol::TurnStatus;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::write_models_cache;
use core_test_support::streaming_sse::StreamingSseChunk;
use core_test_support::streaming_sse::start_streaming_sse_server;
use pretty_assertions::assert_eq;
use std::time::Duration;
use tempfile::TempDir;
use tokio::time::timeout;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn explicit_reloads_apply_local_edits_and_cancel_active_responses() -> Result<()> {
for requirements in ["[application.network]", "[malformed"] {
let (_release, gate) = tokio::sync::oneshot::channel();
let (destination, _) = start_streaming_sse_server(vec![vec![StreamingSseChunk {
gate: Some(gate),
body: String::new(),
}]])
.await;
let home = TempDir::new()?;
MockResponsesConfig::new(destination.uri()).write(home.path())?;
write_models_cache(home.path()).await?;
let mut app = TestAppServer::builder()
.with_codex_home(home.path())
.build_initialized()
.await?;
let thread = app.start_thread(ThreadStartParams::default()).await?.thread;
let params = serde_json::json!({
"threadId": thread.id, "input": [{"type": "text", "text": "Hello"}]
});
app.send_request("turn/start", Some(params)).await?;
timeout(
Duration::from_secs(/*secs*/ 30),
destination.wait_for_request_count(/*count*/ 1),
)
.await?;
std::fs::write(home.path().join("requirements.toml"), requirements)?;
app.send_request("config/read", Some(serde_json::json!({})))
.await?;
let completed: TurnCompletedNotification = timeout(
Duration::from_secs(/*secs*/ 5),
app.read_notification("turn/completed"),
)
.await??;
assert_eq!(completed.turn.status, TurnStatus::Failed);
destination.shutdown().await;
}
Ok(())
}