summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-02-06 15:39:20 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-28 20:58:56 +0100
commitb14c484bb1d174c7c355de2258be1a4414b2cf78 (patch)
treee7cf84f28c964580b74f791d235987948f3cc4a8 /spec
parenta7dae52e9d27adde427ef8aa066c0761071a3cd9 (diff)
downloadgitlab-ce-b14c484bb1d174c7c355de2258be1a4414b2cf78.tar.gz
Merge branch 'use-send-url-for-incompatible-runners' into 'master'
Support SendURL for performing indirect download of artifacts if clients does… See merge request gitlab-org/gitlab-ee!4401
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb17
-rw-r--r--spec/requests/api/runner_spec.rb33
2 files changed, 46 insertions, 4 deletions
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index 249c77dc636..0b34d71bfb2 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -451,4 +451,21 @@ describe Gitlab::Workhorse do
end
end
end
+
+ describe '.send_url' do
+ let(:url) { 'http://example.com' }
+
+ subject { described_class.send_url(url) }
+
+ it 'sets the header correctly' do
+ key, command, params = decode_workhorse_header(subject)
+
+ expect(key).to eq("Gitlab-Workhorse-Send-Data")
+ expect(command).to eq("send-url")
+ expect(params).to eq({
+ 'URL' => url,
+ 'AllowRedirects' => false
+ }.deep_stringify_keys)
+ end
+ end
end
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 8086b91a488..c6366ffec62 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -1157,8 +1157,6 @@ describe API::Runner do
before do
create(:ci_job_artifact, :archive, file_store: store, job: job)
-
- download_artifact
end
context 'when using job token' do
@@ -1168,6 +1166,10 @@ describe API::Runner do
'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
end
+ before do
+ download_artifact
+ end
+
it 'download artifacts' do
expect(response).to have_http_status(200)
expect(response.headers).to include download_headers
@@ -1178,8 +1180,27 @@ describe API::Runner do
let(:store) { JobArtifactUploader::Store::REMOTE }
let!(:job) { create(:ci_build) }
- it 'download artifacts' do
- expect(response).to have_http_status(302)
+ context 'when proxy download is being used' do
+ before do
+ download_artifact(direct_download: false)
+ end
+
+ it 'uses workhorse send-url' do
+ expect(response).to have_gitlab_http_status(200)
+ expect(response.headers).to include(
+ 'Gitlab-Workhorse-Send-Data' => /send-url:/)
+ end
+ end
+
+ context 'when direct download is being used' do
+ before do
+ download_artifact(direct_download: true)
+ end
+
+ it 'receive redirect for downloading artifacts' do
+ expect(response).to have_gitlab_http_status(302)
+ expect(response.headers).to include('Location')
+ end
end
end
end
@@ -1187,6 +1208,10 @@ describe API::Runner do
context 'when using runnners token' do
let(:token) { job.project.runners_token }
+ before do
+ download_artifact
+ end
+
it 'responds with forbidden' do
expect(response).to have_gitlab_http_status(403)
end