Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 9dc4079

Browse files
authored
proxyAuth is not set when authentication is not provided
1 parent edadda1 commit 9dc4079

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

__tests__/proxy.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as http from 'http'
22
import * as httpm from '../_out'
33
import * as pm from '../_out/proxy'
44
import * as proxy from 'proxy'
5+
import * as tunnelm from 'tunnel'
56

67
let _proxyConnects: string[]
78
let _proxyServer: http.Server
@@ -195,6 +196,26 @@ describe('proxy', () => {
195196
expect(obj.url).toBe('https://httpbin.org/get')
196197
expect(_proxyConnects).toHaveLength(0)
197198
})
199+
200+
it('proxyAuth not set in tunnel agent when authentication is not provided', async () => {
201+
process.env['https_proxy'] = 'http://127.0.0.1:8080'
202+
const httpClient = new httpm.HttpClient()
203+
let agent: tunnelm.TunnelingAgent = httpClient.getAgent('https://some-url')
204+
console.log(agent)
205+
expect(agent.proxyOptions.host).toBe('127.0.0.1')
206+
expect(agent.proxyOptions.port).toBe('8080')
207+
expect(agent.proxyOptions.proxyAuth).toBe(undefined)
208+
})
209+
210+
it('proxyAuth is set in tunnel agent when authentication is provided', async () => {
211+
process.env['https_proxy'] = 'http://user:password@127.0.0.1:8080'
212+
const httpClient = new httpm.HttpClient()
213+
let agent: tunnelm.TunnelingAgent = httpClient.getAgent('https://some-url')
214+
console.log(agent)
215+
expect(agent.proxyOptions.host).toBe('127.0.0.1')
216+
expect(agent.proxyOptions.port).toBe('8080')
217+
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
218+
})
198219
})
199220

200221
function _clearVars() {

0 commit comments

Comments
 (0)