From 5a4d18bf1f2989f6b93b671716a18da226a7c203 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 30 Mar 2024 01:38:38 -0700 Subject: [PATCH] . --- packages/https-proxy-agent/test/e2e.test.ts | 9 +++++---- packages/socks-proxy-agent/test/e2e.test.ts | 11 +++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/https-proxy-agent/test/e2e.test.ts b/packages/https-proxy-agent/test/e2e.test.ts index ca347ad..7e1215e 100644 --- a/packages/https-proxy-agent/test/e2e.test.ts +++ b/packages/https-proxy-agent/test/e2e.test.ts @@ -61,7 +61,7 @@ describe('HttpsProxyAgent', () => { } ); console.log( - `Using NordVPN HTTPS proxy server: ${server.name} (${server.hostname})` + `Using NordVPN "proxy_ssl" server: ${server.name} (${server.hostname})` ); }); @@ -74,8 +74,6 @@ describe('HttpsProxyAgent', () => { throw new Error('`NORDVPN_PASSWORD` env var is not defined'); } - const realIp = await getRealIP(); - const username = encodeURIComponent(NORDVPN_USERNAME); const password = encodeURIComponent(NORDVPN_PASSWORD); @@ -85,7 +83,10 @@ describe('HttpsProxyAgent', () => { `https://${username}:${password}@${server.hostname}:89` ); - const res = await req('https://dump.n8.io', { agent }); + const [res, realIp] = await Promise.all([ + req('https://dump.n8.io', { agent }), + getRealIP(), + ]); const body = await json(res); expect(body.request.headers['x-real-ip']).not.toEqual(realIp); expect(body.request.headers['x-vercel-ip-country']).toEqual( diff --git a/packages/socks-proxy-agent/test/e2e.test.ts b/packages/socks-proxy-agent/test/e2e.test.ts index 9b44a5e..4fa3f85 100644 --- a/packages/socks-proxy-agent/test/e2e.test.ts +++ b/packages/socks-proxy-agent/test/e2e.test.ts @@ -43,7 +43,6 @@ describe('SocksProxyAgent', () => { s.status === 'online' && s.technologies.find((t) => t.identifier === 'socks') ); - console.log(servers.length); if (servers.length === 0) { throw new Error( 'Could not find `https` proxy server from NordVPN' @@ -61,7 +60,7 @@ describe('SocksProxyAgent', () => { } ); console.log( - `Using NordVPN HTTPS proxy server: ${server.name} (${server.hostname})` + `Using NordVPN "socks" server: ${server.name} (${server.hostname})` ); }); @@ -74,16 +73,16 @@ describe('SocksProxyAgent', () => { throw new Error('`NORDVPN_PASSWORD` env var is not defined'); } - const realIp = await getRealIP(); - const username = encodeURIComponent(NORDVPN_USERNAME); const password = encodeURIComponent(NORDVPN_PASSWORD); - const agent = new SocksProxyAgent( `socks://${username}:${password}@${server.hostname}` ); - const res = await req('https://dump.n8.io', { agent }); + const [res, realIp] = await Promise.all([ + req('https://dump.n8.io', { agent }), + getRealIP(), + ]); const body = await json(res); expect(body.request.headers['x-real-ip']).not.toEqual(realIp); expect(body.request.headers['x-vercel-ip-country']).toEqual(