1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/test/connection/authorization_test.rb

32 lines
831 B
Ruby
Raw Normal View History

2015-07-12 12:59:46 -04:00
require 'test_helper'
require 'stubs/test_server'
2015-10-15 22:11:49 -04:00
class ActionCable::Connection::AuthorizationTest < ActionCable::TestCase
2015-07-12 12:59:46 -04:00
class Connection < ActionCable::Connection::Base
attr_reader :websocket
def connect
reject_unauthorized_connection
end
def send_async(method, *args)
send method, *args
end
2015-07-12 12:59:46 -04:00
end
test "unauthorized connection" do
2015-10-15 22:11:49 -04:00
run_in_eventmachine do
server = TestServer.new
server.config.allowed_request_origins = %w( http://rubyonrails.com )
env = Rack::MockRequest.env_for "/test", 'HTTP_CONNECTION' => 'upgrade', 'HTTP_UPGRADE' => 'websocket',
'HTTP_HOST' => 'localhost', 'HTTP_ORIGIN' => 'http://rubyonrails.com'
2015-07-12 12:59:46 -04:00
2015-10-15 22:11:49 -04:00
connection = Connection.new(server, env)
connection.websocket.expects(:close)
2015-10-15 22:11:49 -04:00
connection.process
end
2015-07-12 12:59:46 -04:00
end
end