X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/45f10d80d1b584808a6e375214b5be6bc7d2a730..78fedce2fadbe985c5b7ec0dbe26ad8cddfb6cdb:/apps/workbench/test/controllers/application_controller_test.rb diff --git a/apps/workbench/test/controllers/application_controller_test.rb b/apps/workbench/test/controllers/application_controller_test.rb index 15d52da3c3..99b80a0cc9 100644 --- a/apps/workbench/test/controllers/application_controller_test.rb +++ b/apps/workbench/test/controllers/application_controller_test.rb @@ -334,6 +334,45 @@ class ApplicationControllerTest < ActionController::TestCase assert_response 404 end + test "requesting to the API server includes client_session_id param" do + use_token :active do + fixture = api_fixture("collections")["foo_collection_in_aproject"] + c = Collection.find(fixture['uuid']) + + got_query = nil + stub_api_calls + stub_api_client.expects(:post).with do |url, query, opts={}| + got_query = query + true + end.returns fake_api_response('{}', 200, {}) + c.name = "name change for testing" + c.save + + assert_includes got_query, 'client_session_id' + assert_match /\d{10}-\d{9}/, got_query['client_session_id'] + end + end + + [".navbar .login-menu a", + ".navbar .login-menu .dropdown-menu a" + ].each do |css_selector| + test "login link at #{css_selector.inspect} includes return_to param" do + # Without an anonymous token, we're immediately redirected to login. + Rails.configuration.anonymous_user_token = + api_fixture("api_client_authorizations", "anonymous", "api_token") + @controller = ProjectsController.new + test_uuid = "zzzzz-j7d0g-zzzzzzzzzzzzzzz" + get(:show, {id: test_uuid}) + login_link = css_select(css_selector).first + assert_not_nil(login_link, "failed to select login link") + login_href = URI.unescape(login_link.attributes["href"]) + # The parameter needs to include the full URL to work. + assert_includes(login_href, "://") + assert_match(/[\?&]return_to=[^&]*\/projects\/#{test_uuid}(&|$)/, + login_href) + end + end + test "Workbench returns 4xx when API server is unreachable" do # We're really testing ApplicationController's render_exception. # Our primary concern is that it doesn't raise an error and