Commit 7e14b2fe authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-fix-import-artifact-limits' into 'master'

Fix import upload limits

See merge request gitlab-org/gitlab!49420
parents 05e6e622 a47d40d6
......@@ -14,7 +14,7 @@ module WorkhorseAuthorization
authorized = uploader_class.workhorse_authorize(
has_length: false,
maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i)
maximum_size: maximum_size.to_i)
render json: authorized
rescue SocketError
......@@ -33,6 +33,10 @@ module WorkhorseAuthorization
raise NotImplementedError
end
def maximum_size
raise NotImplementedError
end
def file_extension_whitelist
ImportExportUploader::EXTENSION_WHITELIST
end
......
......@@ -68,4 +68,8 @@ class Import::GitlabGroupsController < ApplicationController
def uploader_class
ImportExportUploader
end
def maximum_size
Gitlab::CurrentSettings.max_import_size.megabytes
end
end
......@@ -49,4 +49,8 @@ class Import::GitlabProjectsController < Import::BaseController
def uploader_class
ImportExportUploader
end
def maximum_size
Gitlab::CurrentSettings.max_import_size.megabytes
end
end
......@@ -58,6 +58,10 @@ class Projects::RequirementsManagement::RequirementsController < Projects::Appli
FileUploader
end
def maximum_size
Gitlab::CurrentSettings.max_attachment_size.megabytes
end
def file_extension_whitelist
EXTENSION_WHITELIST
end
......
......@@ -132,6 +132,7 @@ RSpec.describe Projects::RequirementsManagement::RequirementsController do
it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { FileUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_attachment_size.megabytes }
end
end
......
......@@ -195,6 +195,7 @@ RSpec.describe Import::GitlabGroupsController do
describe 'POST authorize' do
it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { ImportExportUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_import_size.megabytes }
subject { post authorize_import_gitlab_group_path, headers: workhorse_headers }
end
......
......@@ -86,6 +86,7 @@ RSpec.describe Import::GitlabProjectsController do
describe 'POST authorize' do
it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { ImportExportUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_import_size.megabytes }
subject { post authorize_import_gitlab_project_path, headers: workhorse_headers }
end
......
......@@ -37,6 +37,7 @@ RSpec.shared_examples 'handle uploads authorize request' do
expect(json_response['RemoteObject']).to have_key('StoreURL')
expect(json_response['RemoteObject']).to have_key('DeleteURL')
expect(json_response['RemoteObject']).to have_key('MultipartUpload')
expect(json_response['MaximumSize']).to eq(maximum_size)
end
end
......@@ -52,6 +53,7 @@ RSpec.shared_examples 'handle uploads authorize request' do
expect(response.media_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response['TempPath']).to eq(uploader_class.workhorse_local_upload_path)
expect(json_response['RemoteObject']).to be_nil
expect(json_response['MaximumSize']).to eq(maximum_size)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment