orcaterm: refresh-token test holds one expiry for its tokens (#675)

refresh-token.test.mjs (db307844) built each fixture token with an exp
read from the clock on every call, so two tokens for the same jti
differed when the calls fell either side of a second boundary. The QR
sign-in test compared them and went red on CI run 41774409142 (it
skipped that publish run's dist job, so reasonix-desktop 0.1.0 from #700
waits for the next one). The file now reads the clock once.

Run (mote): refresh-token.test.mjs 8 times, 6 pass / 0 fail each.
Broken by hand: a 1.1s sleep inside the QR test: green with the fixed
expiry, 1 fail with the old per-call one.
Not tried: the whole orcaterm package again (only this test file
changed).
This commit is contained in:
yetone
2026-11-04 12:47:15 +08:00
parent f6fdf8fee1
commit abefa04ff9
+5 -1
View File
@@ -15,7 +15,11 @@ afterEach(() => { globalThis.fetch = realFetch })
const json = data => Response.json({ code: 0, data })
const JTI = "0d4c2f7e-9b1a-4c3d-8e5f-6a7b8c9d0e1f"
const tail = "A".repeat(43)
const access = (jti, exp = Math.floor(Date.now() / 1000) + 7200) =>
// One expiry for the whole file: a default read from the clock on each call
// made two tokens for the same jti differ across a second boundary (CI
// run 41774409142).
const LATER = Math.floor(Date.now() / 1000) + 7200
const access = (jti, exp = LATER) =>
`eyJhbGciOiJub25lIn0.${Buffer.from(JSON.stringify({ userId: "u1", jti, exp })).toString("base64url")}.test`
const refreshOf = (jti, n = 1) => `${jti}.${n}.${tail}`