From b1c96a56e6b99fbf34d785874f44e8e60ae61d82 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 07:49:58 +0000 Subject: [PATCH] Cover auth-mode missing-token extra-query websocket rejection Co-authored-by: Theo Browne --- apps/t3/scripts/smoke-test.mjs | 8 ++++++++ apps/t3/src/runtimeApiServer.test.ts | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index be6e77e4d7..f0e89f0bdf 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -1547,6 +1547,14 @@ async function main() { const unauthorizedWs = new WebSocket(unauthorizedWsUrl); await waitForUnauthorizedCloseWithoutMessages(unauthorizedWs, "missing-token"); + const missingTokenWithExtraQueryWs = new WebSocket( + `${parsedWsUrl.origin}${parsedWsUrl.pathname}?debug=1`, + ); + await waitForUnauthorizedCloseWithoutMessages( + missingTokenWithExtraQueryWs, + "missing-token-with-extra-query", + ); + const wrongTokenWs = new WebSocket( `${parsedWsUrl.origin}${parsedWsUrl.pathname}?token=wrong-token`, ); diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 7441f69f1d..9bb96014f3 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -986,6 +986,24 @@ describe("runtimeApiServer", () => { expect(unauthorizedClose.reason).toBe(WS_CLOSE_REASONS.unauthorized); expect(unauthorizedMessageCount).toBe(0); + const missingTokenWithExtraQueryUrl = `${authorizedUrl.origin}${authorizedUrl.pathname}?debug=1`; + const missingTokenWithExtraQueryClient = new WebSocket(missingTokenWithExtraQueryUrl); + let missingTokenWithExtraQueryMessageCount = 0; + missingTokenWithExtraQueryClient.on("message", () => { + missingTokenWithExtraQueryMessageCount += 1; + }); + const missingTokenWithExtraQueryClose = await withTimeout( + new Promise<{ code: number; reason: string }>((resolve, reject) => { + missingTokenWithExtraQueryClient.once("close", (code, reason) => + resolve({ code, reason: reason.toString() }), + ); + missingTokenWithExtraQueryClient.once("error", (error) => reject(error)); + }), + ); + expect(missingTokenWithExtraQueryClose.code).toBe(WS_CLOSE_CODES.unauthorized); + expect(missingTokenWithExtraQueryClose.reason).toBe(WS_CLOSE_REASONS.unauthorized); + expect(missingTokenWithExtraQueryMessageCount).toBe(0); + const wrongTokenUrl = `${authorizedUrl.origin}${authorizedUrl.pathname}?token=wrong-token`; const wrongTokenClient = new WebSocket(wrongTokenUrl); let wrongTokenMessageCount = 0;