diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:22:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:22:29 +0300 |
commit | 61d81025139e2e6b3706c05eee4e60ff13417323 (patch) | |
tree | 517dc8ebc4a9f8d74fd77eb7bd6d5466d5184d94 /spec/services/projects | |
parent | 25fc1060affe576fd7c2f8aad586c5109c51cf7e (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-ee
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb | 13 | ||||
-rw-r--r-- | spec/services/projects/lfs_pointers/lfs_download_service_spec.rb | 19 |
2 files changed, 26 insertions, 6 deletions
diff --git a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb index 66a450bd734..047ebe65dff 100644 --- a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb +++ b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::LfsPointers::LfsDownloadLinkListService do let(:lfs_endpoint) { "#{import_url}/info/lfs/objects/batch" } let!(:project) { create(:project, import_url: import_url) } let(:new_oids) { { 'oid1' => 123, 'oid2' => 125 } } + let(:headers) { { 'X-Some-Header' => '456' }} let(:remote_uri) { URI.parse(lfs_endpoint) } let(:request_object) { HTTParty::Request.new(Net::HTTP::Post, '/') } @@ -18,7 +19,7 @@ RSpec.describe Projects::LfsPointers::LfsDownloadLinkListService do { 'oid' => oid, 'size' => size, 'actions' => { - 'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}" } + 'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}", header: headers } } } end @@ -48,12 +49,20 @@ RSpec.describe Projects::LfsPointers::LfsDownloadLinkListService do end describe '#execute' do + let(:download_objects) { subject.execute(new_oids) } + it 'retrieves each download link of every non existent lfs object' do - subject.execute(new_oids).each do |lfs_download_object| + download_objects.each do |lfs_download_object| expect(lfs_download_object.link).to eq "#{import_url}/gitlab-lfs/objects/#{lfs_download_object.oid}" end end + it 'stores headers' do + download_objects.each do |lfs_download_object| + expect(lfs_download_object.headers).to eq(headers) + end + end + context 'when lfs objects size is larger than the batch size' do def stub_successful_request(batch) response = custom_response(success_net_response, objects_response(batch)) diff --git a/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb index 1b829df6e6a..1fb6dae0c08 100644 --- a/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb +++ b/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb @@ -155,13 +155,24 @@ RSpec.describe Projects::LfsPointers::LfsDownloadService do context 'when credentials present' do let(:download_link_with_credentials) { "http://user:password@gitlab.com/#{oid}" } let(:lfs_object) { LfsDownloadObject.new(oid: oid, size: size, link: download_link_with_credentials) } + let!(:request_stub) { stub_full_request(download_link).with(headers: { 'Authorization' => 'Basic dXNlcjpwYXNzd29yZA==' }).to_return(body: lfs_content) } - before do - stub_full_request(download_link).with(headers: { 'Authorization' => 'Basic dXNlcjpwYXNzd29yZA==' }).to_return(body: lfs_content) + it 'the request adds authorization headers' do + subject.execute + + expect(request_stub).to have_been_requested end - it 'the request adds authorization headers' do - subject + context 'when Authorization header is present' do + let(:auth_header) { { 'Authorization' => 'Basic 12345' } } + let(:lfs_object) { LfsDownloadObject.new(oid: oid, size: size, link: download_link_with_credentials, headers: auth_header) } + let!(:request_stub) { stub_full_request(download_link).with(headers: auth_header).to_return(body: lfs_content) } + + it 'request uses the header auth' do + subject.execute + + expect(request_stub).to have_been_requested + end end end |