Commit 9e17ec76 authored by Kamil Trzciński's avatar Kamil Trzciński Committed by Douglas Barbosa Alexandre

Merge branch '25895-fix-headers-in-ci-api-helpers' into 'master'

Ensure nil User-Agent doesn't break the CI API

Closes #25895

See merge request !8213
parent efc97cbc
---
title: Ensure nil User-Agent doesn't break the CI API
merge_request:
author:
......@@ -49,7 +49,7 @@ module Ci
end
def build_not_found!
if headers['User-Agent'].match(/gitlab-ci-multi-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /)
if headers['User-Agent'].to_s.match(/gitlab-ci-multi-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /)
no_content!
else
not_found!
......
......@@ -37,6 +37,11 @@ describe Ci::API::Builds do
let(:user_agent) { 'Go-http-client/1.1' }
it { expect(response).to have_http_status(404) }
end
context "when runner doesn't have a User-Agent" do
let(:user_agent) { nil }
it { expect(response).to have_http_status(404) }
end
end
context 'when there is a pending build' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment