Commit 35971860 authored by Rémy Coutable's avatar Rémy Coutable

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

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 09b622f8
---
title: Ensure nil User-Agent doesn't break the CI API
merge_request:
author:
......@@ -60,7 +60,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