update tests to handle ipv6
This commit is contained in:
parent
7908e9f83b
commit
9cea844607
|
|
@ -114,7 +114,7 @@ export async function setupSocksForwardingServer({
|
||||||
const socksProxy = new SocksProxy();
|
const socksProxy = new SocksProxy();
|
||||||
socksProxy.setPattern('*');
|
socksProxy.setPattern('*');
|
||||||
socksProxy.addListener(SocksProxy.Events.SocksRequested, async (payload: SocksSocketRequestedPayload) => {
|
socksProxy.addListener(SocksProxy.Events.SocksRequested, async (payload: SocksSocketRequestedPayload) => {
|
||||||
if (!['127.0.0.1', 'fake-localhost-127-0-0-1.nip.io', 'localhost'].includes(payload.host) || payload.port !== allowedTargetPort) {
|
if (!['127.0.0.1', '0:0:0:0:0:0:0:1', 'fake-localhost-127-0-0-1.nip.io', 'localhost'].includes(payload.host) || payload.port !== allowedTargetPort) {
|
||||||
socksProxy.sendSocketError({ uid: payload.uid, error: 'ECONNREFUSED' });
|
socksProxy.sendSocketError({ uid: payload.uid, error: 'ECONNREFUSED' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
|
||||||
|
|
||||||
const socksServer = new MockSocksServer();
|
const socksServer = new MockSocksServer();
|
||||||
const socksPort = port + 2;
|
const socksPort = port + 2;
|
||||||
await socksServer.listen(socksPort, 'localhost');
|
await socksServer.listen(socksPort, loopback);
|
||||||
|
|
||||||
const proxyPort = port + 3;
|
const proxyPort = port + 3;
|
||||||
const proxyServer = await TestProxy.create(proxyPort);
|
const proxyServer = await TestProxy.create(proxyPort);
|
||||||
|
|
|
||||||
|
|
@ -390,7 +390,7 @@ test.describe('browser', () => {
|
||||||
});
|
});
|
||||||
expect(connectHosts).toEqual([]);
|
expect(connectHosts).toEqual([]);
|
||||||
await page.goto(serverURL);
|
await page.goto(serverURL);
|
||||||
const host = browserName === 'webkit' && isMac ? 'localhost' : '127.0.0.1';
|
const host = browserName === 'webkit' && isMac ? '0:0:0:0:0:0:0:1' : '127.0.0.1';
|
||||||
expect(connectHosts).toEqual([`${host}:${serverPort}`]);
|
expect(connectHosts).toEqual([`${host}:${serverPort}`]);
|
||||||
await expect(page.getByTestId('message')).toHaveText('Hello Alice, your certificate was issued by localhost!');
|
await expect(page.getByTestId('message')).toHaveText('Hello Alice, your certificate was issued by localhost!');
|
||||||
await page.close();
|
await page.close();
|
||||||
|
|
|
||||||
|
|
@ -862,7 +862,7 @@ it('should include timings when using http proxy', async ({ contextFactory, serv
|
||||||
proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
|
proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
|
||||||
const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `localhost:${proxyServer.PORT}` } });
|
const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `localhost:${proxyServer.PORT}` } });
|
||||||
const response = await page.request.get(server.EMPTY_PAGE);
|
const response = await page.request.get(server.EMPTY_PAGE);
|
||||||
await response.body();
|
expect(proxyServer.connectHosts).toEqual([`localhost:${server.PORT}`]);
|
||||||
await expect(response).toBeOK();
|
await expect(response).toBeOK();
|
||||||
const log = await getLog();
|
const log = await getLog();
|
||||||
expect(log.entries[0].timings.connect).toBeGreaterThan(0);
|
expect(log.entries[0].timings.connect).toBeGreaterThan(0);
|
||||||
|
|
@ -871,7 +871,7 @@ it('should include timings when using http proxy', async ({ contextFactory, serv
|
||||||
it('should include timings when using socks proxy', async ({ contextFactory, server, socksPort }, testInfo) => {
|
it('should include timings when using socks proxy', async ({ contextFactory, server, socksPort }, testInfo) => {
|
||||||
const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `socks5://localhost:${socksPort}` } });
|
const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `socks5://localhost:${socksPort}` } });
|
||||||
const response = await page.request.get(server.EMPTY_PAGE);
|
const response = await page.request.get(server.EMPTY_PAGE);
|
||||||
await response.body();
|
expect(await response.text()).toContain('Served by the SOCKS proxy');
|
||||||
await expect(response).toBeOK();
|
await expect(response).toBeOK();
|
||||||
const log = await getLog();
|
const log = await getLog();
|
||||||
expect(log.entries[0].timings.connect).toBeGreaterThan(0);
|
expect(log.entries[0].timings.connect).toBeGreaterThan(0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue