Browse Source

Fix test of FixedProfile to allow proxy and auth objects.

FelisCatus 8 years ago
parent
commit
48239e5e50
2 changed files with 19 additions and 7 deletions
  1. 1 1
      omega-pac/src/profiles.coffee
  2. 18 6
      omega-pac/test/profiles.coffee

+ 1 - 1
omega-pac/src/profiles.coffee

@@ -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]),

+ 18 - 6
omega-pac/test/profiles.coffee

@@ -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 = '''