Ensure nil User-Agent doesn't break the CI API
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
09b622f84c
commit
359718603e
3 changed files with 10 additions and 1 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Ensure nil User-Agent doesn't break the CI API
|
||||||
|
merge_request:
|
||||||
|
author:
|
|
@ -60,7 +60,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_not_found!
|
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!
|
no_content!
|
||||||
else
|
else
|
||||||
not_found!
|
not_found!
|
||||||
|
|
|
@ -37,6 +37,11 @@ describe Ci::API::Builds do
|
||||||
let(:user_agent) { 'Go-http-client/1.1' }
|
let(:user_agent) { 'Go-http-client/1.1' }
|
||||||
it { expect(response).to have_http_status(404) }
|
it { expect(response).to have_http_status(404) }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'when there is a pending build' do
|
context 'when there is a pending build' do
|
||||||
|
|
Loading…
Reference in a new issue