Skip to content

Commit

Permalink
Fix test of FixedProfile to allow proxy and auth objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisCatus committed Sep 20, 2017
1 parent 323bc90 commit 48239e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion omega-pac/src/profiles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ module.exports = exports =
if profile.bypassList
for cond in profile.bypassList
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]
return [
@pacResult(profile[s.prop]),
Expand Down
24 changes: 18 additions & 6 deletions omega-pac/test/profiles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,34 @@ describe 'Profiles', ->
conditionType: 'BypassCondition'
pattern: '<local>'
}]
proxyForHttp:
scheme: 'socks4'
host: '127.0.0.1'
port: 1234
proxyForHttps:
scheme: 'http'
host: '127.0.0.1'
port: 1234
port: 2345
fallbackProxy:
scheme: 'socks4'
host: '127.0.0.1'
port: 1234
port: 3456
auth:
proxyForHttps:
username: 'test'
password: 'cheesecake'
it 'should use protocol-specific proxies if suitable', ->
testProfile(profile, 'https://www.example.com/',
['PROXY 127.0.0.1:1234', 'https'])
testProfile(profile, 'https://www.example.com/', ['PROXY 127.0.0.1:2345',
'https', profile.proxyForHttps, profile.auth.proxyForHttps])
it 'should use fallback proxies for other protocols', ->
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', ->
testProfile profile, 'ftp://localhost/', ['DIRECT', profile.bypassList[0]]
testProfile profile, 'ftp://localhost/',
['DIRECT', profile.bypassList[0], {scheme: 'direct'}, undefined]
describe 'PacProfile', ->
profile = Profiles.create('test', 'PacProfile')
profile.pacScript = '''
Expand Down

0 comments on commit 48239e5

Please sign in to comment.