Skip to content

Commit 3d1730e

Browse files
test: update
1 parent 9fde868 commit 3d1730e

File tree

3 files changed

+1
-110
lines changed

3 files changed

+1
-110
lines changed

lib/Server.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,10 +3138,7 @@ class Server {
31383138
true,
31393139
).hostname;
31403140

3141-
// allow requests with explicit IPv4 or IPv6-address if allowIP is true.
3142-
// Note that IP should not be automatically allowed for Origin headers,
3143-
// otherwise an untrusted remote IP host can send requests.
3144-
//
3141+
// always allow requests with explicit IPv4 or IPv6-address.
31453142
// A note on IPv6 addresses:
31463143
// hostHeader will always contain the brackets denoting
31473144
// an IPv6-address in URLs,

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -282,32 +282,6 @@ exports[`allowed hosts should disconnect web client using localhost to web socke
282282

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

285-
exports[`allowed hosts should disconnect web client with origin header containing an IP address with the "auto" value ("sockjs"): console messages 1`] = `
286-
[
287-
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
288-
"[HMR] Waiting for update signal from WDS...",
289-
"Hey.",
290-
"[webpack-dev-server] Invalid Host/Origin header",
291-
"[webpack-dev-server] Disconnected!",
292-
"[webpack-dev-server] Trying to reconnect...",
293-
]
294-
`;
295-
296-
exports[`allowed hosts should disconnect web client with origin header containing an IP address with the "auto" value ("sockjs"): page errors 1`] = `[]`;
297-
298-
exports[`allowed hosts should disconnect web client with origin header containing an IP address with the "auto" value ("ws"): console messages 1`] = `
299-
[
300-
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
301-
"[HMR] Waiting for update signal from WDS...",
302-
"Hey.",
303-
"[webpack-dev-server] Invalid Host/Origin header",
304-
"[webpack-dev-server] Disconnected!",
305-
"[webpack-dev-server] Trying to reconnect...",
306-
]
307-
`;
308-
309-
exports[`allowed hosts should disconnect web client with origin header containing an IP address with the "auto" value ("ws"): page errors 1`] = `[]`;
310-
311285
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`] = `
312286
[
313287
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",

test/e2e/allowed-hosts.test.js

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,86 +1206,6 @@ describe("allowed hosts", () => {
12061206
await server.stop();
12071207
}
12081208
});
1209-
1210-
it(`should disconnect web client with origin header containing an IP address with the "auto" value ("${webSocketServer}")`, async () => {
1211-
const devServerHost = "127.0.0.1";
1212-
const devServerPort = port1;
1213-
const proxyHost = devServerHost;
1214-
const proxyPort = port2;
1215-
1216-
const compiler = webpack(config);
1217-
const devServerOptions = {
1218-
client: {
1219-
webSocketURL: {
1220-
port: port2,
1221-
},
1222-
},
1223-
webSocketServer,
1224-
port: devServerPort,
1225-
host: devServerHost,
1226-
allowedHosts: "auto",
1227-
};
1228-
const server = new Server(devServerOptions, compiler);
1229-
1230-
await server.start();
1231-
1232-
function startProxy(callback) {
1233-
const app = express();
1234-
1235-
app.use(
1236-
"/",
1237-
createProxyMiddleware({
1238-
// Emulation
1239-
onProxyReqWs: (proxyReq) => {
1240-
proxyReq.setHeader("origin", "http://192.168.1.1/");
1241-
},
1242-
target: `http://${devServerHost}:${devServerPort}`,
1243-
ws: true,
1244-
changeOrigin: true,
1245-
logLevel: "warn",
1246-
}),
1247-
);
1248-
1249-
return app.listen(proxyPort, proxyHost, callback);
1250-
}
1251-
1252-
const proxy = await new Promise((resolve) => {
1253-
const proxyCreated = startProxy(() => {
1254-
resolve(proxyCreated);
1255-
});
1256-
});
1257-
1258-
const { page, browser } = await runBrowser();
1259-
1260-
try {
1261-
const pageErrors = [];
1262-
const consoleMessages = [];
1263-
1264-
page
1265-
.on("console", (message) => {
1266-
consoleMessages.push(message);
1267-
})
1268-
.on("pageerror", (error) => {
1269-
pageErrors.push(error);
1270-
});
1271-
1272-
await page.goto(`http://${proxyHost}:${proxyPort}/`, {
1273-
waitUntil: "networkidle0",
1274-
});
1275-
1276-
expect(
1277-
consoleMessages.map((message) => message.text()),
1278-
).toMatchSnapshot("console messages");
1279-
expect(pageErrors).toMatchSnapshot("page errors");
1280-
} catch (error) {
1281-
throw error;
1282-
} finally {
1283-
proxy.close();
1284-
1285-
await browser.close();
1286-
await server.stop();
1287-
}
1288-
});
12891209
}
12901210

12911211
describe("check host headers", () => {

0 commit comments

Comments
 (0)