| 8 | const logger = { info: () => {} }; |
| 9 | |
| 10 | function testVariableSet(httpProxy, httpsProxy, allProxy, noProxy) { |
| 11 | return () => { |
| 12 | it(`should use ${httpProxy} environment variable`, () => { |
| 13 | let agent = createWSAgent('https://pushserver', { |
| 14 | [httpProxy]: 'http://proxy:3128', |
| 15 | }, logger); |
| 16 | assert.equal(agent, null); |
| 17 | |
| 18 | agent = createWSAgent('http://pushserver', { |
| 19 | [httpProxy]: proxy, |
| 20 | }, logger); |
| 21 | assert.equal(agent.proxy.href, proxy); |
| 22 | }); |
| 23 | |
| 24 | it(`should use ${httpsProxy} environment variable`, () => { |
| 25 | let agent = createWSAgent('http://pushserver', { |
| 26 | [httpsProxy]: proxy, |
| 27 | }, logger); |
| 28 | assert.equal(agent, null); |
| 29 | |
| 30 | agent = createWSAgent('https://pushserver', { |
| 31 | [httpsProxy]: proxy, |
| 32 | }, logger); |
| 33 | assert.equal(agent.proxy.href, proxy); |
| 34 | }); |
| 35 | |
| 36 | it(`should use ${allProxy} environment variable`, () => { |
| 37 | let agent = createWSAgent('http://pushserver', { |
| 38 | [allProxy]: proxy, |
| 39 | }, logger); |
| 40 | assert.equal(agent.proxy.href, proxy); |
| 41 | |
| 42 | agent = createWSAgent('https://pushserver', { |
| 43 | [allProxy]: proxy, |
| 44 | }, logger); |
| 45 | assert.equal(agent.proxy.href, proxy); |
| 46 | }); |
| 47 | |
| 48 | it(`should use ${noProxy} environment variable`, () => { |
| 49 | let agent = createWSAgent('http://pushserver', { |
| 50 | [noProxy]: 'pushserver', |
| 51 | }, logger); |
| 52 | assert.equal(agent, null); |
| 53 | |
| 54 | agent = createWSAgent('http://pushserver', { |
| 55 | [noProxy]: 'pushserver', |
| 56 | [httpProxy]: proxy, |
| 57 | }, logger); |
| 58 | assert.equal(agent, null); |
| 59 | |
| 60 | agent = createWSAgent('http://pushserver', { |
| 61 | [noProxy]: 'pushserver2', |
| 62 | [httpProxy]: proxy, |
| 63 | }, logger); |
| 64 | assert.equal(agent.proxy.href, proxy); |
| 65 | }); |
| 66 | }; |
| 67 | } |