test(auth): align device authorize tests with guarded claims - #671
Merged
Conversation
Validation * Validation tier: Tier 2 - test-only CI correction for security-sensitive device authorize route coverage; no runtime files changed. * TDD red: bun --cwd packages/frontend test __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.ts: FAIL before fix, 3 failed and 2 passed, matching the Frontend CI device authorize failures. * bun --cwd packages/frontend test __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.ts: PASS, 5 tests. * bun --cwd packages/frontend test: PASS, 48 test files and 391 tests. * bun run lint -- __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.ts (cwd packages/frontend): PASS. * git diff --check: PASS. * git diff --cached --check: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - no release manifests changed. * Not run: Frontend Migration Replay - not required locally because no migration files changed and the failing GitHub job was Frontend Vitest. Rollback * git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the device authorization route tests so they match the current guarded-claim implementation after #654.
Why
The latest
Frontend CIruns onmainstarted failing inFrontend Vitestafterfix(auth): claim device codes atomically (#654). The route now authenticates throughgetSessionFromRequest, which rejects cookie-authenticated mutating requests without an allowedOrigin, and claims device codes throughdb.update(...).set(...).where(...).returning(...). The affected tests were still exercising the old request shape and one CSRF test mock did not expose.returning(), so CI failed even though the runtime route path was intentionally changed.Diff scope
packages/frontend/__tests__/api/deviceAuthorize.test.tsnow sends an allowedOriginfor successful cookie-authenticated mutation tests and removes the stale pre-select fixture from the atomic claim race test.packages/frontend/__tests__/api/deviceAuthorizeCsrf.test.tsnow models the Drizzle update builder with.where(...).returning(...).Branch integrity
main.b48af31e8c119dbc82d8b2e0da2e72a5f9e4d63f.origin/main:1 ahead / 0 behind.b48af31e8c119dbc82d8b2e0da2e72a5f9e4d63f.Commit integrity
f20af788a48154d272c23dca6a33045a65d54503 test(auth): align device authorize mocks with guarded claimsLedger/version proof
Diff hygiene
git diff --name-status origin/main...HEAD: onlypackages/frontend/__tests__/api/deviceAuthorize.test.tsandpackages/frontend/__tests__/api/deviceAuthorizeCsrf.test.ts.git diff --check origin/main...HEAD: PASS, no output..envfiles, secrets, credentials, build output, caches, or unrelated generated files are included.Validation mode and proof
bun --cwd packages/frontend test __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.ts: FAIL before fix, 3 failed and 2 passed, matching theFrontend CIdevice authorize failures.bun --cwd packages/frontend test __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.ts: PASS, 5 tests.bun --cwd packages/frontend test: PASS, 48 test files and 391 tests.bun run lint -- __tests__/api/deviceAuthorize.test.ts __tests__/api/deviceAuthorizeCsrf.test.tsfrompackages/frontend: PASS.git diff --check: PASS.git diff --cached --check: PASS.Frontend Migration Replaylocally — not required because no migration files changed and the failing GitHub job wasFrontend Vitest.CI context confirmation
Runtime safety
Documentation integrity
Rollback plan
Rollback: revert this PR.
DB downgrade: not applicable.
Data repair: not applicable.
Operational caveats: none known.
Known residual risks
Summary by cubic
Aligns device authorization tests with the guarded-claim flow from #654 to fix failing Frontend Vitest runs on
main. Adds an allowedOriginheader and updates Drizzle mocks to use.returning(...); no runtime code changed.packages/frontend/__tests__/api/deviceAuthorize.test.ts: add allowedOriginfor cookie-auth POSTs; remove stale pre-select fixture; add a small request helper.packages/frontend/__tests__/api/deviceAuthorizeCsrf.test.ts: model update builder with.where(...).returning(...)to match Drizzle.Written for commit f20af78. Summary will update on new commits.