Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix raw_ssl_request method for ruby 3.2.0 #127

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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