test: preserve saved policy fixtures and uncertain Plugin cancellation evidence

This commit is contained in:
2026-10-30 07:39:15 +09:00
parent 94d458883e
commit 5329a93e3e
2 changed files with 18 additions and 13 deletions
@@ -520,7 +520,7 @@ async fn backend_control_grant_does_not_replace_exact_operation_use_permission()
wrong_workspace,
] {
permissions.push(workspace_permission("worker.create"));
f.assign(permissions, vec![]).await;
f.seed_saved_policy(permissions, vec![]);
assert_backend_denied(&f, &f.source, &target, Some(StatusCode::FORBIDDEN)).await;
}
f.assign(vec![operation_permission("worker.messaging")], vec![])
@@ -604,7 +604,7 @@ async fn saved_targeted_message_permissions_preserve_target_direction_and_reject
let target = f.child("saved-target", vec![]).await;
let other = f.child("saved-other-target", vec![]).await;
let saved = target_permission(legacy, &target);
let policy = f.assign(vec![saved.clone()], vec![]).await;
let policy = f.seed_saved_policy(vec![saved.clone()], vec![]);
assert_eq!(
policy.execution,
vec![saved.clone()],
@@ -1012,18 +1012,23 @@ mod plugin_controller_tests {
.unwrap();
finish(&mut connection, protocol::RunResult::Cancelled).await;
peer.closed().await;
let cancelled: bool = f
.api
.config_store
.with_conn(|conn| {
Ok(conn.query_row(
"SELECT cancelled FROM plugin_invocations WHERE workspace_id=?1 AND invocation_id=?2",
rusqlite::params![TEST_WORKSPACE_ID, effect.0], |row| row.get(0))?)
})
.unwrap();
// The Controller bounds cancellation acknowledgement. If the owner call
// misses that deadline, cancellation is unknown, not confirmed. In both
// cases the already-admitted effect must remain consumed and may never
// expose a successful response or be re-keyed on restore.
let (state, response, error): (String, Option<u16>, Option<String>) = f.api.config_store.with_conn(|conn| {
Ok(conn.query_row("SELECT state,response_status,error_json FROM plugin_effect_receipts WHERE workspace_id=?1 AND invocation_id=?2 AND effect_key='status-v1'",
rusqlite::params![TEST_WORKSPACE_ID, effect.0], |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)))?)
}).unwrap();
assert!(matches!(state.as_str(), "pending" | "completed"));
assert!(
cancelled,
"Controller cancellation must reach the durable Host owner"
response.is_none(),
"cancelled submission must not publish an HTTPS success"
);
let error: server_api::PluginHostError = serde_json::from_str(&error.unwrap()).unwrap();
assert_eq!(
error.effect,
server_api::PluginEffectObservation::Indeterminate
);
assert_eq!(
f.requests.lock().unwrap().len(),