Merge branch 'create-live-trace-only-if-job-is-complete' into 'master'

Append trace chunk only if job is running

Closes #46383

See merge request gitlab-org/gitlab-ce!18969
This commit is contained in:
Kamil Trzciński 2018-05-21 13:33:48 +00:00
commit 592b8d716f
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
title: Forbid to patch traces for finished jobs
merge_request: 18969
author:
type: fixed

View File

@ -149,6 +149,7 @@ module API
end
patch '/:id/trace' do
job = authenticate_job!
forbidden!('Job is not running') unless job.running?
error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')
content_range = request.headers['Content-Range']

View File

@ -918,6 +918,22 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
end
context 'when job is cancelled' do
before do
job.cancel
end
context 'when trace is patched' do
before do
patch_the_trace
end
it 'returns Forbidden ' do
expect(response.status).to eq(403)
end
end
end
context 'when redis data are flushed' do
before do
redis_shared_state_cleanup!