Skip to content

Commit

Permalink
Merge pull request #127 from Shopify/ruby-3-2-1-posts-data-fix
Browse files Browse the repository at this point in the history
fix raw_ssl_request method for ruby 3.2.0
  • Loading branch information
krzysztofbialek authored Mar 23, 2023
2 parents eb6d260 + 75380e1 commit c5ad433
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/active_utils/posts_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'active_utils'
require 'minitest/autorun'
require 'mocha/setup'
require 'mocha/minitest'

include ActiveUtils

Expand Down
9 changes: 9 additions & 0 deletions test/unit/posts_data_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5ad433

Please sign in to comment.