diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index c4cd19fe610b81..192a6e51a9165c 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -151,17 +151,22 @@ function spawnPromisified(...args) { }); } +function spawnOptions(envExtension) { + const env = { ...process.env }; + // Cleanup the environment to avoid interference with client proxy tests. + for (const key of ['http_proxy', 'https_proxy', 'no_proxy']) { + delete env[key]; + delete env[key.toUpperCase()]; + } + return { env: { ...env, ...envExtension } }; +} + async function checkProxied(type, envExtension, expectation, cliArgsExtension = []) { const script = type === 'fetch' ? fixtures.path('fetch-and-log.mjs') : fixtures.path('request-and-log.js'); const { code, signal, stdout, stderr } = await spawnPromisified( process.execPath, - [...cliArgsExtension, script], { - env: { - NO_LOG_REQUEST: '1', - ...process.env, - ...envExtension, - }, - }); + [...cliArgsExtension, script], + spawnOptions({ ...envExtension, NO_LOG_REQUEST: '1' })); assert.deepStrictEqual({ stderr: stderr.trim(), @@ -188,24 +193,16 @@ exports.runProxiedRequest = async function(envExtension, cliArgsExtension = []) const fixtures = require('./fixtures'); return spawnPromisified( process.execPath, - [...cliArgsExtension, fixtures.path('request-and-log.js')], { - env: { - ...process.env, - ...envExtension, - }, - }); + [...cliArgsExtension, fixtures.path('request-and-log.js')], + spawnOptions(envExtension)); }; exports.runProxiedPOST = async function(envExtension) { const fixtures = require('./fixtures'); return spawnPromisified( process.execPath, - [fixtures.path('post-resource-and-log.js')], { - env: { - ...process.env, - ...envExtension, - }, - }); + [fixtures.path('post-resource-and-log.js')], + spawnOptions(envExtension)); }; exports.startTestServers = async function(options = {}) { diff --git a/test/parallel/test-http2-allow-http1-upgrade-ws.js b/test/parallel/test-http2-allow-http1-upgrade-ws.js index 028dc4e4cde71c..2988071650d12c 100644 --- a/test/parallel/test-http2-allow-http1-upgrade-ws.js +++ b/test/parallel/test-http2-allow-http1-upgrade-ws.js @@ -25,7 +25,8 @@ const WebSocketServer = require('../common/websocket-server'); await new Promise((resolve, reject) => { const ws = new WebSocket(`wss://localhost:${server.address().port}`, { dispatcher: new undici.EnvHttpProxyAgent({ - connect: { rejectUnauthorized: false } + connect: { rejectUnauthorized: false }, + noProxy: '*', }) }); ws.addEventListener('open', common.mustCall(() => { diff --git a/test/parallel/test-inspector-network-fetch.js b/test/parallel/test-inspector-network-fetch.js index 790446c84bfb66..d86049b9c0009e 100644 --- a/test/parallel/test-inspector-network-fetch.js +++ b/test/parallel/test-inspector-network-fetch.js @@ -18,6 +18,7 @@ undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false, }, + noProxy: '*', })); const session = new inspector.Session();