Assert unauthorized websocket close reason semantics
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
dda8abba23
commit
503e6d8a75
1 file changed
+5
-2
@@ -969,12 +969,15 @@ describe("runtimeApiServer", () => {
|
||||
unauthorizedMessageCount += 1;
|
||||
});
|
||||
const unauthorizedClose = await withTimeout(
|
||||
new Promise<{ code: number }>((resolve, reject) => {
|
||||
unauthorizedClient.once("close", (code) => resolve({ code }));
|
||||
new Promise<{ code: number; reason: string }>((resolve, reject) => {
|
||||
unauthorizedClient.once("close", (code, reason) =>
|
||||
resolve({ code, reason: reason.toString() }),
|
||||
);
|
||||
unauthorizedClient.once("error", (error) => reject(error));
|
||||
}),
|
||||
);
|
||||
expect(unauthorizedClose.code).toBe(4001);
|
||||
expect(unauthorizedClose.reason).toBe("unauthorized");
|
||||
expect(unauthorizedMessageCount).toBe(0);
|
||||
|
||||
const wrongTokenUrl = `${authorizedUrl.origin}${authorizedUrl.pathname}?token=wrong-token`;
|
||||
|
||||
Reference in new issue
Block a user