Commit 26459a48279aa570ef06273e319eebabf9d6af1b
1 parent
2e9ca8bf
Exists in
theme-brasil-digital-from-staging
and in
9 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 |
| @@ -167,4 +168,10 @@ class FeedHandlerTest < ActiveSupport::TestCase | @@ -167,4 +168,10 @@ class FeedHandlerTest < ActiveSupport::TestCase | ||
| 167 | assert_equal 'bli content', handler.fetch('http://site.org/feed.xml') | 168 | assert_equal 'bli content', handler.fetch('http://site.org/feed.xml') |
| 168 | end | 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 | end | 177 | end |