X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/060d38d627bd1e51dd2b3c6e7de9af6aa7d7b6f3..8a0e9c549595e114a0eadc9d6792a17fb59d0f3e:/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 af090f9536..b5f71acb53 100644 --- a/services/api/test/functional/application_controller_test.rb +++ b/services/api/test/functional/application_controller_test.rb @@ -34,28 +34,50 @@ class ApplicationControllerTest < ActionController::TestCase test "requesting nonexistent object returns 404 error" do authorize_with :admin - get(:show, id: BAD_UUID) + get(:show, params: {id: BAD_UUID}) check_404 end test "requesting object without read permission returns 404 error" do authorize_with :spectator - get(:show, id: specimens(:owned_by_active_user).uuid) + get(:show, params: {id: specimens(:owned_by_active_user).uuid}) check_404 end test "submitting bad object returns error" do authorize_with :spectator - post(:create, specimen: {badattr: "badvalue"}) + post(:create, params: {specimen: {badattr: "badvalue"}}) assert_response 422 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 authorize_with :active - post :create, { + post :create, params: { group: {}, ensure_unique_name: bogus } @@ -72,7 +94,7 @@ class ApplicationControllerTest < ActionController::TestCase test "boolean parameter #{boolparam.inspect} acceptable" do @controller = Arvados::V1::GroupsController.new authorize_with :active - post :create, { + post :create, params: { group: {}, ensure_unique_name: boolparam } @@ -83,7 +105,7 @@ class ApplicationControllerTest < ActionController::TestCase test "boolean parameter #{boolparam.inspect} accepted as #{bool.inspect}" do @controller = Arvados::V1::GroupsController.new authorize_with :active - post :create, { + post :create, params: { group: { name: groups(:aproject).name, owner_uuid: groups(:aproject).owner_uuid