MCPcopy
hub / github.com/coder/mux / expectWebSocketOriginCase

Function expectWebSocketOriginCase

src/node/orpc/server.test.ts:273–297  ·  view source on GitHub ↗
(input: {
  headers?: OriginHeaders;
  accepted: boolean;
  allowHttpOrigin?: boolean;
})

Source from the content-addressed store, hash-verified

271}
272
273async function expectWebSocketOriginCase(input: {
274 headers?: OriginHeaders;
275 accepted: boolean;
276 allowHttpOrigin?: boolean;
277}): Promise<void> {
278 await withTestOrpcServer(
279 async (server) => {
280 const ws = new WebSocket(server.wsUrl, {
281 headers: resolveOriginHeaders(input.headers, server),
282 });
283
284 try {
285 if (input.accepted) {
286 await waitForWebSocketOpen(ws);
287 await closeWebSocket(ws);
288 } else {
289 await waitForWebSocketRejection(ws);
290 }
291 } finally {
292 ws.terminate();
293 }
294 },
295 input.allowHttpOrigin ? { allowHttpOrigin: true } : {}
296 );
297}
298
299describe("createOrpcServer", () => {
300 test("serveStatic fallback does not swallow /api routes", async () => {

Callers 1

server.test.tsFile · 0.85

Calls 6

withTestOrpcServerFunction · 0.85
resolveOriginHeadersFunction · 0.85
waitForWebSocketOpenFunction · 0.70
closeWebSocketFunction · 0.70
terminateMethod · 0.65

Tested by

no test coverage detected