Skip to content

test(plugin-auth): the forced-reset OAuth test takes its token time from the routine reset, not the wall clock - #36706

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-31yz1e
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-31yz1e

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #36361

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感,只改一条登录插件的测试;产品行为不变。
  • 为什么做:这条测试在合并队列满载时会偶发变红,把无关的 PR 踢出队列,堵住主干。
  • 出错会怎样:只影响测试本身,产品代码一行未动,可直接撤回。
  • 要你做什么:无。

What changes

One test, an administrator's forced reset ends them too and reports the apps; with revocation off it ends none
in 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 iat as Math.floor(Date.now() / 1000) + 1 before 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 takes iat as the first whole second at or
after 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-change
describe 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 afterEach restores real timers.

Why — root cause is the test's clock, not the product

mcpConsentAdmits places a token with no millisecond claim on a consent row at iat * 1000 and refuses it when that
is earlier than the account's credential-change time (issuedBeforeCredentialChange). The routine reset
(revokeSessionsAndKeys: false) writes a new change time. The old test fixed iat at most one second ahead of the
clock 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 true at line 538 (merge-queue run 44999732595, Test
Core 10/10). The product rule is right; the test's premise about timing was wrong.

The two other + 1 sites in the file (the self-service reset case at line 468, the disabled-app case at line 983)
have no credential change between taking iat and the assertion that needs it to stand, so they cannot hit this.

Tests

All on head b4de067d.

  • The pin fails without the fix. main's version of the test with only the two clock lines added fails at the
    card's assertion: AssertionError: expected false to be true at the grantStands() 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 main copy was temporary and is not in the diff.
  • Before the pin existed, the same was shown with a real 1.5 s pause in place of the clock move: red on main,
    green with the fix.
  • The fixed test, 20 consecutive runs: 20/20 passed.
  • pnpm --filter @objectstack/plugin-auth typecheck (including check:test-typecheck): passed.
  • pnpm --filter @objectstack/plugin-auth test: 293 files, 6265 passed, 10 skipped.
  • eslint --no-inline-config on 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 two issuedAt lines back to Math.floor(Date.now() / 1000) + 1 taken before the routine reset and it fails with expected false to be true.

Files to read first: in password-reset-ends-added-access.test.ts, the forced-reset case (the clock move and the iat read back), then the describe's afterEach (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

… 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
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing 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): node scripts/docs-audit/affected-docs.mjs --json b617675d2887f7b88e98a397011f70cf2004ae0c → packageMentionDocs.

…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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

一个登录相关的测试偶尔失败,原因是测试自己用了「当前时间」去估算令牌签发时间,服务器慢一点就会错。产品逻辑没有问题。这次只改测试:按密码重置实际写下的时间来取值,并加了一个故意放慢 2 秒的情况把它钉住。
要你做的:无。

席位核对 — ACCEPT (L1) · repo:objectstack#1 · head b4de067d · 2026-11-23T13:21Z

  • Shape: Fixes #36361, one test file, packages/plugins/plugin-auth/src/password-reset-ends-added-access.test.ts (+16/−3). No product code. Clause-②: no. Metadata-protocol: none. skip-changeset.
  • Read: the token time is now read back from the credential-change time the routine reset wrote (readCredentialChangedAt), rounded up to the whole second. The door compares strictly (issuedAtMs < changedAtMs refuses), so a token at exactly the change second is admitted, as the test asserts. The second commit fakes only Date, 2 s ahead, around the routine reset, so the slow-reset case is pinned on every run, and it asserts the reset does stamp a change time. The forced-reset half is unchanged. No skip, retry or loosened assertion.
  • Evidence (thread): the main copy with a 1.5 s pause reds at the card's assertion; the fixed copy is green with the same pause and 20/20 consecutive runs; plugin-auth 6265 passed.
  • Gates: 57 check-runs on b4de067d: 37 success, 20 skipped, 0 failed. K = 4 behind main (< 15).
  • Landing: ready + auto-merge now. On merge, test(plugin-auth): the forced-reset OAuth test stamps its grant one whole second ahead and turns red when the call takes longer #36361 closes and the seat clears its label.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 13:21
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 9e0c0c2 Nov 23, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-31yz1e branch November 23, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(plugin-auth): the forced-reset OAuth test stamps its grant one whole second ahead and turns red when the call takes longer

1 participant