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

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2016-12-21 11:45:28 +01:00
parent 09b622f84c
commit 359718603e
3 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,4 @@
---
title: Ensure nil User-Agent doesn't break the CI API
merge_request:
author:

View file

@ -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!

View file

@ -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