From abefa04ff9ac0de7b6a7c15121eef4f408a26738 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 4 Nov 2026 12:47:15 +0800 Subject: [PATCH] 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). --- packages/orcaterm/refresh-token.test.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/orcaterm/refresh-token.test.mjs b/packages/orcaterm/refresh-token.test.mjs index f8ba872..b10e296 100644 --- a/packages/orcaterm/refresh-token.test.mjs +++ b/packages/orcaterm/refresh-token.test.mjs @@ -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}`