From 7c070b6425d4dede45317a8a35e62e640d657bdf Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 05:17:09 +0000 Subject: [PATCH] Assert duplicate-token auth attempts do not evict active client Co-authored-by: Theo Browne --- apps/t3/scripts/smoke-test.mjs | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index 2233111677..6238ebe0ac 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -1468,6 +1468,51 @@ async function main() { reject(new Error("Smoke test failed: websocket client error.")); }); }); + + const duplicateTokenWhileConnectedWs = new WebSocket( + `${parsedWsUrl.origin}${parsedWsUrl.pathname}?token=${encodeURIComponent( + parsedWsUrl.searchParams.get("token") ?? "", + )}&token=wrong-token`, + ); + await waitForUnauthorizedCloseWithoutMessages(duplicateTokenWhileConnectedWs); + + await new Promise((resolve, reject) => { + const timer = setTimeout( + () => reject(new Error("Smoke test failed: post-unauthorized websocket health request timed out.")), + 20_000, + ); + const onMessage = (event) => { + let message; + try { + message = JSON.parse(String(event.data)); + } catch { + return; + } + + if (message.type !== "response" || message.id !== "smoke-after-unauth") { + return; + } + if (message.ok !== true || message.result?.status !== "ok") { + clearTimeout(timer); + ws.removeEventListener("message", onMessage); + reject(new Error("Smoke test failed: expected successful post-unauthorized health response.")); + return; + } + + clearTimeout(timer); + ws.removeEventListener("message", onMessage); + resolve(); + }; + + ws.addEventListener("message", onMessage); + ws.send( + JSON.stringify({ + type: "request", + id: "smoke-after-unauth", + method: "app.health", + }), + ); + }); ws.close(); } catch (error) { process.stderr.write(`${error instanceof Error ? error.message : "Smoke test failed."}\n`);