From 19f3647f0ec6d13b58ec48f15e157ccd4074b669 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Fri, 12 Jun 2026 17:27:37 +0200 Subject: [PATCH] test(audit-2026-06-11): fix status-code + rotted /version assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Postgres-backed integration tests surfaced two assertion fixes while verifying the audit branch: * email_inbound::create_without_inbound_secret_is_rejected (added in the H-B2 commit) asserted 400; TriggersApiError::Invalid maps to 422 (UNPROCESSABLE_ENTITY). Corrected. * api::version_includes_public_base_url had two rotted assertions — `schema` pinned at 6 (it's migrations::latest_version(), which had climbed to 41 and is now 42 after 0042_secrets_envelope_version.sql) and `sdk` pinned at "1.1" (the crate is at "1.10"). The test is #[ignore]-gated so the rot went unnoticed in normal runs. Both pinned to current reality. These were pre-existing failures, not caused by the security changes. Verified against a throwaway Postgres: schema_snapshot, api (53), authz (28 of 29 — see below), dispatcher_e2e, email_inbound, invoke_e2e, queue_e2e all green. Known pre-existing failure (NOT fixed here, out of Tier 1+2 scope): authz::deactivating_user_revokes_their_api_keys fails identically on the pre-branch merge-base. It's the PrincipalCache revocation-lag Medium the audit flagged as unfixed (resolve_principal caches by token-hash with no eviction on deactivation; lag bounded by the 60s TTL). Deferred to a Tier 3/4 pass. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/picloud/tests/api.rs | 10 ++++++++-- crates/picloud/tests/email_inbound.rs | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/picloud/tests/api.rs b/crates/picloud/tests/api.rs index cdf8aba..3e1841d 100644 --- a/crates/picloud/tests/api.rs +++ b/crates/picloud/tests/api.rs @@ -890,8 +890,14 @@ async fn version_includes_public_base_url(pool: PgPool) { let v: Value = r.json(); assert!(v["public_base_url"].is_string()); assert_eq!(v["api"], 1); - assert_eq!(v["schema"], 6); - assert_eq!(v["sdk"], "1.1"); + // `schema` is migrations::latest_version() — the highest embedded + // migration number. Bumped to 42 by audit 2026-06-11's + // 0042_secrets_envelope_version.sql (H-D1). Both this and `sdk` had + // rotted (pinned at 6 / "1.1" while the codebase moved to 41 / "1.10") + // because the test is #[ignore]-gated; pinned to current reality so + // unintended changes are still caught. + assert_eq!(v["schema"], 42); + assert_eq!(v["sdk"], "1.10"); } // ============================================================================ diff --git a/crates/picloud/tests/email_inbound.rs b/crates/picloud/tests/email_inbound.rs index 8e85a18..16e6f93 100644 --- a/crates/picloud/tests/email_inbound.rs +++ b/crates/picloud/tests/email_inbound.rs @@ -229,19 +229,19 @@ async fn create_without_inbound_secret_is_rejected() { .post(&format!("/api/v1/admin/apps/{app_id}/triggers/email")) .json(&json!({ "script_id": handler, "inbound_secret": null })) .await; - resp.assert_status(axum::http::StatusCode::BAD_REQUEST); + resp.assert_status(axum::http::StatusCode::UNPROCESSABLE_ENTITY); let resp = server .post(&format!("/api/v1/admin/apps/{app_id}/triggers/email")) .json(&json!({ "script_id": handler, "inbound_secret": "" })) .await; - resp.assert_status(axum::http::StatusCode::BAD_REQUEST); + resp.assert_status(axum::http::StatusCode::UNPROCESSABLE_ENTITY); let resp = server .post(&format!("/api/v1/admin/apps/{app_id}/triggers/email")) .json(&json!({ "script_id": handler, "inbound_secret": " " })) .await; - resp.assert_status(axum::http::StatusCode::BAD_REQUEST); + resp.assert_status(axum::http::StatusCode::UNPROCESSABLE_ENTITY); } #[tokio::test]