From 7c1631fa48b8862f37d1026b4f0cf1061dd6947a Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 4 Nov 2015 12:38:43 -0600 Subject: Make sure cable closes the connection if open when responding to an invalid request --- test/connection/authorization_test.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/connection') diff --git a/test/connection/authorization_test.rb b/test/connection/authorization_test.rb index 762c90fbbc..68668b2835 100644 --- a/test/connection/authorization_test.rb +++ b/test/connection/authorization_test.rb @@ -8,17 +8,25 @@ class ActionCable::Connection::AuthorizationTest < ActionCable::TestCase def connect reject_unauthorized_connection end + + def send_async(method, *args) + # Bypass Celluloid + send method, *args + end end test "unauthorized connection" do run_in_eventmachine do server = TestServer.new - env = Rack::MockRequest.env_for "/test", 'HTTP_CONNECTION' => 'upgrade', 'HTTP_UPGRADE' => 'websocket' + server.config.allowed_request_origins = %w( http://rubyonrails.com ) + + env = Rack::MockRequest.env_for "/test", 'HTTP_CONNECTION' => 'upgrade', 'HTTP_UPGRADE' => 'websocket', + 'HTTP_ORIGIN' => 'http://rubyonrails.com' connection = Connection.new(server, env) connection.websocket.expects(:close) + connection.process - connection.send :on_open end end end -- cgit v1.2.3