diff --git a/lib/active_utils/posts_data.rb b/lib/active_utils/posts_data.rb index 53ab31f..48d8200 100644 --- a/lib/active_utils/posts_data.rb +++ b/lib/active_utils/posts_data.rb @@ -43,7 +43,7 @@ def ssl_request(method, endpoint, data, headers) def raw_ssl_request(method, endpoint, data, headers = {}) logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict - logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint =~ /^https:/ + logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint.to_s =~ /^https:/ connection = new_connection(endpoint) connection.open_timeout = open_timeout diff --git a/test/test_helper.rb b/test/test_helper.rb index 60cc8cc..984b405 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,6 @@ require 'active_utils' require 'minitest/autorun' -require 'mocha/setup' +require 'mocha/minitest' include ActiveUtils diff --git a/test/unit/posts_data_test.rb b/test/unit/posts_data_test.rb index f42d16c..4cade9a 100644 --- a/test/unit/posts_data_test.rb +++ b/test/unit/posts_data_test.rb @@ -46,6 +46,15 @@ def test_logger_warns_if_ssl_strict_disabled @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) end + def test_logger_warns_can_handle_non_string_endpoints + @poster.logger = stub() + @poster.logger.expects(:warn).with("PostsDataTest::SSLPoster posting to plaintext endpoint, which is insecure") + + Connection.any_instance.stubs(:request) + + @poster.raw_ssl_request(:post, URI("http://shopify.com"), "", {}) + end + def test_logger_no_warning_if_ssl_strict_enabled @poster.logger = stub() @poster.logger.stubs(:warn).never