Commit 01fecce0c24f89482fe63b75ccecdf7ea81df9ad
Committed by
Joenio Costa
1 parent
732da2a8
Exists in
send_email_to_admins
and in
5 other branches
Disable ssl verification for feed handler"
Showing
2 changed files
with
8 additions
and
0 deletions
Show diff stats
lib/feed_handler.rb
... | ... | @@ -48,6 +48,7 @@ class FeedHandler |
48 | 48 | else |
49 | 49 | header.merge!(:proxy => ENV['FEED_HTTP_PROXY']) if ENV['FEED_HTTP_PROXY'] |
50 | 50 | end |
51 | + header.merge!(:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) if ENV['SSL_VERIFY_NONE'] | |
51 | 52 | open(address, header, &block) |
52 | 53 | end |
53 | 54 | return content | ... | ... |
test/unit/feed_handler_test.rb
... | ... | @@ -5,6 +5,7 @@ class FeedHandlerTest < ActiveSupport::TestCase |
5 | 5 | def setup |
6 | 6 | @handler = FeedHandler.new |
7 | 7 | @container = nil |
8 | + ENV.stubs('[]').with(anything) | |
8 | 9 | end |
9 | 10 | attr_reader :handler |
10 | 11 | def container |
... | ... | @@ -175,4 +176,10 @@ class FeedHandlerTest < ActiveSupport::TestCase |
175 | 176 | assert_equal 'bli content', handler.fetch('http://site.org/feed.xml') |
176 | 177 | end |
177 | 178 | |
179 | + should 'not verify ssl when define env parameter SSL_VERIFY_NONE' do | |
180 | + ENV.stubs('[]').with('SSL_VERIFY_NONE').returns(true) | |
181 | + handler.expects(:open).with('http://site.org/feed.xml', {"User-Agent" => "Noosfero/#{Noosfero::VERSION}", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}, anything) | |
182 | + handler.fetch('http://site.org/feed.xml') | |
183 | + end | |
184 | + | |
178 | 185 | end | ... | ... |