diff --git a/test/lib/web_push/connections_test.rb b/test/lib/web_push/connections_test.rb index 9eb2b2b..1fb2d29 100644 --- a/test/lib/web_push/connections_test.rb +++ b/test/lib/web_push/connections_test.rb @@ -76,11 +76,13 @@ class WebPush::ConnectionsTest < ActiveSupport::TestCase end end - test "a TLS failure on a new connection before the push is written is reported as it is" do - failing_check = Module.new { private def begin_transport(*) = raise(OpenSSL::SSL::SSLError, "alert right after the handshake") } + class FailingCheckHTTP < WebPush::Connections::HTTP + private def begin_transport(*) = raise(OpenSSL::SSL::SSLError, "alert right after the handshake") + end + test "a TLS failure on a new connection before the push is written is reported as it is" do with_push_service do |server| - assert_raises(OpenSSL::SSL::SSLError) { @connections.request(pinned_connection(server).extend(failing_check), push_request) } + assert_raises(OpenSSL::SSL::SSLError) { @connections.request(pinned_connection(server, http_class: FailingCheckHTTP), push_request) } assert_empty server.requests end end diff --git a/test/test_helpers/push_service_test_helper.rb b/test/test_helpers/push_service_test_helper.rb index 1d4e701..ebe1cfd 100644 --- a/test/test_helpers/push_service_test_helper.rb +++ b/test/test_helpers/push_service_test_helper.rb @@ -108,8 +108,8 @@ module PushServiceTestHelper end # Built as WebPush::PersistentRequest builds it for a delivery. - def pinned_connection(server, ip = IP) - WebPush::Connections::HTTP.new(HOST, server.port, nil).tap do |http| + def pinned_connection(server, ip = IP, http_class: WebPush::Connections::HTTP) + http_class.new(HOST, server.port, nil).tap do |http| http.ipaddr = ip http.use_ssl = true end