X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/248c7167e95d970b770c43102ee68cf1319973f7..aceb1f665394d84ec238d6654b5447a37c2bc3b3:/services/api/test/functional/application_controller_test.rb diff --git a/services/api/test/functional/application_controller_test.rb b/services/api/test/functional/application_controller_test.rb index b5f71acb53..af7882141e 100644 --- a/services/api/test/functional/application_controller_test.rb +++ b/services/api/test/functional/application_controller_test.rb @@ -28,7 +28,9 @@ class ApplicationControllerTest < ActionController::TestCase def check_404(errmsg="Path not found") assert_response 404 - assert_equal([errmsg], json_response['errors']) + json_response['errors'].each do |err| + assert(err.include?(errmsg), "error message '#{err}' expected to include '#{errmsg}'") + end check_error_token end @@ -51,28 +53,6 @@ class ApplicationControllerTest < ActionController::TestCase check_error_token end - test "X-Request-Id header" do - authorize_with :spectator - get(:index) - assert_match /^req-[0-9a-zA-Z]{20}$/, response.headers['X-Request-Id'] - end - - # The response header is the one that gets logged, so this test also - # ensures we log the ID supplied in the request, if any. - test "X-Request-Id given by client" do - authorize_with :spectator - @request.headers['X-Request-Id'] = 'abcdefG' - get(:index) - assert_equal 'abcdefG', response.headers['X-Request-Id'] - end - - test "X-Request-Id given by client is ignored if too long" do - authorize_with :spectator - @request.headers['X-Request-Id'] = 'abcdefG' * 1000 - get(:index) - assert_match /^req-[0-9a-zA-Z]{20}$/, response.headers['X-Request-Id'] - end - ['foo', '', 'FALSE', 'TRUE', nil, [true], {a:true}, '"true"'].each do |bogus| test "bogus boolean parameter #{bogus.inspect} returns error" do @controller = Arvados::V1::GroupsController.new @@ -95,7 +75,7 @@ class ApplicationControllerTest < ActionController::TestCase @controller = Arvados::V1::GroupsController.new authorize_with :active post :create, params: { - group: {}, + group: {group_class: "project"}, ensure_unique_name: boolparam } assert_response :success @@ -108,7 +88,8 @@ class ApplicationControllerTest < ActionController::TestCase post :create, params: { group: { name: groups(:aproject).name, - owner_uuid: groups(:aproject).owner_uuid + owner_uuid: groups(:aproject).owner_uuid, + group_class: "project" }, ensure_unique_name: boolparam } @@ -116,4 +97,16 @@ class ApplicationControllerTest < ActionController::TestCase end end end + + test "exceptions with backtraces get logged at exception_backtrace key" do + Group.stubs(:new).raises(Exception, 'Whoops') + Rails.logger.expects(:info).with(any_parameters) do |param| + param.include?('Whoops') and param.include?('"exception_backtrace":') + end + @controller = Arvados::V1::GroupsController.new + authorize_with :active + post :create, params: { + group: {}, + } + end end