X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1e2ace543b5614023e30f77d85c19da954cbf1cb..fe3f19bb8f0a684de9c5a7d1f7c619943d0daca0:/apps/workbench/test/controllers/collections_controller_test.rb?ds=sidebyside diff --git a/apps/workbench/test/controllers/collections_controller_test.rb b/apps/workbench/test/controllers/collections_controller_test.rb index 8c42145962..45aab3c857 100644 --- a/apps/workbench/test/controllers/collections_controller_test.rb +++ b/apps/workbench/test/controllers/collections_controller_test.rb @@ -534,7 +534,7 @@ class CollectionsControllerTest < ActionController::TestCase id = api_fixture('collections')['w_a_z_file'][id_type] get :show_file, {uuid: id, file: "w a z"}, session_for(:active) assert_response :redirect - assert_equal "https://#{id.sub '+', '-'}.example/_/w+a+z?api_token=#{tok}", @response.redirect_url + assert_equal "https://#{id.sub '+', '-'}.example/_/w%20a%20z?api_token=#{tok}", @response.redirect_url end test "Redirect to keep_web_url via #{id_type} with reader token" do @@ -543,7 +543,7 @@ class CollectionsControllerTest < ActionController::TestCase id = api_fixture('collections')['w_a_z_file'][id_type] get :show_file, {uuid: id, file: "w a z", reader_token: tok}, session_for(:expired) assert_response :redirect - assert_equal "https://#{id.sub '+', '-'}.example/t=#{tok}/_/w+a+z", @response.redirect_url + assert_equal "https://#{id.sub '+', '-'}.example/t=#{tok}/_/w%20a%20z", @response.redirect_url end test "Redirect to keep_web_url via #{id_type} with no token" do @@ -552,7 +552,7 @@ class CollectionsControllerTest < ActionController::TestCase id = api_fixture('collections')['public_text_file'][id_type] get :show_file, {uuid: id, file: "Hello World.txt"} assert_response :redirect - assert_equal "https://#{id.sub '+', '-'}.example/_/Hello+World.txt", @response.redirect_url + assert_equal "https://#{id.sub '+', '-'}.example/_/Hello%20World.txt", @response.redirect_url end test "Redirect to keep_web_url via #{id_type} with disposition param" do @@ -565,7 +565,7 @@ class CollectionsControllerTest < ActionController::TestCase disposition: 'attachment', } assert_response :redirect - assert_equal "https://#{id.sub '+', '-'}.example/_/Hello+World.txt?disposition=attachment", @response.redirect_url + assert_equal "https://#{id.sub '+', '-'}.example/_/Hello%20World.txt?disposition=attachment", @response.redirect_url end test "Redirect to keep_web_download_url via #{id_type}" do @@ -575,7 +575,18 @@ class CollectionsControllerTest < ActionController::TestCase id = api_fixture('collections')['w_a_z_file'][id_type] get :show_file, {uuid: id, file: "w a z"}, session_for(:active) assert_response :redirect - assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w+a+z?api_token=#{tok}", @response.redirect_url + assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{tok}", @response.redirect_url + end + + test "Redirect to keep_web_url via #{id_type} when trust_all_content enabled" do + Rails.configuration.trust_all_content = true + setup_for_keep_web('https://collections.example/c=%{uuid_or_pdh}', + 'https://download.example/c=%{uuid_or_pdh}') + tok = api_fixture('api_client_authorizations')['active']['api_token'] + id = api_fixture('collections')['w_a_z_file'][id_type] + get :show_file, {uuid: id, file: "w a z"}, session_for(:active) + assert_response :redirect + assert_equal "https://collections.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{tok}", @response.redirect_url end end @@ -600,7 +611,7 @@ class CollectionsControllerTest < ActionController::TestCase disposition: 'attachment', }, session_for(:active) assert_response :redirect - expect_url = "https://download.example/c=#{id.sub '+', '-'}/_/Hello+world.txt" + expect_url = "https://download.example/c=#{id.sub '+', '-'}/_/Hello%20world.txt" if not anon expect_url += "?api_token=#{tok}" end @@ -617,12 +628,15 @@ class CollectionsControllerTest < ActionController::TestCase assert_response 422 end - test "Redirect preview to keep_web_download_url when preview is disabled" do - setup_for_keep_web false, 'https://download.example/c=%{uuid_or_pdh}' - tok = api_fixture('api_client_authorizations')['active']['api_token'] - id = api_fixture('collections')['w_a_z_file']['uuid'] - get :show_file, {uuid: id, file: "w a z"}, session_for(:active) - assert_response :redirect - assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w+a+z?api_token=#{tok}", @response.redirect_url + [false, true].each do |trust_all_content| + test "Redirect preview to keep_web_download_url when preview is disabled and trust_all_content is #{trust_all_content}" do + Rails.configuration.trust_all_content = trust_all_content + setup_for_keep_web false, 'https://download.example/c=%{uuid_or_pdh}' + tok = api_fixture('api_client_authorizations')['active']['api_token'] + id = api_fixture('collections')['w_a_z_file']['uuid'] + get :show_file, {uuid: id, file: "w a z"}, session_for(:active) + assert_response :redirect + assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{tok}", @response.redirect_url + end end end