X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0561bd0c3c07257fd58ded6c7cfa5feeae97af57..d1e00d89dac87929d39c0689a593f0574980f2e8:/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..27b046e3c2 100644 --- a/services/api/test/functional/application_controller_test.rb +++ b/services/api/test/functional/application_controller_test.rb @@ -51,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