@@ -9,8 +9,8 @@ module WebRequestConcern |
||
9 | 9 |
errors.add(:base, "user_agent must be a string") unless options['user_agent'].is_a?(String) |
10 | 10 |
end |
11 | 11 |
|
12 |
- if options['disable_ssl_verification'].present? and not [true, false].include? options['disable_ssl_verification'] |
|
13 |
- errors.add(:base, "if provided, disable_ssl_verification must be a boolean") |
|
12 |
+ if options['disable_ssl_verification'].present? && ![true, false, 'true', 'false'].include?(options['disable_ssl_verification']) |
|
13 |
+ errors.add(:base, "if provided, disable_ssl_verification must be true or false") |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
unless headers(options['headers']).is_a?(Hash) |
@@ -27,7 +27,7 @@ module WebRequestConcern |
||
27 | 27 |
def faraday |
28 | 28 |
faraday_options = { |
29 | 29 |
ssl: { |
30 |
- verify: !options['disable_ssl_verification'] |
|
30 |
+ verify: !boolify(options['disable_ssl_verification']) |
|
31 | 31 |
} |
32 | 32 |
} |
33 | 33 |
|
@@ -19,6 +19,7 @@ module Agents |
||
19 | 19 |
|
20 | 20 |
* `headers` - When present, it should be a hash of headers to send with the request. |
21 | 21 |
* `basic_auth` - Specify HTTP basic auth parameters: `"username:password"`, or `["username", "password"]`. |
22 |
+ * `disable_ssl_verification` - Set to `true` to disable ssl verification. |
|
22 | 23 |
* `user_agent` - A custom User-Agent name (default: "Faraday v#{Faraday::VERSION}"). |
23 | 24 |
MD |
24 | 25 |
|
@@ -22,6 +22,7 @@ module Agents |
||
22 | 22 |
* `expected_update_period_in_days` - How often you expect this RSS feed to change. If more than this amount of time passes without an update, the Agent will mark itself as not working. |
23 | 23 |
* `headers` - When present, it should be a hash of headers to send with the request. |
24 | 24 |
* `basic_auth` - Specify HTTP basic auth parameters: `"username:password"`, or `["username", "password"]`. |
25 |
+ * `disable_ssl_verification` - Set to `true` to disable ssl verification. |
|
25 | 26 |
* `user_agent` - A custom User-Agent name (default: "Faraday v#{Faraday::VERSION}"). |
26 | 27 |
MD |
27 | 28 |
end |
@@ -74,6 +74,8 @@ module Agents |
||
74 | 74 |
|
75 | 75 |
The `headers` field is optional. When present, it should be a hash of headers to send with the request. |
76 | 76 |
|
77 |
+ Set `disable_ssl_verification` to `true` to disable ssl verification. |
|
78 |
+ |
|
77 | 79 |
The WebsiteAgent can also scrape based on incoming events. It will scrape the url contained in the `url` key of the incoming event payload. If you specify `merge` as the mode, it will retain the old payload and update it with the new values. |
78 | 80 |
|
79 | 81 |
In Liquid templating, the following variable is available: |
@@ -73,6 +73,12 @@ shared_examples_for WebRequestConcern do |
||
73 | 73 |
agent.options['disable_ssl_verification'] = false |
74 | 74 |
expect(agent).to be_valid |
75 | 75 |
|
76 |
+ agent.options['disable_ssl_verification'] = 'true' |
|
77 |
+ expect(agent).to be_valid |
|
78 |
+ |
|
79 |
+ agent.options['disable_ssl_verification'] = 'false' |
|
80 |
+ expect(agent).to be_valid |
|
81 |
+ |
|
76 | 82 |
agent.options['disable_ssl_verification'] = 'blah' |
77 | 83 |
expect(agent).not_to be_valid |
78 | 84 |
|
@@ -111,9 +117,29 @@ shared_examples_for WebRequestConcern do |
||
111 | 117 |
expect(agent.faraday.ssl.verify).to eq(true) |
112 | 118 |
end |
113 | 119 |
|
120 |
+ it "should enable SSL verification when nil" do |
|
121 |
+ agent.options['disable_ssl_verification'] = nil |
|
122 |
+ expect(agent.faraday.ssl.verify).to eq(true) |
|
123 |
+ end |
|
124 |
+ |
|
125 |
+ it "should disable SSL verification if disable_ssl_verification option is 'true'" do |
|
126 |
+ agent.options['disable_ssl_verification'] = 'true' |
|
127 |
+ expect(agent.faraday.ssl.verify).to eq(false) |
|
128 |
+ end |
|
129 |
+ |
|
114 | 130 |
it "should disable SSL verification if disable_ssl_verification option is true" do |
115 | 131 |
agent.options['disable_ssl_verification'] = true |
116 | 132 |
expect(agent.faraday.ssl.verify).to eq(false) |
117 | 133 |
end |
134 |
+ |
|
135 |
+ it "should not disable SSL verification if disable_ssl_verification option is 'false'" do |
|
136 |
+ agent.options['disable_ssl_verification'] = 'false' |
|
137 |
+ expect(agent.faraday.ssl.verify).to eq(true) |
|
138 |
+ end |
|
139 |
+ |
|
140 |
+ it "should not disable SSL verification if disable_ssl_verification option is false" do |
|
141 |
+ agent.options['disable_ssl_verification'] = false |
|
142 |
+ expect(agent.faraday.ssl.verify).to eq(true) |
|
143 |
+ end |
|
118 | 144 |
end |
119 | 145 |
end |