This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from pravipati/fix-missing-proxy-auth
Fix missing proxy auth
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import * as http from 'http' | |
import * as httpm from '../_out' | ||
import * as pm from '../_out/proxy' | ||
import * as proxy from 'proxy' | ||
import * as tunnelm from 'tunnel' | ||
|
||
let _proxyConnects: string[] | ||
let _proxyServer: http.Server | ||
|
@@ -195,6 +196,26 @@ describe('proxy', () => { | |
expect(obj.url).toBe('https://httpbin.org/get') | ||
expect(_proxyConnects).toHaveLength(0) | ||
}) | ||
|
||
it('proxyAuth not set in tunnel agent when authentication is not provided', async () => { | ||
process.env['https_proxy'] = 'http://127.0.0.1:8080' | ||
const httpClient = new httpm.HttpClient() | ||
let agent: tunnelm.TunnelingAgent = httpClient.getAgent('https://some-url') | ||
console.log(agent) | ||
expect(agent.proxyOptions.host).toBe('127.0.0.1') | ||
expect(agent.proxyOptions.port).toBe('8080') | ||
expect(agent.proxyOptions.proxyAuth).toBe(undefined) | ||
}) | ||
|
||
it('proxyAuth is set in tunnel agent when authentication is provided', async () => { | ||
process.env['https_proxy'] = 'http://user:[email protected]:8080' | ||
const httpClient = new httpm.HttpClient() | ||
let agent: tunnelm.TunnelingAgent = httpClient.getAgent('https://some-url') | ||
console.log(agent) | ||
expect(agent.proxyOptions.host).toBe('127.0.0.1') | ||
expect(agent.proxyOptions.port).toBe('8080') | ||
expect(agent.proxyOptions.proxyAuth).toBe('user:password') | ||
}) | ||
}) | ||
|
||
function _clearVars() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters