Merge pull request #360 from Molecule-AI/chore/issue-358-wsauth-dead-constants

All CI green. Removes dead constants and stale comment left over from PR #357 grace-period test deletion (closes #358).
This commit is contained in:
Hongming Wang 2026-04-15 22:05:37 -07:00 committed by GitHub
commit 2e1fc8d832

View File

@ -14,14 +14,11 @@ import (
// WorkspaceAuth middleware tests (covers findings C4, C8 and the full // WorkspaceAuth middleware tests (covers findings C4, C8 and the full
// per-workspace bearer-token contract). // per-workspace bearer-token contract).
// //
// WorkspaceAuth calls wsauth.HasAnyLiveToken to decide whether to enforce: // Since PR #357 (#351 fix) the middleware enforces strictly: every request
// - 0 live tokens → fail-open (bootstrap / rolling upgrade) // under /workspaces/:id/* must carry a valid bearer token — no fail-open,
// - ≥1 live token → Authorization: Bearer <token> required and validated // 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. // hasAnyLiveTokenGlobalQuery is matched for HasAnyLiveTokenGlobal.
const hasAnyLiveTokenGlobalQuery = "SELECT COUNT.*FROM workspace_auth_tokens" const hasAnyLiveTokenGlobalQuery = "SELECT COUNT.*FROM workspace_auth_tokens"
@ -44,10 +41,6 @@ func newWorkspaceAuthRouter(db sqlmock.Sqlmock, realDB interface{ Close() error
return r 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 // TestWorkspaceAuth_351_NoBearer_Returns401 — strict contract: every request
// under /workspaces/:id/* must carry a valid bearer, period. No fail-open, // under /workspaces/:id/* must carry a valid bearer, period. No fail-open,
// no grace period, no existence check. The middleware goes straight to // no grace period, no existence check. The middleware goes straight to