Sha256: 10b89d19eb3a29ca14bf179fbc7c516074b34a89b5e583002d8593196211bf38
Contents?: true
Size: 1.6 KB
Versions: 5
Compression:
Stored size: 1.6 KB
Contents
require 'test_helper' require 'active_support/core_ext/class' class PostsDataTest < Test::Unit::TestCase class SSLPoster include PostsData attr_accessor :logger end def setup @poster = SSLPoster.new end def test_ssl_request_retried_three_times_by_default requester = stubs(:requester) requester.expects(:post).raises(Errno::ECONNREFUSED).times(3) Connection.any_instance.stubs(:http => requester) assert_raises ActiveMerchant::ConnectionError do @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) end end def test_ssl_request_never_retried_if_max_retries_set SSLPoster.max_retries = 1 requester = stubs(:requester) requester.expects(:post).raises(Errno::ECONNREFUSED).times(1) Connection.any_instance.stubs(:http => requester) assert_raises ActiveMerchant::ConnectionError do @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) end ensure SSLPoster.max_retries = ActiveMerchant::Connection::MAX_RETRIES end def test_logger_warns_if_ssl_strict_disabled @poster.logger = stub() @poster.logger.expects(:warn).with("PostsDataTest::SSLPoster using ssl_strict=false, which is insecure") Connection.any_instance.stubs(:request) SSLPoster.ssl_strict = false @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) end def test_logger_no_warning_if_ssl_strict_enabled @poster.logger = stub() @poster.logger.stubs(:warn).never Connection.any_instance.stubs(:request) SSLPoster.ssl_strict = true @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) end end
Version data entries
5 entries across 5 versions & 1 rubygems