-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added formatted proxy URL * version increment
- Loading branch information
1 parent
7486d51
commit fb34438
Showing
6 changed files
with
104 additions
and
4 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as assert from 'assert'; | ||
import * as tl from '../_build/task'; | ||
|
||
enum ProxyEnvironmentEnum { | ||
proxyUrl = 'AGENT_PROXYURL', | ||
proxyUsername = 'AGENT_PROXYUSERNAME', | ||
proxyPassword = 'AGENT_PROXYPASSWORD', | ||
proxyBypass = 'AGENT_PROXYBYPASSLIST' | ||
} | ||
|
||
describe('GetHttpProxyConfiguration Tests', () => { | ||
const proxyHost: string = 'proxy.example.com'; | ||
const proxyPort: number = 8888; | ||
const proxyUrl: string = `http://${proxyHost}:${proxyPort}`; | ||
const proxyUsername: string = 'proxyUser'; | ||
const proxyPassword: string = 'proxyPassword'; | ||
const proxyByPass: string[] = ['http://bypass.example.com']; | ||
const formatedUrlWithoutCrednetials = proxyUrl; | ||
const fortmatedUrlWithCredentials = `http://${proxyUsername}:${proxyPassword}@${proxyHost}:${proxyPort}`; | ||
|
||
it('returns a valid proxy configuration if no credentials set', () => { | ||
process.env[ProxyEnvironmentEnum.proxyUrl] = proxyUrl; | ||
process.env[ProxyEnvironmentEnum.proxyBypass] = JSON.stringify(proxyByPass); | ||
const expected: tl.ProxyConfiguration = { | ||
proxyUrl: proxyUrl, | ||
proxyBypassHosts: proxyByPass, | ||
proxyUsername: undefined, | ||
proxyPassword: undefined, | ||
proxyFormattedUrl: formatedUrlWithoutCrednetials | ||
} | ||
const result = tl.getHttpProxyConfiguration(); | ||
assert.deepStrictEqual(result, expected, 'it should have valid configuration'); | ||
}); | ||
|
||
it('returns valid proxy configuration if credentials set', () => { | ||
process.env[ProxyEnvironmentEnum.proxyUrl] = proxyUrl; | ||
process.env[ProxyEnvironmentEnum.proxyUsername] = proxyUsername; | ||
process.env[ProxyEnvironmentEnum.proxyPassword] = proxyPassword; | ||
process.env[ProxyEnvironmentEnum.proxyBypass] = JSON.stringify(proxyByPass); | ||
const expected: tl.ProxyConfiguration = { | ||
proxyUrl: proxyUrl, | ||
proxyBypassHosts: proxyByPass, | ||
proxyFormattedUrl: fortmatedUrlWithCredentials, | ||
proxyPassword: proxyPassword, | ||
proxyUsername: proxyUsername | ||
} | ||
const result = tl.getHttpProxyConfiguration(); | ||
assert.deepStrictEqual(result, expected, 'it should have credentials in formatted url'); | ||
}); | ||
|
||
it('returns null if host should be bypassed', () => { | ||
process.env[ProxyEnvironmentEnum.proxyUrl] = proxyUrl; | ||
const result = tl.getHttpProxyConfiguration(proxyByPass[0]); | ||
assert.strictEqual(result, null, 'result should be null'); | ||
}); | ||
}) |
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