aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-11-04 12:38:43 -0600
committerPratik Naik <pratiknaik@gmail.com>2015-11-04 12:38:43 -0600
commit7c1631fa48b8862f37d1026b4f0cf1061dd6947a (patch)
treec7240f39faff2e2512ac704c9cb14382fd606302 /test
parentdf20d87c7b50cb7b19cc176a8f7944ee9f258446 (diff)
downloadrails-7c1631fa48b8862f37d1026b4f0cf1061dd6947a.tar.gz
rails-7c1631fa48b8862f37d1026b4f0cf1061dd6947a.tar.bz2
rails-7c1631fa48b8862f37d1026b4f0cf1061dd6947a.zip
Make sure cable closes the connection if open when responding to an invalid request
Diffstat (limited to 'test')
-rw-r--r--test/connection/authorization_test.rb12
1 files changed, 10 insertions, 2 deletions
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