mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Install: log proxy use, if any, to aid with debugging
This commit is contained in:
@@ -10,34 +10,40 @@ describe('HTTP agent', function () {
|
||||
|
||||
it('HTTPS proxy with auth from HTTPS_PROXY', function () {
|
||||
process.env.HTTPS_PROXY = 'https://user:pass@secure:123';
|
||||
const proxy = agent();
|
||||
let logMsg = '';
|
||||
const proxy = agent(msg => { logMsg = msg; });
|
||||
delete process.env.HTTPS_PROXY;
|
||||
assert.strictEqual('object', typeof proxy);
|
||||
assert.strictEqual('secure', proxy.options.proxy.host);
|
||||
assert.strictEqual(123, proxy.options.proxy.port);
|
||||
assert.strictEqual('user:pass', proxy.options.proxy.proxyAuth);
|
||||
assert.strictEqual(443, proxy.defaultPort);
|
||||
assert.strictEqual(logMsg, 'Via proxy https:://secure:123 with credentials');
|
||||
});
|
||||
|
||||
it('HTTPS proxy with auth from HTTPS_PROXY using credentials containing special characters', function () {
|
||||
process.env.HTTPS_PROXY = 'https://user,:pass=@secure:123';
|
||||
const proxy = agent();
|
||||
process.env.HTTPS_PROXY = 'https://user,:pass=@secure:789';
|
||||
let logMsg = '';
|
||||
const proxy = agent(msg => { logMsg = msg; });
|
||||
delete process.env.HTTPS_PROXY;
|
||||
assert.strictEqual('object', typeof proxy);
|
||||
assert.strictEqual('secure', proxy.options.proxy.host);
|
||||
assert.strictEqual(123, proxy.options.proxy.port);
|
||||
assert.strictEqual(789, proxy.options.proxy.port);
|
||||
assert.strictEqual('user,:pass=', proxy.options.proxy.proxyAuth);
|
||||
assert.strictEqual(443, proxy.defaultPort);
|
||||
assert.strictEqual(logMsg, 'Via proxy https:://secure:789 with credentials');
|
||||
});
|
||||
|
||||
it('HTTP proxy without auth from npm_config_proxy', function () {
|
||||
process.env.npm_config_proxy = 'http://plaintext:456';
|
||||
const proxy = agent();
|
||||
let logMsg = '';
|
||||
const proxy = agent(msg => { logMsg = msg; });
|
||||
delete process.env.npm_config_proxy;
|
||||
assert.strictEqual('object', typeof proxy);
|
||||
assert.strictEqual('plaintext', proxy.options.proxy.host);
|
||||
assert.strictEqual(456, proxy.options.proxy.port);
|
||||
assert.strictEqual(null, proxy.options.proxy.proxyAuth);
|
||||
assert.strictEqual(443, proxy.defaultPort);
|
||||
assert.strictEqual(logMsg, 'Via proxy http:://plaintext:456 no credentials');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user