test(audit-2026-06-11): fix status-code + rotted /version assertions

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) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-12 17:27:37 +02:00
parent 513c4a2d3c
commit 19f3647f0e
2 changed files with 11 additions and 5 deletions

View File

@@ -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");
}
// ============================================================================

View File

@@ -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]