Fix test of FixedProfile to allow proxy and auth objects.

This commit is contained in:
FelisCatus 2017-09-20 16:13:36 -07:00
parent 323bc9014c
commit 48239e5e50
2 changed files with 22 additions and 10 deletions

View File

@ -257,7 +257,7 @@ module.exports = exports =
if profile.bypassList if profile.bypassList
for cond in profile.bypassList for cond in profile.bypassList
if Conditions.match(cond, request) if Conditions.match(cond, request)
return [@pacResult(), cond, {scheme: 'direct'}, null] return [@pacResult(), cond, {scheme: 'direct'}, undefined]
for s in @schemes when s.scheme == request.scheme and profile[s.prop] for s in @schemes when s.scheme == request.scheme and profile[s.prop]
return [ return [
@pacResult(profile[s.prop]), @pacResult(profile[s.prop]),

View File

@ -97,22 +97,34 @@ describe 'Profiles', ->
conditionType: 'BypassCondition' conditionType: 'BypassCondition'
pattern: '<local>' pattern: '<local>'
}] }]
proxyForHttps: proxyForHttp:
scheme: 'http'
host: '127.0.0.1'
port: 1234
fallbackProxy:
scheme: 'socks4' scheme: 'socks4'
host: '127.0.0.1' host: '127.0.0.1'
port: 1234 port: 1234
proxyForHttps:
scheme: 'http'
host: '127.0.0.1'
port: 2345
fallbackProxy:
scheme: 'socks4'
host: '127.0.0.1'
port: 3456
auth:
proxyForHttps:
username: 'test'
password: 'cheesecake'
it 'should use protocol-specific proxies if suitable', -> it 'should use protocol-specific proxies if suitable', ->
testProfile(profile, 'https://www.example.com/', testProfile(profile, 'https://www.example.com/', ['PROXY 127.0.0.1:2345',
['PROXY 127.0.0.1:1234', 'https']) 'https', profile.proxyForHttps, profile.auth.proxyForHttps])
it 'should use fallback proxies for other protocols', -> it 'should use fallback proxies for other protocols', ->
testProfile(profile, 'ftp://www.example.com/', testProfile(profile, 'ftp://www.example.com/',
['SOCKS 127.0.0.1:1234', '']) ['SOCKS 127.0.0.1:3456', '', profile.fallbackProxy, undefined])
it 'should not return authentication if not provided for protocol', ->
testProfile(profile, 'http://www.example.com/',
['SOCKS 127.0.0.1:1234', 'http', profile.proxyForHttp, undefined])
it 'should not use any proxy for requests matching the bypassList', -> it 'should not use any proxy for requests matching the bypassList', ->
testProfile profile, 'ftp://localhost/', ['DIRECT', profile.bypassList[0]] testProfile profile, 'ftp://localhost/',
['DIRECT', profile.bypassList[0], {scheme: 'direct'}, undefined]
describe 'PacProfile', -> describe 'PacProfile', ->
profile = Profiles.create('test', 'PacProfile') profile = Profiles.create('test', 'PacProfile')
profile.pacScript = ''' profile.pacScript = '''