2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'Direct upload support' do
|
2018-11-08 19:23:39 +05:30
|
|
|
subject do
|
|
|
|
load Rails.root.join('config/initializers/direct_upload_support.rb')
|
|
|
|
end
|
|
|
|
|
|
|
|
where(:config_name) do
|
2020-10-24 23:57:45 +05:30
|
|
|
%w(artifacts lfs uploads)
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
let(:connection) do
|
|
|
|
{ provider: provider }
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:object_store) do
|
|
|
|
{
|
|
|
|
enabled: enabled,
|
|
|
|
direct_upload: direct_upload,
|
|
|
|
connection: connection
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config).to receive_messages(to_settings(config_name => {
|
|
|
|
object_store: object_store
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when object storage is enabled' do
|
|
|
|
let(:enabled) { true }
|
|
|
|
|
|
|
|
context 'when direct upload is enabled' do
|
|
|
|
let(:direct_upload) { true }
|
|
|
|
|
|
|
|
context 'when provider is AWS' do
|
|
|
|
let(:provider) { 'AWS' }
|
|
|
|
|
|
|
|
it 'succeeds' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when provider is Google' do
|
|
|
|
let(:provider) { 'Google' }
|
|
|
|
|
|
|
|
it 'succeeds' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
context 'when provider is AzureRM' do
|
|
|
|
let(:provider) { 'AzureRM' }
|
|
|
|
|
|
|
|
it 'succeeds' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
context 'when connection is empty' do
|
|
|
|
let(:connection) { nil }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
2020-10-24 23:57:45 +05:30
|
|
|
expect { subject }.to raise_error "No provider configured for '#{config_name}'. Only Google, AWS, and AzureRM are supported."
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when other provider is used' do
|
|
|
|
let(:provider) { 'Rackspace' }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect { subject }.to raise_error /Object storage provider '#{provider}' is not supported when 'direct_upload' is used for '#{config_name}'/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when connection is omitted' do
|
|
|
|
let(:object_store) do
|
|
|
|
{
|
|
|
|
enabled: enabled,
|
|
|
|
direct_upload: direct_upload
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'raises an error' do
|
|
|
|
expect { subject }.to raise_error /the 'connection' section is missing/
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when direct upload is disabled' do
|
|
|
|
let(:direct_upload) { false }
|
|
|
|
let(:provider) { 'AWS' }
|
|
|
|
|
|
|
|
it 'succeeds' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when object storage is disabled' do
|
|
|
|
let(:enabled) { false }
|
|
|
|
let(:direct_upload) { false }
|
|
|
|
let(:provider) { 'Rackspace' }
|
|
|
|
|
|
|
|
it 'succeeds' do
|
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|