proxy_pac_rb 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +91 -0
- data/Gemfile +1 -1
- data/README.md +6 -6
- data/Rakefile +11 -1
- data/features/resolve_proxy.feature +34 -10
- data/lib/proxy_pac_rb/cli/init_proxy_pac.rb +4 -4
- data/lib/proxy_pac_rb/javascript.rb +2 -0
- data/lib/proxy_pac_rb/proxy_pac_compressor.rb +1 -1
- data/lib/proxy_pac_rb/proxy_pac_dumper.rb +2 -2
- data/lib/proxy_pac_rb/proxy_pac_js.rb +5 -5
- data/lib/proxy_pac_rb/runtimes.rb +1 -1
- data/lib/proxy_pac_rb/version.rb +1 -1
- data/proxy_pac_rb.gemspec +2 -2
- data/script/config.ru +0 -1
- data/spec/api/proxy_pac_compressor_spec.rb +1 -1
- data/spec/api/proxy_pac_dumper_spec.rb +2 -2
- data/spec/api/proxy_pac_file_spec.rb +1 -1
- data/spec/api/proxy_pac_linter_spec.rb +3 -3
- data/spec/api/proxy_pac_loader_spec.rb +3 -3
- data/spec/api/proxy_pac_parser_spec.rb +3 -3
- data/spec/parser_spec.rb +35 -7
- data/spec/rack/proxy_pac_compressor_spec.rb +2 -2
- data/spec/rack/proxy_pac_linter_spec.rb +3 -3
- data/spec/rspec/compare_proxy_pac_files_spec.rb +5 -5
- data/spec/rspec/parse_proxy_pac_spec.rb +3 -3
- data/spec/rspec/readability_spec.rb +3 -3
- data/spec/rspec/validitiy_spec.rb +4 -4
- metadata +14 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 037d43fa0910685b4a38a431bc1bd25a3fa3c299
|
4
|
+
data.tar.gz: 47cf7ce08c6770974784e50eef702424e13f70ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46b7925d4034bbeefcdda66e868042fb15ef9e5c9c2f2c1fc988eb2464d0e273c82368cb93959bd01736931da08303ea9adc041d13081fba6c261f8fb709c2c
|
7
|
+
data.tar.gz: 8cf646fc6d0c88abb7db9433edb3c173ed8e1e7e6741c0920c51d904965ded102ecd9d54802c45df27e76f4c89517417fae40687fbe865a31c5d1104f5e27ea9
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-06-04 19:50:00 +0000 using RuboCop version 0.49.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 82
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/EmptyLineAfterMagicComment:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
# Offense count: 87
|
15
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
16
|
+
# SupportedStyles: native, lf, crlf
|
17
|
+
Layout/EndOfLine:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
# Offense count: 27
|
21
|
+
# Cop supports --auto-correct.
|
22
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
23
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
24
|
+
Layout/IndentHeredoc:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/proxy_pac_rb/cli/init_proxy_pac.rb'
|
27
|
+
- 'lib/proxy_pac_rb/proxy_pac_js.rb'
|
28
|
+
- 'proxy_pac_rb.gemspec'
|
29
|
+
- 'spec/parser_spec.rb'
|
30
|
+
- 'spec/rack/proxy_pac_compressor_spec.rb'
|
31
|
+
- 'spec/rack/proxy_pac_linter_spec.rb'
|
32
|
+
- 'spec/rspec/compare_proxy_pac_files_spec.rb'
|
33
|
+
- 'spec/rspec/parse_proxy_pac_spec.rb'
|
34
|
+
- 'spec/rspec/readability_spec.rb'
|
35
|
+
- 'spec/rspec/validitiy_spec.rb'
|
36
|
+
|
37
|
+
# Offense count: 17
|
38
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
39
|
+
Metrics/BlockLength:
|
40
|
+
Max: 178
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
45
|
+
# SupportedStyles: compact, expanded
|
46
|
+
Style/EmptyMethod:
|
47
|
+
Exclude:
|
48
|
+
- 'lib/proxy_pac_rb/runtime.rb'
|
49
|
+
|
50
|
+
# Offense count: 1
|
51
|
+
# Cop supports --auto-correct.
|
52
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
53
|
+
# SupportedStyles: when_needed, always, never
|
54
|
+
Style/FrozenStringLiteralComment:
|
55
|
+
Exclude:
|
56
|
+
- 'Vagrantfile'
|
57
|
+
|
58
|
+
# Offense count: 1
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
# Configuration parameters: InverseMethods, InverseBlocks.
|
61
|
+
Style/InverseMethods:
|
62
|
+
Exclude:
|
63
|
+
- 'lib/proxy_pac_rb/rspec.rb'
|
64
|
+
|
65
|
+
# Offense count: 7
|
66
|
+
# Cop supports --auto-correct.
|
67
|
+
# Configuration parameters: PreferredDelimiters.
|
68
|
+
Style/PercentLiteralDelimiters:
|
69
|
+
Exclude:
|
70
|
+
- 'Rakefile'
|
71
|
+
- 'lib/proxy_pac_rb/cli/shared.rb'
|
72
|
+
- 'lib/proxy_pac_rb/main.rb'
|
73
|
+
- 'lib/proxy_pac_rb/rspec.rb'
|
74
|
+
- 'spec/environment_spec.rb'
|
75
|
+
- 'templates/test_framework/rspec/support/aruba.rb'
|
76
|
+
|
77
|
+
# Offense count: 2
|
78
|
+
# Cop supports --auto-correct.
|
79
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
80
|
+
# SupportedStyles: percent, brackets
|
81
|
+
Style/SymbolArray:
|
82
|
+
EnforcedStyle: brackets
|
83
|
+
|
84
|
+
# Offense count: 4
|
85
|
+
# Cop supports --auto-correct.
|
86
|
+
Style/YodaCondition:
|
87
|
+
Exclude:
|
88
|
+
- 'lib/proxy_pac_rb/proxy_pac_file.rb'
|
89
|
+
- 'lib/proxy_pac_rb/rack/proxy_pac_compressor.rb'
|
90
|
+
- 'lib/proxy_pac_rb/rack/proxy_pac_linter.rb'
|
91
|
+
- 'lib/proxy_pac_rb/rspec/helpers.rb'
|
data/Gemfile
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
group :development, :test do
|
16
16
|
gem 'middleman', '~> 4.1', require: false
|
17
|
-
gem 'aruba', '~>0.
|
17
|
+
gem 'aruba', '~>0.14.2', require: false
|
18
18
|
gem 'awesome_print', require: 'ap'
|
19
19
|
gem 'bundler', '~> 1.3', require: false
|
20
20
|
gem 'command_exec', require: false
|
data/README.md
CHANGED
@@ -271,7 +271,7 @@ file.find('https://github.com') # => "DIRECT"
|
|
271
271
|
```ruby
|
272
272
|
require 'proxy_pac_rb'
|
273
273
|
|
274
|
-
string =
|
274
|
+
string = <<~EOS
|
275
275
|
function FindProxyForURL(url, host) {
|
276
276
|
if (dateRange("JUL", "SEP")) {
|
277
277
|
return "PROXY localhost:8080";
|
@@ -379,7 +379,7 @@ RSpec.describe 'proxy.pac', type: :proxy_pac do
|
|
379
379
|
```ruby
|
380
380
|
RSpec.describe 'String', type: :proxy_pac do
|
381
381
|
subject do
|
382
|
-
|
382
|
+
<<~EOS.chomp
|
383
383
|
function FindProxyForURL(url, host) {
|
384
384
|
return "DIRECT";
|
385
385
|
}
|
@@ -439,7 +439,7 @@ require 'proxy_pac_rb/rspec'
|
|
439
439
|
|
440
440
|
RSpec.describe 'proxy.pac', type: :proxy_pac do
|
441
441
|
subject do
|
442
|
-
|
442
|
+
<<~EOS.chomp
|
443
443
|
function FindProxyForURL(url, host) {
|
444
444
|
return "DIRECT";
|
445
445
|
}
|
@@ -490,7 +490,7 @@ require 'proxy_pac_rb/rspec'
|
|
490
490
|
|
491
491
|
RSpec.describe 'proxy.pac', type: :proxy_pac do
|
492
492
|
subject do
|
493
|
-
|
493
|
+
<<~EOS.chomp
|
494
494
|
function FindProxyForURL(url, host) {
|
495
495
|
return "DIRECT";
|
496
496
|
}
|
@@ -503,7 +503,7 @@ RSpec.describe 'proxy.pac', type: :proxy_pac do
|
|
503
503
|
|
504
504
|
context 'when proxy.pac is not valid' do
|
505
505
|
subject do
|
506
|
-
|
506
|
+
<<~EOS.chomp
|
507
507
|
function FindProxyForURL(url, host) {
|
508
508
|
return adsf;
|
509
509
|
}
|
@@ -524,7 +524,7 @@ the proxy.pac and returns the proxy to be used for a given url.
|
|
524
524
|
require 'proxy_pac_rb/rspec'
|
525
525
|
RSpec.describe 'proxy.pac', type: :proxy_pac do
|
526
526
|
subject do
|
527
|
-
|
527
|
+
<<~EOS.chomp
|
528
528
|
function FindProxyForURL(url, host) {
|
529
529
|
if (dnsDomainIs(host, 'www1.example.com'')) {
|
530
530
|
return "PROXY proxy1.example.com:8080";
|
data/Rakefile
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
# require 'bundler'
|
5
4
|
# Bundler.require :default, :test, :development
|
6
5
|
|
6
|
+
# temp fix for NoMethodError: undefined method `last_comment'
|
7
|
+
# remove when fixed in Rake 11.x
|
8
|
+
# see http://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11
|
9
|
+
module TempFixForRakeLastComment
|
10
|
+
def last_comment
|
11
|
+
last_description
|
12
|
+
end
|
13
|
+
end
|
14
|
+
Rake::Application.send :include, TempFixForRakeLastComment
|
15
|
+
### end of tempfix
|
16
|
+
|
7
17
|
require 'filegen'
|
8
18
|
require 'fedux_org_stdlib/rake_tasks'
|
9
19
|
|
@@ -11,7 +11,7 @@ Feature: Resolve proxy
|
|
11
11
|
return 'PROXY localhost:3128';
|
12
12
|
}
|
13
13
|
"""
|
14
|
-
When I successfully run `pprb find proxy -p proxy.pac -u www.example.org`
|
14
|
+
When I successfully run `pprb find proxy -p proxy.pac -u http://www.example.org`
|
15
15
|
Then the output should contain:
|
16
16
|
"""
|
17
17
|
PROXY localhost:3128
|
@@ -22,7 +22,7 @@ Feature: Resolve proxy
|
|
22
22
|
"""
|
23
23
|
function FindProxyForURL(){return"PROXY localhost:3128"}
|
24
24
|
"""
|
25
|
-
When I successfully run `pprb find proxy -p proxy.pac -u www.example.org`
|
25
|
+
When I successfully run `pprb find proxy -p proxy.pac -u http://www.example.org`
|
26
26
|
Then the output should contain:
|
27
27
|
"""
|
28
28
|
PROXY localhost:3128
|
@@ -35,7 +35,7 @@ Feature: Resolve proxy
|
|
35
35
|
return 'PROXY localhost:3128';
|
36
36
|
}
|
37
37
|
"""
|
38
|
-
When I successfully run `pprb find proxy -p ./proxy.pac -u www.example.org`
|
38
|
+
When I successfully run `pprb find proxy -p ./proxy.pac -u http://www.example.org`
|
39
39
|
Then the output should contain:
|
40
40
|
"""
|
41
41
|
PROXY localhost:3128
|
@@ -48,14 +48,14 @@ Feature: Resolve proxy
|
|
48
48
|
return 'PROXY localhost:3128';
|
49
49
|
}
|
50
50
|
"""
|
51
|
-
When I successfully run `pprb find proxy -p http://127.0.0.1:65535/proxy.pac -u www.example.org`
|
51
|
+
When I successfully run `pprb find proxy -p http://127.0.0.1:65535/proxy.pac -u http://www.example.org`
|
52
52
|
Then the output should contain:
|
53
53
|
"""
|
54
54
|
PROXY localhost:3128
|
55
55
|
"""
|
56
56
|
|
57
57
|
Scenario: Non-Existing proxy.pac
|
58
|
-
When I run `pprb find proxy -p proxy.pac -u www.example.org`
|
58
|
+
When I run `pprb find proxy -p proxy.pac -u http://www.example.org`
|
59
59
|
Then the output should contain:
|
60
60
|
"""
|
61
61
|
You need to provide a path to an existing proxy pac file. The file "proxy.pac" does not exist.
|
@@ -81,7 +81,7 @@ Feature: Resolve proxy
|
|
81
81
|
return 'PROXY localhost:3128';
|
82
82
|
}
|
83
83
|
"""
|
84
|
-
When I run `pprb find proxy -u www.example.org`
|
84
|
+
When I run `pprb find proxy -u http://www.example.org`
|
85
85
|
Then the output should contain:
|
86
86
|
"""
|
87
87
|
No value provided for required options '--proxy-pac'
|
@@ -98,12 +98,12 @@ Feature: Resolve proxy
|
|
98
98
|
}
|
99
99
|
}
|
100
100
|
"""
|
101
|
-
When I successfully run `pprb find proxy -p proxy.pac -c 10.0.0.1 -u www.example.org`
|
101
|
+
When I successfully run `pprb find proxy -p proxy.pac -c 10.0.0.1 -u http://www.example.org`
|
102
102
|
Then the output should contain:
|
103
103
|
"""
|
104
104
|
PROXY localhost:3128
|
105
105
|
"""
|
106
|
-
When I successfully run `pprb find proxy -p proxy.pac -c 192.0.0.1 -u www.example.org`
|
106
|
+
When I successfully run `pprb find proxy -p proxy.pac -c 192.0.0.1 -u http://www.example.org`
|
107
107
|
Then the output should contain:
|
108
108
|
"""
|
109
109
|
DIRECT
|
@@ -120,12 +120,12 @@ Feature: Resolve proxy
|
|
120
120
|
}
|
121
121
|
}
|
122
122
|
"""
|
123
|
-
When I successfully run `pprb find proxy -p proxy.pac -t 2014-04-09 -u www.example.org`
|
123
|
+
When I successfully run `pprb find proxy -p proxy.pac -t 2014-04-09 -u http://www.example.org`
|
124
124
|
Then the output should contain:
|
125
125
|
"""
|
126
126
|
PROXY localhost:3128
|
127
127
|
"""
|
128
|
-
When I successfully run `pprb find proxy -p proxy.pac -t 2014-12-07 -u www.example.org`
|
128
|
+
When I successfully run `pprb find proxy -p proxy.pac -t 2014-12-07 -u http://www.example.org`
|
129
129
|
Then the output should contain:
|
130
130
|
"""
|
131
131
|
DIRECT
|
@@ -164,3 +164,27 @@ Feature: Resolve proxy
|
|
164
164
|
"""
|
165
165
|
proxy.example.com
|
166
166
|
"""
|
167
|
+
|
168
|
+
Scenario: Missing scheme in proxy.pac
|
169
|
+
Given a file named "proxy.pac" with:
|
170
|
+
"""
|
171
|
+
function FindProxyForURL(url, host) {
|
172
|
+
if (dnsDomainIs(host,"in.example.com")) {
|
173
|
+
return "DIRECT";
|
174
|
+
}
|
175
|
+
|
176
|
+
if (dnsDomainIs(host,"ex.example.com")) return "PROXY localhost:8080";
|
177
|
+
|
178
|
+
return 'PROXY localhost:3128';
|
179
|
+
}
|
180
|
+
"""
|
181
|
+
When I successfully run `pprb find proxy -p proxy.pac -u www.in.example.com`
|
182
|
+
Then the output should contain:
|
183
|
+
"""
|
184
|
+
DIRECT
|
185
|
+
"""
|
186
|
+
When I successfully run `pprb find proxy -p proxy.pac -u www.ex.example.com`
|
187
|
+
Then the output should contain:
|
188
|
+
"""
|
189
|
+
PROXY localhost:8080
|
190
|
+
"""
|
@@ -29,7 +29,7 @@ module ProxyPacRb
|
|
29
29
|
|
30
30
|
directory 'test_framework/rspec/', 'spec'
|
31
31
|
|
32
|
-
append_file 'Gemfile',
|
32
|
+
append_file 'Gemfile', <<~EOS
|
33
33
|
group :development, :test do
|
34
34
|
gem 'aruba', require: false
|
35
35
|
|
@@ -43,7 +43,7 @@ module ProxyPacRb
|
|
43
43
|
end
|
44
44
|
EOS
|
45
45
|
|
46
|
-
append_file 'Rakefile',
|
46
|
+
append_file 'Rakefile', <<~EOS
|
47
47
|
desc 'Run tests'
|
48
48
|
task test: 'test:local'
|
49
49
|
|
@@ -71,12 +71,12 @@ module ProxyPacRb
|
|
71
71
|
|
72
72
|
directory 'build/middleman', './'
|
73
73
|
|
74
|
-
append_file 'Gemfile',
|
74
|
+
append_file 'Gemfile', <<~EOS
|
75
75
|
gem 'middleman', '~>3.3.10'
|
76
76
|
gem 'therubyracer'
|
77
77
|
EOS
|
78
78
|
|
79
|
-
append_file 'Rakefile',
|
79
|
+
append_file 'Rakefile', <<~EOS
|
80
80
|
desc 'Build site'
|
81
81
|
task :build do
|
82
82
|
sh 'bundle exec middleman build --verbose'
|
@@ -53,7 +53,7 @@ module ProxyPacRb
|
|
53
53
|
# pure_funcs: nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
|
54
54
|
# drop_console: false, # Drop calls to console.* functions
|
55
55
|
# angular: false, # Process @ngInject annotations
|
56
|
-
|
56
|
+
keep_fargs: true # Preserve unused function arguments
|
57
57
|
# keep_fnames: true # Preserve function names
|
58
58
|
}
|
59
59
|
}.deep_merge options
|
@@ -55,9 +55,9 @@ module ProxyPacRb
|
|
55
55
|
|
56
56
|
def output_path(path)
|
57
57
|
if ::File.exist?(path.gsub(/#{in_extension}*$/, '') + in_extension)
|
58
|
-
|
58
|
+
path.gsub(/#{in_extension}*$/, '')
|
59
59
|
elsif ::File.exist? path
|
60
|
-
|
60
|
+
path + out_extension
|
61
61
|
else
|
62
62
|
raise Errno::ENOENT, "Both paths \"#{path.gsub(/#{in_extension}*$/, '') + in_extension}\" and \"#{path}\" do not exist."
|
63
63
|
end
|
@@ -5,7 +5,7 @@ module ProxyPacRb
|
|
5
5
|
class ProxyPacJs
|
6
6
|
class << self
|
7
7
|
def my_ip_address_template(value)
|
8
|
-
|
8
|
+
<<~EOS
|
9
9
|
function myIpAddress() {
|
10
10
|
return "#{value}";
|
11
11
|
}
|
@@ -15,7 +15,7 @@ module ProxyPacRb
|
|
15
15
|
# taken from releases-mozilla-release / netwerk / base / src / ProxyAutoConfig.cpp @ bitbucket.org
|
16
16
|
# https://bitbucket.org/mozilla/releases-mozilla-release/raw/dece38633cf1adcab2071d69fea264580d24cc9e/netwerk/base/src/ProxyAutoConfig.cpp
|
17
17
|
def time_variables
|
18
|
-
|
18
|
+
<<~EOS
|
19
19
|
var wdays = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6};
|
20
20
|
var months = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11};
|
21
21
|
EOS
|
@@ -24,7 +24,7 @@ module ProxyPacRb
|
|
24
24
|
def week_day_range_template(value = nil)
|
25
25
|
value = %("#{value}") if value
|
26
26
|
|
27
|
-
|
27
|
+
<<~EOS
|
28
28
|
function getDay(weekday) {
|
29
29
|
if (weekday in wdays) {
|
30
30
|
return wdays[weekday];
|
@@ -55,7 +55,7 @@ module ProxyPacRb
|
|
55
55
|
def date_range_template(value = nil)
|
56
56
|
value = %("#{value}") if value
|
57
57
|
|
58
|
-
|
58
|
+
<<~EOS
|
59
59
|
function getMonth(name) {
|
60
60
|
if (name in months) {
|
61
61
|
return months[name];
|
@@ -137,7 +137,7 @@ module ProxyPacRb
|
|
137
137
|
def time_range_template(value = nil)
|
138
138
|
value = %("#{value}") if value
|
139
139
|
|
140
|
-
|
140
|
+
<<~EOS
|
141
141
|
function timeRange() {
|
142
142
|
var argc = arguments.length;
|
143
143
|
var date = new Date(#{value});
|
data/lib/proxy_pac_rb/version.rb
CHANGED
data/proxy_pac_rb.gemspec
CHANGED
@@ -22,8 +22,8 @@ DESC
|
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
24
|
spec.add_runtime_dependency 'addressable', '~>2.3'
|
25
|
-
spec.add_runtime_dependency 'activesupport', '
|
26
|
-
spec.add_runtime_dependency 'uglifier', '
|
25
|
+
spec.add_runtime_dependency 'activesupport', '>=4.1', '<5.2'
|
26
|
+
spec.add_runtime_dependency 'uglifier', '>= 2.7.1'
|
27
27
|
spec.add_runtime_dependency 'excon', '~> 0.45.3'
|
28
28
|
spec.add_runtime_dependency 'contracts', '~> 0.9'
|
29
29
|
spec.add_runtime_dependency 'thor', '~> 0.19'
|
data/script/config.ru
CHANGED
@@ -8,7 +8,7 @@ RSpec.describe ProxyPacCompressor do
|
|
8
8
|
let(:modified_content) { %(function FindProxyForURL(url, host) {\n return \"DIRECT\";\n}) }
|
9
9
|
|
10
10
|
let(:content) do
|
11
|
-
|
11
|
+
<<~EOS.chomp
|
12
12
|
// comment
|
13
13
|
function FindProxyForURL(url, host) {
|
14
14
|
return "DIRECT";
|
@@ -5,7 +5,7 @@ RSpec.describe ProxyPacDumper, type: :aruba do
|
|
5
5
|
subject(:proxy_pac) { instance_double('ProxyPac::ProxyPacFile') }
|
6
6
|
|
7
7
|
let(:content) do
|
8
|
-
|
8
|
+
<<~EOS.chomp
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
return "DIRECT";
|
11
11
|
}
|
@@ -13,7 +13,7 @@ RSpec.describe ProxyPacDumper, type: :aruba do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:source) do
|
16
|
-
|
16
|
+
<<~EOS.chomp
|
17
17
|
function FindProxyForURL(url, host) {
|
18
18
|
return "DIRECT";
|
19
19
|
}
|
@@ -5,7 +5,7 @@ RSpec.describe ProxyPacLinter do
|
|
5
5
|
subject(:proxy_pac) { instance_double('ProxyPac::ProxyPacFile') }
|
6
6
|
|
7
7
|
let(:content) do
|
8
|
-
|
8
|
+
<<~EOS.chomp
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
return "DIRECT";
|
11
11
|
}
|
@@ -13,7 +13,7 @@ RSpec.describe ProxyPacLinter do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:source) do
|
16
|
-
|
16
|
+
<<~EOS.chomp
|
17
17
|
function FindProxyForURL(url, host) {
|
18
18
|
return "DIRECT";
|
19
19
|
}
|
@@ -50,7 +50,7 @@ RSpec.describe ProxyPacLinter do
|
|
50
50
|
context 'when is proxy.pac cannot be compiled' do
|
51
51
|
let(:result) { false }
|
52
52
|
let(:content) do
|
53
|
-
|
53
|
+
<<~EOS.chomp
|
54
54
|
function FindProxyForURL(url, host) {
|
55
55
|
asdfasf $$ SDF
|
56
56
|
}
|
@@ -5,7 +5,7 @@ RSpec.describe ProxyPacLoader, type: :aruba do
|
|
5
5
|
subject(:proxy_pac) { instance_double('ProxyPac::ProxyPacFile') }
|
6
6
|
|
7
7
|
let(:content) do
|
8
|
-
|
8
|
+
<<~EOS
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
return "DIRECT";
|
11
11
|
}
|
@@ -13,7 +13,7 @@ RSpec.describe ProxyPacLoader, type: :aruba do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:source) do
|
16
|
-
|
16
|
+
<<~EOS
|
17
17
|
function FindProxyForURL(url, host) {
|
18
18
|
return "DIRECT";
|
19
19
|
}
|
@@ -51,7 +51,7 @@ RSpec.describe ProxyPacLoader, type: :aruba do
|
|
51
51
|
it_behaves_like 'an un-readable proxy.pac'
|
52
52
|
end
|
53
53
|
|
54
|
-
context 'when proxy pac is file' do
|
54
|
+
context 'when proxy pac is file', type: :aruba do
|
55
55
|
let(:file) { 'proxy.pac' }
|
56
56
|
let(:type) { :file }
|
57
57
|
let(:source) { expand_path(file) }
|
@@ -5,7 +5,7 @@ RSpec.describe ProxyPacParser do
|
|
5
5
|
subject(:proxy_pac) { instance_double('ProxyPac::ProxyPacFile') }
|
6
6
|
|
7
7
|
let(:content) do
|
8
|
-
|
8
|
+
<<~EOS.chomp
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
return "DIRECT";
|
11
11
|
}
|
@@ -13,7 +13,7 @@ RSpec.describe ProxyPacParser do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:source) do
|
16
|
-
|
16
|
+
<<~EOS.chomp
|
17
17
|
function FindProxyForURL(url, host) {
|
18
18
|
return "DIRECT";
|
19
19
|
}
|
@@ -39,7 +39,7 @@ RSpec.describe ProxyPacParser do
|
|
39
39
|
|
40
40
|
context 'when is invalid' do
|
41
41
|
let(:content) do
|
42
|
-
|
42
|
+
<<~EOS.chomp
|
43
43
|
function FindProxyForURL(url, host) {
|
44
44
|
asdfasf $$ SDF
|
45
45
|
}
|
data/spec/parser_spec.rb
CHANGED
@@ -8,7 +8,7 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
8
8
|
let(:environment) { Environment.new }
|
9
9
|
|
10
10
|
let(:content) do
|
11
|
-
|
11
|
+
<<~EOS.chomp
|
12
12
|
function FindProxyForURL(url, host) {
|
13
13
|
return "DIRECT";
|
14
14
|
}
|
@@ -16,7 +16,7 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
let(:source) do
|
19
|
-
|
19
|
+
<<~EOS.chomp
|
20
20
|
function FindProxyForURL(url, host) {
|
21
21
|
return "DIRECT";
|
22
22
|
}
|
@@ -27,16 +27,44 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
27
27
|
it { expect(proxy_pac).not_to be_nil }
|
28
28
|
end
|
29
29
|
|
30
|
-
context 'when path is given' do
|
30
|
+
context 'when path is given', type: :aruba do
|
31
31
|
let(:source) { expand_path('proxy.pac') }
|
32
32
|
before(:each) { write_file(source, content) }
|
33
33
|
|
34
34
|
it { expect(proxy_pac).not_to be_nil }
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'when input is given' do
|
38
|
+
let(:source) do
|
39
|
+
<<~EOS.chomp
|
40
|
+
function FindProxyForURL(url, host) {
|
41
|
+
if (dnsDomainIs(host,"in.example.com")) {
|
42
|
+
return "DIRECT";
|
43
|
+
}
|
44
|
+
|
45
|
+
if (dnsDomainIs(host,"ex.example.com")) return "PROXY localhost:8080";
|
46
|
+
|
47
|
+
return 'PROXY localhost:3128';
|
48
|
+
}
|
49
|
+
EOS
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when url' do
|
53
|
+
it { expect(proxy_pac.find('http://www.in.example.com')).to eq('DIRECT') }
|
54
|
+
it { expect(proxy_pac.find('http://www.ex.example.com')).to eq('PROXY localhost:8080') }
|
55
|
+
it { expect(proxy_pac.find('http://www.other.example.de')).to eq('PROXY localhost:3128') }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when hostname' do
|
59
|
+
it { expect(proxy_pac.find('www.in.example.com')).to eq('DIRECT') }
|
60
|
+
it { expect(proxy_pac.find('www.ex.example.com')).to eq('PROXY localhost:8080') }
|
61
|
+
it { expect(proxy_pac.find('www.other.example.de')).to eq('PROXY localhost:3128') }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
37
65
|
context 'when ip address is given' do
|
38
66
|
let(:source) do
|
39
|
-
|
67
|
+
<<~EOS
|
40
68
|
function FindProxyForURL(url, host) {
|
41
69
|
if ( myIpAddress() == '127.0.0.2' ) {
|
42
70
|
return "DIRECT";
|
@@ -60,7 +88,7 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
60
88
|
|
61
89
|
context 'when date is given' do
|
62
90
|
let(:source) do
|
63
|
-
|
91
|
+
<<~EOS
|
64
92
|
function FindProxyForURL(url, host) {
|
65
93
|
if (weekdayRange("FRI", "SAT")) {
|
66
94
|
return "PROXY localhost:8080";
|
@@ -84,7 +112,7 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
84
112
|
|
85
113
|
context 'when time range is used' do
|
86
114
|
let(:source) do
|
87
|
-
|
115
|
+
<<~EOS
|
88
116
|
function FindProxyForURL(url, host) {
|
89
117
|
if (timeRange(8, 18)) {
|
90
118
|
return "PROXY localhost:8080";
|
@@ -108,7 +136,7 @@ RSpec.describe ProxyPacRb::Parser, type: :aruba do
|
|
108
136
|
|
109
137
|
context 'when date range is used' do
|
110
138
|
let(:source) do
|
111
|
-
|
139
|
+
<<~EOS
|
112
140
|
function FindProxyForURL(url, host) {
|
113
141
|
if (dateRange("JUL", "SEP")) {
|
114
142
|
return "PROXY localhost:8080";
|
@@ -17,7 +17,7 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
get '/' do
|
20
|
-
|
20
|
+
<<~EOS.chomp
|
21
21
|
// comment
|
22
22
|
function FindProxyForURL(url, host) {
|
23
23
|
return "DIRECT";
|
@@ -46,7 +46,7 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
get '/' do
|
49
|
-
|
49
|
+
<<~EOS.chomp
|
50
50
|
function FindProxyForURL(url, host) {
|
51
51
|
return $"§$ "DIRECT";
|
52
52
|
}
|
@@ -5,7 +5,7 @@ require 'rack/lint'
|
|
5
5
|
|
6
6
|
RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
7
7
|
let(:content) do
|
8
|
-
|
8
|
+
<<~EOS.chomp
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
return "DIRECT";
|
11
11
|
}
|
@@ -23,7 +23,7 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
get '/' do
|
26
|
-
|
26
|
+
<<~EOS.chomp
|
27
27
|
function FindProxyForURL(url, host) {
|
28
28
|
return "DIRECT";
|
29
29
|
}
|
@@ -51,7 +51,7 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
get '/' do
|
54
|
-
|
54
|
+
<<~EOS.chomp
|
55
55
|
function FindProxyForURL(url, host) {
|
56
56
|
return $"§$ "DIRECT";
|
57
57
|
}
|
@@ -4,7 +4,7 @@ require 'proxy_pac_rb/rspec'
|
|
4
4
|
|
5
5
|
RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
|
6
6
|
subject do
|
7
|
-
|
7
|
+
<<~EOS.chomp
|
8
8
|
function FindProxyForURL(url, host) {
|
9
9
|
return "DIRECT";
|
10
10
|
}
|
@@ -12,7 +12,7 @@ RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:file_a) do
|
15
|
-
|
15
|
+
<<~EOS.chomp
|
16
16
|
function FindProxyForURL(url, host) {
|
17
17
|
return "DIRECT";
|
18
18
|
}
|
@@ -20,7 +20,7 @@ RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:file_b) do
|
23
|
-
|
23
|
+
<<~EOS.chomp
|
24
24
|
function FindProxyForURL(url, host) {
|
25
25
|
return "DIRECT";
|
26
26
|
}
|
@@ -53,7 +53,7 @@ RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
|
|
53
53
|
|
54
54
|
context 'when both are not eqal' do
|
55
55
|
let(:file_a) do
|
56
|
-
|
56
|
+
<<~EOS.chomp
|
57
57
|
function FindProxyForURL(url, host) {
|
58
58
|
return "DIRECT";
|
59
59
|
}
|
@@ -61,7 +61,7 @@ RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
let(:file_b) do
|
64
|
-
|
64
|
+
<<~EOS.chomp
|
65
65
|
function FindProxyForURL(url, host) {
|
66
66
|
return "PROXY localhost:8080";
|
67
67
|
}
|
@@ -5,7 +5,7 @@ require 'proxy_pac_rb/rspec'
|
|
5
5
|
RSpec.describe 'Parse proxy.pac', type: :proxy_pac do
|
6
6
|
describe 'Browse url' do
|
7
7
|
subject do
|
8
|
-
|
8
|
+
<<~EOS.chomp
|
9
9
|
function FindProxyForURL(url, host) {
|
10
10
|
if (dnsDomainIs(host, 'localhost')) {
|
11
11
|
return "DIRECT";
|
@@ -29,7 +29,7 @@ RSpec.describe 'Parse proxy.pac', type: :proxy_pac do
|
|
29
29
|
|
30
30
|
describe 'Change time' do
|
31
31
|
subject do
|
32
|
-
|
32
|
+
<<~EOS.chomp
|
33
33
|
function FindProxyForURL(url, host) {
|
34
34
|
if (weekdayRange("FRI", "SAT")) {
|
35
35
|
return "PROXY localhost:8080";
|
@@ -59,7 +59,7 @@ RSpec.describe 'Parse proxy.pac', type: :proxy_pac do
|
|
59
59
|
|
60
60
|
describe 'Change client ip' do
|
61
61
|
subject do
|
62
|
-
|
62
|
+
<<~EOS.chomp
|
63
63
|
function FindProxyForURL(url, host) {
|
64
64
|
if ( myIpAddress() == '127.0.0.2' ) {
|
65
65
|
return "PROXY localhost:8080";
|
@@ -4,14 +4,14 @@ require 'proxy_pac_rb/rspec'
|
|
4
4
|
|
5
5
|
RSpec.describe 'Readability', type: [:proxy_pac, :aruba] do
|
6
6
|
let(:content) do
|
7
|
-
|
7
|
+
<<~EOS.chomp
|
8
8
|
function FindProxyForURL(url, host) {
|
9
9
|
return "DIRECT";
|
10
10
|
}
|
11
11
|
EOS
|
12
12
|
end
|
13
13
|
|
14
|
-
context 'when is file' do
|
14
|
+
context 'when is file', type: :aruba do
|
15
15
|
let(:root_path) { expand_path('.') }
|
16
16
|
|
17
17
|
subject { 'proxy.pac' }
|
@@ -45,7 +45,7 @@ RSpec.describe 'Readability', type: [:proxy_pac, :aruba] do
|
|
45
45
|
context 'when is string' do
|
46
46
|
context 'it is always readable' do
|
47
47
|
subject do
|
48
|
-
|
48
|
+
<<~EOS.chomp
|
49
49
|
function FindProxyForURL(url, host) {
|
50
50
|
return "DIRECT";
|
51
51
|
}
|
@@ -4,7 +4,7 @@ require 'proxy_pac_rb/rspec'
|
|
4
4
|
|
5
5
|
RSpec.describe 'Validity', type: :proxy_pac do
|
6
6
|
subject do
|
7
|
-
|
7
|
+
<<~EOS.chomp
|
8
8
|
function FindProxyForURL(url, host) {
|
9
9
|
return "DIRECT";
|
10
10
|
}
|
@@ -16,7 +16,7 @@ RSpec.describe 'Validity', type: :proxy_pac do
|
|
16
16
|
|
17
17
|
context 'although it makes URI to raise invalid url error' do
|
18
18
|
subject do
|
19
|
-
|
19
|
+
<<~EOS.chomp
|
20
20
|
function FindProxyForURL(url, host) {
|
21
21
|
// comment
|
22
22
|
if ( dnsDomainIs ( host, "example.org") ) {
|
@@ -39,7 +39,7 @@ RSpec.describe 'Validity', type: :proxy_pac do
|
|
39
39
|
|
40
40
|
context 'when contains gargabe' do
|
41
41
|
subject do
|
42
|
-
|
42
|
+
<<~EOS.chomp
|
43
43
|
function FindProxyForURL(url, host) {
|
44
44
|
return $§"% "DIRECT";
|
45
45
|
}
|
@@ -51,7 +51,7 @@ RSpec.describe 'Validity', type: :proxy_pac do
|
|
51
51
|
|
52
52
|
context 'when undefined variable is referenced' do
|
53
53
|
subject do
|
54
|
-
|
54
|
+
<<~EOS.chomp
|
55
55
|
function FindProxyForURL(url, host) {
|
56
56
|
return asdf;
|
57
57
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_pac_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Günnewig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -28,28 +28,34 @@ dependencies:
|
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.1'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5.2'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '4.1'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5.2'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: uglifier
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 2.7.1
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: 2.7.1
|
55
61
|
- !ruby/object:Gem::Dependency
|
@@ -113,6 +119,7 @@ files:
|
|
113
119
|
- ".rdebugrc"
|
114
120
|
- ".rspec"
|
115
121
|
- ".rubocop.yml"
|
122
|
+
- ".rubocop_todo.yml"
|
116
123
|
- ".simplecov"
|
117
124
|
- ".travis.yml"
|
118
125
|
- ".yardopts"
|
@@ -260,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
267
|
version: '0'
|
261
268
|
requirements: []
|
262
269
|
rubyforge_project:
|
263
|
-
rubygems_version: 2.6.
|
270
|
+
rubygems_version: 2.6.12
|
264
271
|
signing_key:
|
265
272
|
specification_version: 4
|
266
273
|
summary: Compress, lint and parse proxy auto-config files from commandline, rack-compatible
|