From 409a249ca6cbe2a9e520a59cdcf1f5f16b723bf2 Mon Sep 17 00:00:00 2001 From: PM Bot Date: Thu, 16 Apr 2026 05:02:11 +0000 Subject: [PATCH] chore(test): remove dead constants from wsauth_middleware_test.go (#358) PR #357 deleted the grace-period tests that used hasLiveTokenQuery and workspaceExistsQuery, but the constants themselves (and the stale comment describing the old HasAnyLiveToken-based dispatch) were not removed. Remove both dead const declarations and update the header comment to reflect the strict-enforcement contract introduced by #357. Closes #358. Co-Authored-By: Claude Sonnet 4.6 --- .../internal/middleware/wsauth_middleware_test.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/platform/internal/middleware/wsauth_middleware_test.go b/platform/internal/middleware/wsauth_middleware_test.go index f0849de6..2f062f41 100644 --- a/platform/internal/middleware/wsauth_middleware_test.go +++ b/platform/internal/middleware/wsauth_middleware_test.go @@ -14,14 +14,11 @@ import ( // WorkspaceAuth middleware tests (covers findings C4, C8 and the full // per-workspace bearer-token contract). // -// WorkspaceAuth calls wsauth.HasAnyLiveToken to decide whether to enforce: -// - 0 live tokens → fail-open (bootstrap / rolling upgrade) -// - ≥1 live token → Authorization: Bearer required and validated +// Since PR #357 (#351 fix) the middleware enforces strictly: every request +// under /workspaces/:id/* must carry a valid bearer token — no fail-open, +// no grace period, no existence check. // ──────────────────────────────────────────────────────────────────────────── -// hasLiveTokenQuery is the SQL fragment matched by sqlmock for HasAnyLiveToken. -const hasLiveTokenQuery = "SELECT COUNT.*FROM workspace_auth_tokens.*workspace_id" - // hasAnyLiveTokenGlobalQuery is matched for HasAnyLiveTokenGlobal. const hasAnyLiveTokenGlobalQuery = "SELECT COUNT.*FROM workspace_auth_tokens" @@ -44,10 +41,6 @@ func newWorkspaceAuthRouter(db sqlmock.Sqlmock, realDB interface{ Close() error return r } -// workspaceExistsQuery is matched by sqlmock for wsauth.WorkspaceExists. -// Matches the SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1) query. -const workspaceExistsQuery = "SELECT EXISTS.*FROM workspaces WHERE id" - // TestWorkspaceAuth_351_NoBearer_Returns401 — strict contract: every request // under /workspaces/:id/* must carry a valid bearer, period. No fail-open, // no grace period, no existence check. The middleware goes straight to