mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-27 07:56:48 +09:00
Raise the TLS alert from a subclass instead of extending one connection
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ce7b5d4ea0
commit
8d4a5264cf
2 files changed
+7
-5
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user