Commit 26459a48279aa570ef06273e319eebabf9d6af1b

Authored by Victor Costa
1 parent 2e9ca8bf

Disable ssl verification for feed handler"

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
... ... @@ -167,4 +168,10 @@ class FeedHandlerTest < ActiveSupport::TestCase
167 168 assert_equal 'bli content', handler.fetch('http://site.org/feed.xml')
168 169 end
169 170  
  171 + should 'not verify ssl when define env parameter SSL_VERIFY_NONE' do
  172 + ENV.stubs('[]').with('SSL_VERIFY_NONE').returns(true)
  173 + handler.expects(:open).with('http://site.org/feed.xml', {"User-Agent" => "Noosfero/#{Noosfero::VERSION}", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}, anything)
  174 + handler.fetch('http://site.org/feed.xml')
  175 + end
  176 +
170 177 end
... ...