1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class UserSessionsControllerTest < ActionController::TestCase
10 @allowed_return_to = ",https://controller.api.client.invalid"
13 test "login route deleted" do
14 @request.headers['Authorization'] = 'Bearer '+Rails.configuration.SystemRootToken
15 get :login, params: {provider: 'controller', return_to: @allowed_return_to}
19 test "controller cannot create session without SystemRootToken" do
20 get :create, params: {provider: 'controller', auth_info: {email: "foo@bar.com"}, return_to: @allowed_return_to}
24 test "controller cannot create session with wrong SystemRootToken" do
25 @request.headers['Authorization'] = 'Bearer blah'
26 get :create, params: {provider: 'controller', auth_info: {email: "foo@bar.com"}, return_to: @allowed_return_to}
30 test "controller can create session using SystemRootToken" do
31 @request.headers['Authorization'] = 'Bearer '+Rails.configuration.SystemRootToken
32 get :create, params: {provider: 'controller', auth_info: {email: "foo@bar.com"}, return_to: @allowed_return_to}
33 assert_response :redirect
34 api_client_auth = assigns(:api_client_auth)
35 assert_not_nil api_client_auth
36 assert_includes(@response.redirect_url, 'api_token='+api_client_auth.token)