test(auth): add vitest harness + 16 auth-focused unit tests (Brief 5 of fix-auth-bypass) #11
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#11
Loading…
Reference in a new issue
No description provided.
Delete branch "brief/fix-auth-bypass/5-vitest-and-auth-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Convoy
fix-auth-bypass/ Brief 5 of 5 — the final brief. Adds a vitest test harness and 16 unit tests that lock in the security-critical behavior shipped by Briefs 1, 2, and 4.vitest@^3.2.4as a single devDep (no UI/coverage/jsdom add-ons — bundle stays minimal).getUserFromRequestnull-for-unauthenticated contract (incl. a regression lock against Brief 2's synthetic-admin shape), andauth-utils.generateToken24h JWT mint + verify round-trip.test:job re-enabled (previously commented out) — blocking (no|| truewrapper). First repo to ship with vitest as a real gate.Files changed
package.json—vitest@^3.2.4in devDeps;test+test:runscriptspackage-lock.json— regenerated (singlevitest@3.2.4, singlevite@7.3.3)vitest.config.js(new) — ESM,environment: 'node',globals: false,setupFiles: ['./test/setup.js']test/setup.js(new) — setsJWT_SECRET+NODE_ENV='test'before any module loadstest/lib/auth-secret.test.js(new) — 3 teststest/lib/permission-middleware.test.js(new) — 8 tests (mocks@vercel/postgres)test/api/auth-utils.test.js(new) — 5 tests (mockslib/database.js).github/workflows/ci.yml— re-enabledtest:job; header comment updatedTest plan
npm run test:run→ 3 files / 16 tests pass in 1.68s (zero retries used)npm run build→ exit 0 (Next.js prod build unaffected)npm run lint→ matches baseline (128 problems pre-existing; 0 new fromtest/orvitest.config.js)npm ls vitest→ singlevitest@3.2.4npm installclean — only one transitive deprecation warning (node-domexception@1.0.0), noERESOLVElib/**orpages/api/**)test:job runs and passes on this PR's preview build. Temporarily reintroduce the synthetic admin in a side-branch and confirm the Brief 2 regression test fails as designed.⚠️ Implementer deviation worth surfacing
The brief was strict on test contract (3 + 8 + 5 = 16 tests verbatim). The implementer also made a one-line consistency edit to the CI workflow header comment (added "- Unit tests (vitest)" to the "What this CI covers" bullet list), in addition to the brief's required removal of the "no test runner installed yet" note. They flagged it explicitly and offered to revert if reviewer prefers strict scope. My (parent) read: keep the consistency edit — the alternative is a stale comment that contradicts the now-real
test:job.Pre-merge requirements
test:job uses a fakeJWT_SECRETfor tests; production secret is unaffected)test:job — verify in the GH Actions tab before mergeOut of scope (intentionally — see convoy plan)
lib/rate-limit.jsfrom Brief 4) → futureexpand-auth-testsconvoy per architect's R11 callpages/api/auth/login.js/register.js→ same future convoywithCollectionPermission/checkCollectionPermissiontest coverage → same future convoy@vitest/eslint-plugin) → only useful if we enableglobals: truelaterConvoy completion
This is the last brief in
fix-auth-bypass. After this merges, the only remaining work is the doc-writer sweep:.convoys/fix-auth-bypass/brief-4-tighten-auth-surface.mdenv var names corrected (UPSTASH_REDIS_REST_*→KV_REST_API_*).cursor/rules/api-routes.mdc§ "Dev/test endpoints" removed (Brief 3 deleted them).convoys/ship-readiness.mdP0 items marked resolved🤖 Pipeline metadata: convoy=fix-auth-bypass, brief=5 (final), depends_on=[1, 2, 4 all merged], audit=reviewer-only
Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.