diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/object_storage | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/object_storage')
-rw-r--r-- | spec/lib/object_storage/direct_upload_spec.rb | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb index c3890c72852..1c1455e2456 100644 --- a/spec/lib/object_storage/direct_upload_spec.rb +++ b/spec/lib/object_storage/direct_upload_spec.rb @@ -2,10 +2,11 @@ require 'spec_helper' -describe ObjectStorage::DirectUpload do +RSpec.describe ObjectStorage::DirectUpload do let(:region) { 'us-east-1' } let(:path_style) { false } let(:use_iam_profile) { false } + let(:consolidated_settings) { false } let(:credentials) do { provider: 'AWS', @@ -23,7 +24,7 @@ describe ObjectStorage::DirectUpload do let(:object_name) { 'tmp/uploads/my-file' } let(:maximum_size) { 1.gigabyte } - let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) } + let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size, consolidated_settings: consolidated_settings) } before do Fog.unmock! @@ -60,6 +61,38 @@ describe ObjectStorage::DirectUpload do end end + describe '#get_url' do + subject { described_class.new(credentials, bucket_name, object_name, has_length: true) } + + context 'when AWS is used' do + it 'calls the proper method' do + expect_next_instance_of(::Fog::Storage, credentials) do |connection| + expect(connection).to receive(:get_object_url).once + end + + subject.get_url + end + end + + context 'when Google is used' do + let(:credentials) do + { + provider: 'Google', + google_storage_access_key_id: 'GOOGLE_ACCESS_KEY_ID', + google_storage_secret_access_key: 'GOOGLE_SECRET_ACCESS_KEY' + } + end + + it 'calls the proper method' do + expect_next_instance_of(::Fog::Storage, credentials) do |connection| + expect(connection).to receive(:get_object_https_url).once + end + + subject.get_url + end + end + end + describe '#to_hash' do subject { direct_upload.to_hash } @@ -109,6 +142,14 @@ describe ObjectStorage::DirectUpload do expect(subject[:UseWorkhorseClient]).to eq(use_iam_profile) end end + + context 'when consolidated settings are used' do + let(:consolidated_settings) { true } + + it 'enables the Workhorse client' do + expect(subject[:UseWorkhorseClient]).to be true + end + end end shared_examples 'a valid Google upload' do |