Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions test/common/proxy-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 = {}) {
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-http2-allow-http1-upgrade-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-inspector-network-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({
connect: {
rejectUnauthorized: false,
},
noProxy: '*',
}));

const session = new inspector.Session();
Expand Down
Loading