From a536cc8f1e31e09526b6b43c07ec255d66cd2049 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 24 Feb 2016 21:48:59 -0500 Subject: Only hijack Rack socket when first needed Fixes #23471 --- actioncable/test/connection/base_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'actioncable/test/connection/base_test.rb') diff --git a/actioncable/test/connection/base_test.rb b/actioncable/test/connection/base_test.rb index 3bef9e95a1..fb11f9be64 100644 --- a/actioncable/test/connection/base_test.rb +++ b/actioncable/test/connection/base_test.rb @@ -108,6 +108,26 @@ class ActionCable::Connection::BaseTest < ActionCable::TestCase end end + test "rejecting a connection causes a 404" do + run_in_eventmachine do + class CallMeMaybe + def call(*) + raise 'Do not call me!' + end + end + + env = Rack::MockRequest.env_for( + "/test", + { 'HTTP_CONNECTION' => 'upgrade', 'HTTP_UPGRADE' => 'websocket', + 'HTTP_ORIGIN' => 'http://rubyonrails.org', 'rack.hijack' => CallMeMaybe.new } + ) + + connection = ActionCable::Connection::Base.new(@server, env) + response = connection.process + assert_equal 404, response[0] + end + end + private def open_connection env = Rack::MockRequest.env_for "/test", 'HTTP_CONNECTION' => 'upgrade', 'HTTP_UPGRADE' => 'websocket', -- cgit v1.2.3