X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2cdc648b5367efd4c8e7b2ede93a2b3ba0871c17..44e4d85c32d5e4ea4dc651570672e59d7a10d3b3:/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 81834439c6..c2828020bd 100644 --- a/apps/workbench/test/functional/application_controller_test.rb +++ b/apps/workbench/test/functional/application_controller_test.rb @@ -83,7 +83,7 @@ class ApplicationControllerTest < ActionController::TestCase [:preload_log_collections_for_objects, nil], [:log_collections_for_object, nil], [:preload_objects_for_dataclass, 'input not an array'], - [:preload_objects_for_dataclass, nil], + [:preload_objects_for_dataclass, nil], [:object_for_dataclass, 'some_dataclass', nil], [:object_for_dataclass, nil, 'some_uuid'], ].each do |input| @@ -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