X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/19ae770973482257117fe8ded5619c3018c4b60f..652e26feea271a3d86430cd494503ff96e11dc9f:/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 3a4a244edd..27b046e3c2 100644 --- a/services/api/test/functional/application_controller_test.rb +++ b/services/api/test/functional/application_controller_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class ApplicationControllerTest < ActionController::TestCase @@ -47,6 +51,28 @@ 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