summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-02-28 17:55:56 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-03-02 17:45:46 +0100
commitf7d352341eb4a0eea98889275cbbeb46049d21a2 (patch)
tree8ab1d81b230d2193fee03fcb5eb678781bae6ea8 /spec/requests
parentc2eb54760d74cb901d251e8e0af5e9d0db314755 (diff)
downloadgitlab-ce-f7d352341eb4a0eea98889275cbbeb46049d21a2.tar.gz
Add artifacts downloading API
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/runner_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index de8e8a012a0..37045610cc2 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -895,6 +895,46 @@ describe API::Runner do
post api("/jobs/#{job.id}/artifacts"), params, headers
end
end
+
+ describe 'GET /api/v4/jobs/:id/artifacts' do
+ let(:token) { job.token }
+
+ before { download_artifact }
+
+ context 'when job has artifacts' do
+ let(:job) { create(:ci_build, :artifacts) }
+ let(:download_headers) do
+ { 'Content-Transfer-Encoding' => 'binary',
+ 'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
+ end
+
+ context 'when using job token' do
+ it 'download artifacts' do
+ expect(response).to have_http_status(200)
+ expect(response.headers).to include download_headers
+ end
+ end
+
+ context 'when using runnners token' do
+ let(:token) { job.project.runners_token }
+
+ it 'responds with forbidden' do
+ expect(response).to have_http_status(403)
+ end
+ end
+ end
+
+ context 'when job does not has artifacts' do
+ it 'responds with not found' do
+ expect(response).to have_http_status(404)
+ end
+ end
+
+ def download_artifact(params = {}, request_headers = headers)
+ params = params.merge(token: token)
+ get api("/jobs/#{job.id}/artifacts"), params, request_headers
+ end
+ end
end
end
end