Repository navigation
test(plugin-auth): the forced-reset OAuth test takes its token time from the routine reset, not the wall clock - #36706
Merged
Conversation
… routine reset's change time The forced-reset OAuth test took its token's iat one whole second ahead of the wall clock before the routine reset ran. When that admin call took longer than about a second (full-suite load), the change time the reset wrote landed after iat * 1000 and the grant read as issued before it. Read the change time back after the routine reset and take the first whole second at or after it, so the assertion no longer depends on how long the reset took. The product rule is unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWUnHRCP5qaRA2VJEj
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
…th test Move the wall clock two seconds on before the routine reset, as an administrator's call under load does, so the case the old one-second stamp failed on runs every time. On the old stamp it fails at the routine-reset assertion; with the change time read back it passes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWUnHRCP5qaRA2VJEj
Contributor
Author
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读一个登录相关的测试偶尔失败,原因是测试自己用了「当前时间」去估算令牌签发时间,服务器慢一点就会错。产品逻辑没有问题。这次只改测试:按密码重置实际写下的时间来取值,并加了一个故意放慢 2 秒的情况把它钉住。 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
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.
Requested by Warren · project thread
Fixes #36361
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
One test,
an administrator's forced reset ends them too and reports the apps; with revocation off it ends nonein
packages/plugins/plugin-auth/src/password-reset-ends-added-access.test.ts. Test-only: no product file moves.The test used to take its token's
iatasMath.floor(Date.now() / 1000) + 1before the routine admin reset ran.Now it runs the routine reset first, reads the credential-change time that reset wrote
(
readCredentialChangedAt, the same reader the MCP door uses), and takesiatas the first whole second at orafter it (
Math.ceil(changedAtMs / 1000)). The forced-reset half is unchanged.The slow call is pinned: just before the routine reset the test moves the wall clock two seconds on
(
vi.useFakeTimers({ toFake: ['Date'] })+vi.setSystemTime, the same pattern the file's credential-changedescribe already uses), standing in for an admin call that takes longer than a second under load. Every run now
takes the path the queue build failed on. The describe's
afterEachrestores real timers.Why — root cause is the test's clock, not the product
mcpConsentAdmitsplaces a token with no millisecond claim on a consent row atiat * 1000and refuses it when thatis earlier than the account's credential-change time (
issuedBeforeCredentialChange). The routine reset(
revokeSessionsAndKeys: false) writes a new change time. The old test fixediatat most one second ahead of theclock it read before the reset, so it assumed the admin HTTP call finished inside that second. Under full-suite
load the call took longer, the change time landed after
iat * 1000, and the door correctly refused a token that,by its own
iat, predates the reset:expected false to be trueat line 538 (merge-queue run 44999732595, TestCore 10/10). The product rule is right; the test's premise about timing was wrong.
The two other
+ 1sites in the file (the self-service reset case at line 468, the disabled-app case at line 983)have no credential change between taking
iatand the assertion that needs it to stand, so they cannot hit this.Tests
All on head
b4de067d.main's version of the test with only the two clock lines added fails at thecard's assertion:
AssertionError: expected false to be trueat thegrantStands()right after the routine reset(the same line as merge-queue run 44999732595, shifted by the two inserted lines). The fixed test passes in the
same run. The
maincopy was temporary and is not in the diff.main,green with the fix.
pnpm --filter @objectstack/plugin-auth typecheck(includingcheck:test-typecheck): passed.pnpm --filter @objectstack/plugin-auth test: 293 files, 6265 passed, 10 skipped.eslint --no-inline-configon the changed file: clean.No skip, no narrowing, no retry wrapper, no timeout change.
Acceptance notes
None.
Verification
Two-minute check:
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/password-reset-ends-added-access.test.ts -t "forced reset ends them too"— 1 passed. Swap the twoissuedAtlines back toMath.floor(Date.now() / 1000) + 1taken before the routine reset and it fails withexpected false to be true.Files to read first: in
password-reset-ends-added-access.test.ts, the forced-reset case (the clock move and theiatread back), then the describe'safterEach(vi.useRealTimers()).Changeset: none; the diff changes a test file only and publishes nothing (
skip-changeset).🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbWUnHRCP5qaRA2VJEj