提交 592b8d71 编写于 作者: K Kamil Trzciński

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
---
title: Forbid to patch traces for finished jobs
merge_request: 18969
author:
type: fixed
...@@ -149,6 +149,7 @@ module API ...@@ -149,6 +149,7 @@ module API
end end
patch '/:id/trace' do patch '/:id/trace' do
job = authenticate_job! job = authenticate_job!
forbidden!('Job is not running') unless job.running?
error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range') error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')
content_range = request.headers['Content-Range'] content_range = request.headers['Content-Range']
......
...@@ -918,6 +918,22 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -918,6 +918,22 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended' expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
end 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 context 'when redis data are flushed' do
before do before do
redis_shared_state_cleanup! redis_shared_state_cleanup!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册