@@ -2,6 +2,7 @@ import * as http from 'http'
2
2
import * as httpm from '../_out'
3
3
import * as pm from '../_out/proxy'
4
4
import * as proxy from 'proxy'
5
+ import * as tunnelm from 'tunnel'
5
6
6
7
let _proxyConnects : string [ ]
7
8
let _proxyServer : http . Server
@@ -195,6 +196,26 @@ describe('proxy', () => {
195
196
expect ( obj . url ) . toBe ( 'https://httpbin.org/get' )
196
197
expect ( _proxyConnects ) . toHaveLength ( 0 )
197
198
} )
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
+ } )
198
219
} )
199
220
200
221
function _clearVars ( ) {
0 commit comments