Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-12-05 17:31:33 +0300
committerKamil TrzciƄski <ayufan@ayufan.eu>2018-02-28 22:44:09 +0300
commit6ca02a41500790b3e9061dd8836540955b9aaf7c (patch)
tree5c66c4826cafa2657fe25d85eb9e189b5f290f32 /spec/requests/api/jobs_spec.rb
parentec72abf53fd82ca3e7f126536a83b27b368696ec (diff)
Merge branch 'zj-multiple-artifacts-ee' into 'master'
Multiple artifacts ee See merge request gitlab-org/gitlab-ee!3276
Diffstat (limited to 'spec/requests/api/jobs_spec.rb')
-rw-r--r--spec/requests/api/jobs_spec.rb61
1 files changed, 51 insertions, 10 deletions
diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb
index a435945fea2..9ebf5bf7e97 100644
--- a/spec/requests/api/jobs_spec.rb
+++ b/spec/requests/api/jobs_spec.rb
@@ -288,14 +288,21 @@ describe API::Jobs do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
- context 'job with artifacts' do
- context 'when artifacts are stored locally' do
- let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
+ context 'normal authentication' do
+ before do
+ stub_artifacts_object_storage
+ end
- context 'authorized user' do
- let(:download_headers) do
- { 'Content-Transfer-Encoding' => 'binary',
- 'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
+ context 'job with artifacts' do
+ context 'when artifacts are stored locally' do
+ let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
+
+ before do
+ get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
+ end
+
+ context 'authorized user' do
+ it_behaves_like 'downloads artifact'
end
it 'returns specific job artifacts' do
@@ -305,13 +312,40 @@ describe API::Jobs do
end
end
- context 'unauthorized user' do
- let(:api_user) { nil }
+ context 'when artifacts are stored remotely' do
+ let(:job) { create(:ci_build, pipeline: pipeline) }
+ let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
+
+ before do
+ job.reload
+
+ get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
+ end
it 'does not return specific job artifacts' do
expect(response).to have_http_status(401)
end
end
+
+ it 'does not return job artifacts if not uploaded' do
+ get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+ end
+
+ context 'authorized by job_token' do
+ let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
+
+ before do
+ get api("/projects/#{project.id}/jobs/#{job.id}/artifacts"), job_token: job.token
+ end
+
+ context 'user is developer' do
+ let(:api_user) { user }
+
+ it_behaves_like 'downloads artifact'
end
context 'when artifacts are stored remotely' do
@@ -402,7 +436,14 @@ describe API::Jobs do
end
context 'when artifacts are stored remotely' do
- let(:job) { create(:ci_build, :artifacts, :remote_store, pipeline: pipeline) }
+ let(:job) { create(:ci_build, pipeline: pipeline, user: api_user) }
+ let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
+
+ before do
+ job.reload
+
+ get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
+ end
it 'returns location redirect' do
expect(response).to have_http_status(302)