summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicaël Bergeron <mbergeron@gitlab.com>2018-02-22 10:46:13 -0500
committerMicaël Bergeron <mbergeron@gitlab.com>2018-02-22 10:46:13 -0500
commitcccec27dfa45d0b50d2500b9feba15d121358bfe (patch)
treedecf3a5464e7bfeaedf0a218e06b5e3589322930
parent5f173b68fa0535e347299933cf40a71b9194980e (diff)
downloadgitlab-ce-cccec27dfa45d0b50d2500b9feba15d121358bfe.tar.gz
remove the license check
-rw-r--r--app/controllers/concerns/send_file_upload.rb14
-rw-r--r--app/uploaders/object_storage.rb12
-rw-r--r--spec/requests/lfs_http_spec.rb42
-rw-r--r--spec/support/stub_object_storage.rb4
-rw-r--r--spec/uploaders/lfs_object_uploader_spec.rb22
5 files changed, 15 insertions, 79 deletions
diff --git a/app/controllers/concerns/send_file_upload.rb b/app/controllers/concerns/send_file_upload.rb
new file mode 100644
index 00000000000..d4de4cf1fda
--- /dev/null
+++ b/app/controllers/concerns/send_file_upload.rb
@@ -0,0 +1,14 @@
+module SendFileUpload
+ def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil)
+ if attachment
+ redirect_params[:query] = { "response-content-disposition" => "attachment;filename=#{attachment.inspect}" }
+ send_params.merge!(filename: attachment, disposition: 'attachment')
+ end
+
+ if file_upload.file_storage?
+ send_file file_upload.path, send_params
+ else
+ redirect_to file_upload.url(**redirect_params)
+ end
+ end
+end
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index 95f54b14d04..43d881e5aba 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -105,7 +105,6 @@ module ObjectStorage
included do |base|
base.include(ObjectStorage)
- before :store, :verify_license!
after :migrate, :delete_migrated_file
end
@@ -130,10 +129,6 @@ module ObjectStorage
object_store_options.remote_directory
end
- def licensed?
- License.feature_available?(:object_storage)
- end
-
def serialization_column(model_class, mount_point)
model_class.uploader_options.dig(mount_point, :mount_on) || mount_point
end
@@ -248,12 +243,6 @@ module ObjectStorage
migrated_file.delete if exists?
end
- def verify_license!(_file)
- return if file_storage?
-
- raise(ObjectStorageUnavailable, 'Object Storage feature is missing') unless self.class.licensed?
- end
-
def exists?
file.present?
end
@@ -274,7 +263,6 @@ module ObjectStorage
def schedule_background_upload?
self.class.object_store_enabled? &&
self.class.background_upload_enabled? &&
- self.class.licensed? &&
self.file_storage?
end
diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb
index da7dd936a76..0ddbddb112c 100644
--- a/spec/requests/lfs_http_spec.rb
+++ b/spec/requests/lfs_http_spec.rb
@@ -683,34 +683,6 @@ describe 'Git LFS API and storage' do
expect(json_response['objects'].first['actions']['upload']['href']).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}.git/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
expect(json_response['objects'].first['actions']['upload']['header']).to eq('Authorization' => authorization)
end
-
- ## EE-specific context
- context 'and project is above the limit' do
- let(:update_lfs_permissions) do
- allow_any_instance_of(EE::Project).to receive_messages(
- repository_and_lfs_size: 100.megabytes,
- actual_size_limit: 99.megabytes)
- end
-
- it 'responds with status 406' do
- expect(response).to have_gitlab_http_status(406)
- expect(json_response['message']).to eql('Your push has been rejected, because this repository has exceeded its size limit of 99 MB by 1 MB. Please contact your GitLab administrator for more information.')
- end
- end
-
- context 'and project will go over the limit' do
- let(:update_lfs_permissions) do
- allow_any_instance_of(EE::Project).to receive_messages(
- repository_and_lfs_size: 200.megabytes,
- actual_size_limit: 300.megabytes)
- end
-
- it 'responds with status 406' do
- expect(response).to have_gitlab_http_status(406)
- expect(json_response['documentation_url']).to include('/help')
- expect(json_response['message']).to eql('Your push has been rejected, because this repository has exceeded its size limit of 300 MB by 50 MB. Please contact your GitLab administrator for more information.')
- end
- end
end
describe 'when request is authenticated' do
@@ -1049,20 +1021,6 @@ describe 'Git LFS API and storage' do
end
end
- context 'and project has limit enabled but will stay under the limit' do
- before do
- allow_any_instance_of(EE::Project).to receive_messages(
- actual_size_limit: 200,
- size_limit_enabled?: true)
-
- put_finalize
- end
-
- it 'responds with status 200' do
- expect(response).to have_gitlab_http_status(200)
- end
- end
-
context 'invalid tempfiles' do
it 'rejects slashes in the tempfile name (path traversal' do
put_finalize('foo/bar')
diff --git a/spec/support/stub_object_storage.rb b/spec/support/stub_object_storage.rb
index 93477e513f2..69c59fb0015 100644
--- a/spec/support/stub_object_storage.rb
+++ b/spec/support/stub_object_storage.rb
@@ -1,12 +1,10 @@
module StubConfiguration
- def stub_object_storage_uploader(config:, uploader:, remote_directory:, enabled: true, licensed: true, background_upload: false)
+ def stub_object_storage_uploader(config:, uploader:, remote_directory:, enabled: true, background_upload: false)
Fog.mock!
allow(config).to receive(:enabled) { enabled }
allow(config).to receive(:background_upload) { background_upload }
- stub_licensed_features(object_storage: licensed) unless licensed == :skip
-
return unless enabled
::Fog::Storage.new(uploader.object_store_credentials).tap do |connection|
diff --git a/spec/uploaders/lfs_object_uploader_spec.rb b/spec/uploaders/lfs_object_uploader_spec.rb
index fbb4a188646..a2fb3886610 100644
--- a/spec/uploaders/lfs_object_uploader_spec.rb
+++ b/spec/uploaders/lfs_object_uploader_spec.rb
@@ -43,18 +43,6 @@ describe LfsObjectUploader do
lfs_object
end
end
-
- context 'with object storage unlicenced' do
- before do
- stub_lfs_object_storage(licensed: false)
- end
-
- it 'is skipped' do
- expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
-
- lfs_object
- end
- end
end
describe 'remote file' do
@@ -75,16 +63,6 @@ describe LfsObjectUploader do
expect(lfs_object.file.path).not_to be_blank
end
end
-
- context 'with object storage unlicenced' do
- before do
- stub_lfs_object_storage(licensed: false)
- end
-
- it 'can not store file remotely' do
- expect { store_file(lfs_object) }.to raise_error('Object Storage feature is missing')
- end
- end
end
def store_file(lfs_object)