X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/77d3ed33f525bd6859580954c6d7b9b36b394b98..25f3a23bc8794b77a1b5fa1e5e7f9c38a152dd8f:/apps/workbench/test/functional/collections_controller_test.rb diff --git a/apps/workbench/test/functional/collections_controller_test.rb b/apps/workbench/test/functional/collections_controller_test.rb index 7a1516116b..19d08d73b3 100644 --- a/apps/workbench/test/functional/collections_controller_test.rb +++ b/apps/workbench/test/functional/collections_controller_test.rb @@ -88,29 +88,14 @@ class CollectionsControllerTest < ActionController::TestCase "controller did not find related log") end - test "viewing a collection with a reader token" do + test "viewing collection files with a reader token" do params = collection_params(:foo_file) - params[:reader_tokens] = - [api_fixture('api_client_authorizations')['active']['api_token']] - show_collection(params) - assert_equal([['.', 'foo', 3]], assigns(:object).files) - assert_no_session - end - - test "viewing the index with a reader token" do - params = {reader_tokens: - [api_fixture('api_client_authorizations')['spectator']['api_token']] - } - get(:index, params) + params[:reader_token] = + api_fixture('api_client_authorizations')['active']['api_token'] + get(:show_file_links, params) assert_response :success + assert_equal([['.', 'foo', 3]], assigns(:object).files) assert_no_session - listed_collections = assigns(:collections).map { |c| c.uuid } - assert_includes(listed_collections, - api_fixture('collections')['bar_file']['uuid'], - "spectator reader token didn't list bar file") - refute_includes(listed_collections, - api_fixture('collections')['foo_file']['uuid'], - "spectator reader token listed foo file") end test "getting a file from Keep" do @@ -126,7 +111,7 @@ class CollectionsControllerTest < ActionController::TestCase params = collection_params(:foo_file, 'foo') sess = session_for(:spectator) get(:show_file, params, sess) - assert_includes([403, 404], @response.code.to_i) + assert_response 404 end test "trying to get a nonexistent file from Keep returns a 404" do @@ -139,7 +124,7 @@ class CollectionsControllerTest < ActionController::TestCase test "getting a file from Keep with a good reader token" do params = collection_params(:foo_file, 'foo') read_token = api_fixture('api_client_authorizations')['active']['api_token'] - params[:reader_tokens] = [read_token] + params[:reader_token] = read_token get(:show_file, params) assert_response :success assert_equal(expected_contents(params, read_token), @response.body, @@ -150,9 +135,8 @@ class CollectionsControllerTest < ActionController::TestCase test "trying to get from Keep with an unscoped reader token prompts login" do params = collection_params(:foo_file, 'foo') - read_token = + params[:reader_token] = api_fixture('api_client_authorizations')['active_noscope']['api_token'] - params[:reader_tokens] = [read_token] get(:show_file, params) assert_response :redirect end @@ -161,7 +145,7 @@ class CollectionsControllerTest < ActionController::TestCase params = collection_params(:foo_file, 'foo') sess = session_for(:expired) read_token = api_fixture('api_client_authorizations')['active']['api_token'] - params[:reader_tokens] = [read_token] + params[:reader_token] = read_token get(:show_file, params, sess) assert_response :success assert_equal(expected_contents(params, read_token), @response.body,