test: pin serialized scheduled/forced refresh acceptance (CEL-1721) - #20
test: pin serialized scheduled/forced refresh acceptance (CEL-1721)#20mong-x wants to merge 1 commit into
Conversation
Adds a regression suite driving the real createAuthStore with an intercepted transport and deferred /auth/refresh responses: - timer + forced ensureAccessToken overlap sends exactly one request - forced and non-forced ensure callers share one in-flight result - pending state clears on completion AND on error; sequential legitimate refresh remains possible - a late refresh response cannot resurrect a session after logout - a late refresh response cannot overwrite a newer user's token Verified red against the audit-era commit 1ef93c6 (two overlapping refresh POSTs, session resurrection, stale-token overwrite) and green on main, where the CEL-1782/CEL-1853 session-resolution chain already routes scheduled, bootstrap, forced and 401-retry refresh through the shared refreshFlight operation.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe pull request adds integration tests for refresh serialization. The tests control deferred refresh responses and verify single-flight behavior, retry handling, logout safety, and protection against stale tokens. ChangesRefresh serialization tests
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to This PR adds coverage for refresh serialization and stale-token handling. The tests pass, but the direct fetch mock could affect later tests in a shared process, so mergeability is low risk with cleanup or isolation awareness. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit guards the refresh gate Comment |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Test-only addition pinning refresh serialization behavior; no production code changes, bounded and clearly beneficial.
Re-trigger cubic
CEL-1721 — serialize scheduled and forced customer-token refresh
Linear: CEL-1721 · Audit:
docs/audits/2026-09-06-platform-audit-identity.md(Item 6, sessions)Finding
The audit-era code (commit
1ef93c6, installed 0.14.0) had the defect exactly as reported: the refresh timer calledperformRefresh()directly whileensureAccessTokendeduplicated only its own callers, so a timer tick + forced ensure before the response sent twoPOST /auth/refreshrequests — and backend replay detection revokes the session on the second use of the shared refresh cookie.The fix already landed on main via the CEL-1782/CEL-1853 session-resolution chain (
d3cad5a..6de0850): the timer now routes throughstore.resolveSession({ refresh: true }), and scheduled, bootstrap, forced, and 401-retry callers all join the samerefreshFlightend-to-end operation (through refreshed-identity resolution), with generation guards so a late response can neither resurrect a logged-out session nor overwrite a newer user's token.This PR
Adds
__tests__/refresh-serialization.test.ts— six tests through the realcreateAuthStoreinterface with intercepted transport and deferred refresh responses, pinning every CEL-1721 acceptance criterion so the serialization cannot regress:ensureAccessTokenoverlap sends exactly ONE/auth/refreshunauthorized)TDD evidence
1ef93c6: tests 1, 5, 6 fail — two overlapping refresh POSTs,tok_lateresurrecting after logout,tok_staleoverwritingtok_newer_user.Checks
npm run typecheck✓ ·npm test✓ (15 files, 189 tests) ·npm run build✓ ·npx publint✓ (all four CI steps)Scope
Same-store defect only, per the ticket. Cross-origin dashboard/session isolation (separate store instances) is explicitly out of scope here. Publishing (currently 0.16.0) follows the repo release process via CI on merge; consumer pin cascades are tracked separately.
Summary by cubic
Adds a regression suite for CEL-1721 that pins the serialized refresh behavior now on main. The tests drive the real
createAuthStorewith an intercepted transport and deferred refresh responses, and fail on the audit-era code where overlapping refresh requests sent two POSTs, a late response resurrected a logged-out session, and a stale token overwrote a newer user's token.Written for commit 05195d5. Summary will update on new commits.