Commit 26f1c097 authored by Fabio Huser's avatar Fabio Huser

Correct job artifacts API download for expired and locked files

GitLab allows to keep artifacts around beyond their expiration, if
a pipeline is the latest on a certain REF. One can download those
files via Web UI, but the download via API was broken. This commit
corrects the expiration check and also adds a unit-test case for it.
parent b93bdfaa
......@@ -90,7 +90,7 @@ module API
build = find_build!(params[:job_id])
authorize_read_job_artifacts!(build)
not_found! unless build.artifacts?
not_found! unless build.available_artifacts?
path = Gitlab::Ci::Build::Artifacts::Path
.new(params[:artifact_path])
......
......@@ -328,6 +328,17 @@ RSpec.describe API::Jobs do
.to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
context 'when artifacts are locked' do
it 'allows access to expired artifact' do
pipeline.artifacts_locked!
job.update!(artifacts_expire_at: Time.now - 7.days)
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
end
......
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