Cover no-auth unexpected-query unauthorized non-eviction

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 05:46:24 +00:00
1 parent 90da976395
commit 684388fbbf
1 file changed
+36
+36
View File
@@ -1108,6 +1108,42 @@ describe("runtimeApiServer", () => {
authorizedClient.socket.close();
});
it("does not evict active client when unexpected-query client connects without auth", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const activeClient = await connectClient(server.wsUrl);
await activeClient.nextMessage();
const activeClose = new Promise<{ code: number }>((resolve) => {
activeClient.socket.once("close", (code) => resolve({ code }));
});
const unauthorizedUnexpectedQueryClient = new WebSocket(`${server.wsUrl}?debug=1`);
const unauthorizedUnexpectedQueryClose = await withTimeout(
new Promise<{ code: number }>((resolve, reject) => {
unauthorizedUnexpectedQueryClient.once("close", (code) => resolve({ code }));
unauthorizedUnexpectedQueryClient.once("error", (error) => reject(error));
}),
);
expect(unauthorizedUnexpectedQueryClose.code).toBe(4001);
const response = await sendRequest(
activeClient.socket,
activeClient.nextMessage,
"todos-authless-unexpected-query-1",
"todos.list",
);
expect(response.ok).toBe(true);
activeClient.socket.close();
const closed = await withTimeout(activeClose);
expect([1000, 1005]).toContain(closed.code);
});
it("does not evict authorized client when unauthorized client connects", async () => {
const server = await startRuntimeApiServer({
port: 0,