Skip to content

Commit 046ffde

Browse files
committed
test: enable allowed-hosts.test.js
1 parent 02ad09c commit 046ffde

3 files changed

Lines changed: 565 additions & 50 deletions

File tree

jest.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const config = {
1212
'<rootDir>/tests/e2e/*.test.js',
1313
],
1414
testPathIgnorePatterns: [
15-
// TODO: check why http proxy server throw error with websocket server
16-
'<rootDir>/tests/e2e/allowed-hosts.test.js',
1715
// TODO: check why this test timeout
1816
'<rootDir>/tests/e2e/host.test.js',
1917
// TODO: check why this test throw error when run with other tests

tests/e2e/__snapshots__/allowed-hosts.test.js.snap.webpack5

Lines changed: 144 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,78 @@ exports[`allowed hosts check host headers should always allow any host if option
3030

3131
exports[`allowed hosts check host headers should always allow any host if options.allowedHosts is all: response status 1`] = `200`;
3232

33+
exports[`allowed hosts check host headers should always allow value from the \`host\` options if options.allowedHosts is auto: console messages 1`] = `[]`;
34+
35+
exports[`allowed hosts check host headers should always allow value from the \`host\` options if options.allowedHosts is auto: page errors 1`] = `[]`;
36+
37+
exports[`allowed hosts check host headers should always allow value from the \`host\` options if options.allowedHosts is auto: response status 1`] = `200`;
38+
3339
exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: console messages 1`] = `[]`;
3440

3541
exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: page errors 1`] = `[]`;
3642

3743
exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: response status 1`] = `200`;
3844

45+
exports[`allowed hosts should connect web socket client using "[::1] host to web socket server with the "auto" value ("sockjs"): console messages 1`] = `
46+
[
47+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
48+
"[HMR] Waiting for update signal from WDS...",
49+
"Hey.",
50+
]
51+
`;
52+
53+
exports[`allowed hosts should connect web socket client using "[::1] host to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`;
54+
55+
exports[`allowed hosts should connect web socket client using "[::1] host to web socket server with the "auto" value ("ws"): console messages 1`] = `
56+
[
57+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
58+
"[HMR] Waiting for update signal from WDS...",
59+
"Hey.",
60+
]
61+
`;
62+
63+
exports[`allowed hosts should connect web socket client using "[::1] host to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`;
64+
65+
exports[`allowed hosts should connect web socket client using "0.0.0.0" host to web socket server with the "auto" value ("sockjs"): console messages 1`] = `
66+
[
67+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
68+
"[HMR] Waiting for update signal from WDS...",
69+
"Hey.",
70+
]
71+
`;
72+
73+
exports[`allowed hosts should connect web socket client using "0.0.0.0" host to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`;
74+
75+
exports[`allowed hosts should connect web socket client using "0.0.0.0" host to web socket server with the "auto" value ("ws"): console messages 1`] = `
76+
[
77+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
78+
"[HMR] Waiting for update signal from WDS...",
79+
"Hey.",
80+
]
81+
`;
82+
83+
exports[`allowed hosts should connect web socket client using "0.0.0.0" host to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`;
84+
85+
exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server by default ("sockjs"): console messages 1`] = `
86+
[
87+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
88+
"[HMR] Waiting for update signal from WDS...",
89+
"Hey.",
90+
]
91+
`;
92+
93+
exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server by default ("sockjs"): page errors 1`] = `[]`;
94+
95+
exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server by default ("ws"): console messages 1`] = `
96+
[
97+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
98+
"[HMR] Waiting for update signal from WDS...",
99+
"Hey.",
100+
]
101+
`;
102+
103+
exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server by default ("ws"): page errors 1`] = `[]`;
104+
39105
exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("sockjs"): console messages 1`] = `
40106
[
41107
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
@@ -96,6 +162,26 @@ exports[`allowed hosts should connect web socket client using "file:" protocol t
96162

97163
exports[`allowed hosts should connect web socket client using "file:" protocol to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`;
98164

165+
exports[`allowed hosts should connect web socket client using "localhost" host to web socket server by default ("sockjs"): console messages 1`] = `
166+
[
167+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
168+
"[HMR] Waiting for update signal from WDS...",
169+
"Hey.",
170+
]
171+
`;
172+
173+
exports[`allowed hosts should connect web socket client using "localhost" host to web socket server by default ("sockjs"): page errors 1`] = `[]`;
174+
175+
exports[`allowed hosts should connect web socket client using "localhost" host to web socket server by default ("ws"): console messages 1`] = `
176+
[
177+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
178+
"[HMR] Waiting for update signal from WDS...",
179+
"Hey.",
180+
]
181+
`;
182+
183+
exports[`allowed hosts should connect web socket client using "localhost" host to web socket server by default ("ws"): page errors 1`] = `[]`;
184+
99185
exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value ("sockjs"): console messages 1`] = `
100186
[
101187
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
@@ -236,18 +322,72 @@ exports[`allowed hosts should connect web socket client using localhost to web s
236322

237323
exports[`allowed hosts should connect web socket client using localhost to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`;
238324

239-
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): console messages 1`] = `[]`;
325+
exports[`allowed hosts should connect web socket client using origin header containing an IP address with the custom hostname value ("sockjs"): (work) console messages 1`] = `
326+
[
327+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
328+
"[HMR] Waiting for update signal from WDS...",
329+
"Hey.",
330+
]
331+
`;
332+
333+
exports[`allowed hosts should connect web socket client using origin header containing an IP address with the custom hostname value ("sockjs"): (work) page errors 1`] = `[]`;
334+
335+
exports[`allowed hosts should connect web socket client using origin header containing an IP address with the custom hostname value ("ws"): (work) console messages 1`] = `
336+
[
337+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
338+
"[HMR] Waiting for update signal from WDS...",
339+
"Hey.",
340+
]
341+
`;
240342

241-
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): html 1`] = `"<html><head></head><body>Invalid Host header</body></html>"`;
343+
exports[`allowed hosts should connect web socket client using origin header containing an IP address with the custom hostname value ("ws"): (work) page errors 1`] = `[]`;
344+
345+
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): console messages 1`] = `
346+
[
347+
"Failed to load resource: the server responded with a status of 403 (Forbidden)",
348+
]
349+
`;
350+
351+
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): html 1`] = `"<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Invalid Host header</pre></body></html>"`;
242352

243353
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`;
244354

245-
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): console messages 1`] = `[]`;
355+
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): console messages 1`] = `
356+
[
357+
"Failed to load resource: the server responded with a status of 403 (Forbidden)",
358+
]
359+
`;
246360

247-
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): html 1`] = `"<html><head></head><body>Invalid Host header</body></html>"`;
361+
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): html 1`] = `"<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Invalid Host header</pre></body></html>"`;
248362

249363
exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`;
250364

365+
exports[`allowed hosts should disconnect web client using origin header containing an IP address with the "auto" value ("sockjs"): (work) console messages 1`] = `
366+
[
367+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
368+
"[HMR] Waiting for update signal from WDS...",
369+
"Hey.",
370+
"[webpack-dev-server] Invalid Host/Origin header",
371+
"[webpack-dev-server] Disconnected!",
372+
"[webpack-dev-server] Trying to reconnect...",
373+
]
374+
`;
375+
376+
exports[`allowed hosts should disconnect web client using origin header containing an IP address with the "auto" value ("sockjs"): (work) page errors 1`] = `[]`;
377+
378+
exports[`allowed hosts should disconnect web client using origin header containing an IP address with the "auto" value ("ws"): (work) console messages 1`] = `
379+
[
380+
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
381+
"[HMR] Waiting for update signal from WDS...",
382+
"Hey.",
383+
"[webpack-dev-server] Invalid Host/Origin header",
384+
"[webpack-dev-server] Disconnected!",
385+
"[webpack-dev-server] Trying to reconnect...",
386+
]
387+
`;
388+
389+
exports[`allowed hosts should disconnect web client using origin header containing an IP address with the "auto" value ("ws"): (work) page errors 1`] = `[]`;
390+
251391
exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("sockjs"): console messages 1`] = `
252392
[
253393
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",

0 commit comments

Comments
 (0)