diff options
author | Micaël Bergeron <mbergeron@gitlab.com> | 2018-03-09 10:09:00 -0500 |
---|---|---|
committer | Micaël Bergeron <mbergeron@gitlab.com> | 2018-03-22 08:49:04 -0400 |
commit | 44f37504fb229ab78606a5fd11f75316ebc2667b (patch) | |
tree | 084a49e025463f67942c85c3f99edd4a827e1a89 /spec | |
parent | e1f076ecb5c0e92e62ee628b6c18bc8869812b2e (diff) | |
download | gitlab-ce-44f37504fb229ab78606a5fd11f75316ebc2667b.tar.gz |
Backport ee-40781-os-to-ce
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/concerns/send_file_upload_spec.rb | 8 | ||||
-rw-r--r-- | spec/features/projects/import_export/test_project_export.tar.gz | bin | 343092 -> 341299 bytes | |||
-rw-r--r-- | spec/lib/gitlab/ci/trace/http_io_spec.rb | 26 | ||||
-rw-r--r-- | spec/requests/api/jobs_spec.rb | 47 |
4 files changed, 52 insertions, 29 deletions
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb index da4e955f6a3..f4c99ea4064 100644 --- a/spec/controllers/concerns/send_file_upload_spec.rb +++ b/spec/controllers/concerns/send_file_upload_spec.rb @@ -64,10 +64,12 @@ describe SendFileUpload do end it 'sends a file' do - subject + headers = double + expect(headers).to receive(:store).with(Gitlab::Workhorse::SEND_DATA_HEADER, /^send-url:/) + expect(controller).to receive(:headers) { headers } + expect(controller).to receive(:head).with(:ok) - is_expected.to start_with(Gitlab::Workhorse::SEND_DATA_HEADER) - is_expected.to end_with(/^send-url:/) + subject end end diff --git a/spec/features/projects/import_export/test_project_export.tar.gz b/spec/features/projects/import_export/test_project_export.tar.gz Binary files differindex 0cc68aff494..ecb7651acad 100644 --- a/spec/features/projects/import_export/test_project_export.tar.gz +++ b/spec/features/projects/import_export/test_project_export.tar.gz diff --git a/spec/lib/gitlab/ci/trace/http_io_spec.rb b/spec/lib/gitlab/ci/trace/http_io_spec.rb index b839ef7ce36..5474e2f518c 100644 --- a/spec/lib/gitlab/ci/trace/http_io_spec.rb +++ b/spec/lib/gitlab/ci/trace/http_io_spec.rb @@ -7,26 +7,6 @@ describe Gitlab::Ci::Trace::HttpIO do let(:url) { remote_trace_url } let(:size) { remote_trace_size } - describe 'Interchangeability between IO and HttpIO' do - EXCEPT_METHODS = %i[read_nonblock raw raw! cooked cooked! getch echo= echo? - winsize winsize= iflush oflush ioflush beep goto cursor cursor= pressed? - getpass write_nonblock stat pathconf wait_readable wait_writable getbyte << - wait lines bytes chars codepoints getc readpartial set_encoding printf print - putc puts readlines gets each each_byte each_char each_codepoint to_io reopen - syswrite to_i fileno sysread fdatasync fsync sync= sync lineno= lineno readchar - ungetbyte readbyte ungetc nonblock= nread rewind pos= eof close_on_exec? - close_on_exec= closed? close_read close_write isatty tty? binmode? sysseek - advise ioctl fcntl pid external_encoding internal_encoding autoclose? autoclose= - posix_fileno nonblock? ready? noecho nonblock].freeze - - it 'HttpIO covers core interfaces in IO' do - expected_interfaces = ::IO.instance_methods(false) - expected_interfaces -= EXCEPT_METHODS - - expect(expected_interfaces - described_class.instance_methods).to be_empty - end - end - describe '#close' do subject { http_io.close } @@ -48,6 +28,12 @@ describe Gitlab::Ci::Trace::HttpIO do describe '#path' do subject { http_io.path } + it { is_expected.to be_nil } + end + + describe '#url' do + subject { http_io.url } + it { is_expected.to eq(url) } end diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 62ed9fd00a1..81335e72350 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -21,6 +21,7 @@ describe API::Jobs do let(:guest) { create(:project_member, :guest, project: project).user } before do + stub_licensed_features(cross_project_pipelines: true) project.add_developer(user) end @@ -316,11 +317,6 @@ describe API::Jobs do end end - before do - stub_artifacts_object_storage - get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user) - end - context 'normal authentication' do context 'job with artifacts' do context 'when artifacts are stored locally' do @@ -344,8 +340,10 @@ describe API::Jobs do end context 'when artifacts are stored remotely' do + let(:proxy_download) { false } + before do - stub_artifacts_object_storage + stub_artifacts_object_storage(proxy_download: proxy_download) end let(:job) { create(:ci_build, pipeline: pipeline) } @@ -357,6 +355,20 @@ describe API::Jobs do get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user) end + context 'when proxy download is enabled' do + let(:proxy_download) { true } + + it 'responds with the workhorse send-url' do + expect(response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("send-url:") + end + end + + context 'when proxy download is disabled' do + it 'returns location redirect' do + expect(response).to have_gitlab_http_status(302) + end + end + context 'authorized user' do it 'returns the file remote URL' do expect(response).to redirect_to(artifact.file.url) @@ -495,6 +507,29 @@ describe API::Jobs do it_behaves_like 'a valid file' end + + context 'when using job_token to authenticate' do + before do + pipeline.reload + pipeline.update(ref: 'master', + sha: project.commit('master').sha) + + get api("/projects/#{project.id}/jobs/artifacts/master/download"), job: job.name, job_token: job.token + end + + context 'when user is reporter' do + it_behaves_like 'a valid file' + end + + context 'when user is admin, but not member' do + let(:api_user) { create(:admin) } + let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) } + + it 'does not allow to see that artfiact is present' do + expect(response).to have_gitlab_http_status(404) + end + end + end end end |