Cover wrong-path unauthorized non-eviction behavior
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
90f6d84729
commit
3cab8e6602
2 files changed
+51
No files matched your search
@@ -2197,6 +2197,14 @@ async function main() {
|
||||
"wrong-token-key-while-connected",
|
||||
);
|
||||
|
||||
const wrongPathWhileConnectedWs = new WebSocket(
|
||||
`${parsedWsUrl.origin}/unexpected?token=${runtimeAuthTokenParam}`,
|
||||
);
|
||||
await waitForUnauthorizedCloseWithoutMessages(
|
||||
wrongPathWhileConnectedWs,
|
||||
"wrong-path-while-connected",
|
||||
);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(
|
||||
() => reject(new Error("Smoke test failed: post-unauthorized websocket health request timed out.")),
|
||||
|
||||
@@ -1483,6 +1483,49 @@ describe("runtimeApiServer", () => {
|
||||
expect([1000, 1005]).toContain(closed.code);
|
||||
});
|
||||
|
||||
it("does not evict authorized client when wrong-path client connects", async () => {
|
||||
const server = await startRuntimeApiServer({
|
||||
port: 0,
|
||||
launchCwd: process.cwd(),
|
||||
authToken: "secret-token",
|
||||
});
|
||||
servers.push(server);
|
||||
|
||||
const authorizedClient = await connectClient(server.wsUrl);
|
||||
await authorizedClient.nextMessage();
|
||||
|
||||
const authorizedClose = new Promise<{ code: number }>((resolve) => {
|
||||
authorizedClient.socket.once("close", (code) => resolve({ code }));
|
||||
});
|
||||
|
||||
const authorizedUrl = new URL(server.wsUrl);
|
||||
const wrongPathClient = new WebSocket(
|
||||
`${authorizedUrl.origin}/unexpected?token=secret-token`,
|
||||
);
|
||||
const wrongPathClose = await withTimeout(
|
||||
new Promise<{ code: number; reason: string }>((resolve, reject) => {
|
||||
wrongPathClient.once("close", (code, reason) =>
|
||||
resolve({ code, reason: reason.toString() }),
|
||||
);
|
||||
wrongPathClient.once("error", (error) => reject(error));
|
||||
}),
|
||||
);
|
||||
expect(wrongPathClose.code).toBe(WS_CLOSE_CODES.unauthorized);
|
||||
expect(wrongPathClose.reason).toBe(WS_CLOSE_REASONS.unauthorized);
|
||||
|
||||
const response = await sendRequest(
|
||||
authorizedClient.socket,
|
||||
authorizedClient.nextMessage,
|
||||
"todos-auth-wrong-path-1",
|
||||
"todos.list",
|
||||
);
|
||||
expect(response.ok).toBe(true);
|
||||
|
||||
authorizedClient.socket.close();
|
||||
const closed = await withTimeout(authorizedClose);
|
||||
expect([1000, 1005]).toContain(closed.code);
|
||||
});
|
||||
|
||||
it("returns a bootstrap payload even when codex cannot initialize", async () => {
|
||||
const originalPath = process.env.PATH;
|
||||
process.env.PATH = "";
|
||||
|
||||
Reference in new issue
Block a user