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,6 +48,7 @@ class FeedHandler | ||
48 | else | 48 | else |
49 | header.merge!(:proxy => ENV['FEED_HTTP_PROXY']) if ENV['FEED_HTTP_PROXY'] | 49 | header.merge!(:proxy => ENV['FEED_HTTP_PROXY']) if ENV['FEED_HTTP_PROXY'] |
50 | end | 50 | end |
51 | + header.merge!(:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) if ENV['SSL_VERIFY_NONE'] | ||
51 | open(address, header, &block) | 52 | open(address, header, &block) |
52 | end | 53 | end |
53 | return content | 54 | return content |
test/unit/feed_handler_test.rb
@@ -5,6 +5,7 @@ class FeedHandlerTest < ActiveSupport::TestCase | @@ -5,6 +5,7 @@ class FeedHandlerTest < ActiveSupport::TestCase | ||
5 | def setup | 5 | def setup |
6 | @handler = FeedHandler.new | 6 | @handler = FeedHandler.new |
7 | @container = nil | 7 | @container = nil |
8 | + ENV.stubs('[]').with(anything) | ||
8 | end | 9 | end |
9 | attr_reader :handler | 10 | attr_reader :handler |
10 | def container | 11 | def container |
@@ -175,4 +176,10 @@ class FeedHandlerTest < ActiveSupport::TestCase | @@ -175,4 +176,10 @@ class FeedHandlerTest < ActiveSupport::TestCase | ||
175 | assert_equal 'bli content', handler.fetch('http://site.org/feed.xml') | 176 | assert_equal 'bli content', handler.fetch('http://site.org/feed.xml') |
176 | end | 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 | end | 185 | end |