X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/eaa312ea7c35e35c64dbef9624be1d9c7df034ef..d44a5c508cfa664134daad806d7be9a7cb0bd6ee:/apps/workbench/test/functional/application_controller_test.rb diff --git a/apps/workbench/test/functional/application_controller_test.rb b/apps/workbench/test/functional/application_controller_test.rb index f3dbcb523b..c2828020bd 100644 --- a/apps/workbench/test/functional/application_controller_test.rb +++ b/apps/workbench/test/functional/application_controller_test.rb @@ -296,4 +296,29 @@ class ApplicationControllerTest < ActionController::TestCase assert users.size == 3, 'Expected two objects in the preloaded hash' end + test "requesting a nonexistent object returns 404" do + # We're really testing ApplicationController's find_object_by_uuid. + # It's easiest to do that by instantiating a concrete controller. + @controller = NodesController.new + get(:show, {id: "zzzzz-zzzzz-zzzzzzzzzzzzzzz"}, session_for(:admin)) + assert_response 404 + 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 + # return 500. + orig_api_server = Rails.configuration.arvados_v1_base + begin + # The URL should look valid in all respects, and avoid talking over a + # network. 100::/64 is the IPv6 discard prefix, so it's perfect. + Rails.configuration.arvados_v1_base = "https://[100::f]:1/" + @controller = NodesController.new + get(:index, {}, session_for(:active)) + assert_includes(405..422, @response.code.to_i, + "bad response code when API server is unreachable") + ensure + Rails.configuration.arvados_v1_base = orig_api_server + end + end end