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 ...@@ -14,7 +14,7 @@ module WorkhorseAuthorization
authorized = uploader_class.workhorse_authorize( authorized = uploader_class.workhorse_authorize(
has_length: false, has_length: false,
maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i) maximum_size: maximum_size.to_i)
render json: authorized render json: authorized
rescue SocketError rescue SocketError
...@@ -33,6 +33,10 @@ module WorkhorseAuthorization ...@@ -33,6 +33,10 @@ module WorkhorseAuthorization
raise NotImplementedError raise NotImplementedError
end end
def maximum_size
raise NotImplementedError
end
def file_extension_whitelist def file_extension_whitelist
ImportExportUploader::EXTENSION_WHITELIST ImportExportUploader::EXTENSION_WHITELIST
end end
......
...@@ -68,4 +68,8 @@ class Import::GitlabGroupsController < ApplicationController ...@@ -68,4 +68,8 @@ class Import::GitlabGroupsController < ApplicationController
def uploader_class def uploader_class
ImportExportUploader ImportExportUploader
end end
def maximum_size
Gitlab::CurrentSettings.max_import_size.megabytes
end
end end
...@@ -49,4 +49,8 @@ class Import::GitlabProjectsController < Import::BaseController ...@@ -49,4 +49,8 @@ class Import::GitlabProjectsController < Import::BaseController
def uploader_class def uploader_class
ImportExportUploader ImportExportUploader
end end
def maximum_size
Gitlab::CurrentSettings.max_import_size.megabytes
end
end end
...@@ -58,6 +58,10 @@ class Projects::RequirementsManagement::RequirementsController < Projects::Appli ...@@ -58,6 +58,10 @@ class Projects::RequirementsManagement::RequirementsController < Projects::Appli
FileUploader FileUploader
end end
def maximum_size
Gitlab::CurrentSettings.max_attachment_size.megabytes
end
def file_extension_whitelist def file_extension_whitelist
EXTENSION_WHITELIST EXTENSION_WHITELIST
end end
......
...@@ -132,6 +132,7 @@ RSpec.describe Projects::RequirementsManagement::RequirementsController do ...@@ -132,6 +132,7 @@ RSpec.describe Projects::RequirementsManagement::RequirementsController do
it_behaves_like 'handle uploads authorize request' do it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { FileUploader } let(:uploader_class) { FileUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_attachment_size.megabytes }
end end
end end
......
...@@ -195,6 +195,7 @@ RSpec.describe Import::GitlabGroupsController do ...@@ -195,6 +195,7 @@ RSpec.describe Import::GitlabGroupsController do
describe 'POST authorize' do describe 'POST authorize' do
it_behaves_like 'handle uploads authorize request' do it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { ImportExportUploader } let(:uploader_class) { ImportExportUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_import_size.megabytes }
subject { post authorize_import_gitlab_group_path, headers: workhorse_headers } subject { post authorize_import_gitlab_group_path, headers: workhorse_headers }
end end
......
...@@ -86,6 +86,7 @@ RSpec.describe Import::GitlabProjectsController do ...@@ -86,6 +86,7 @@ RSpec.describe Import::GitlabProjectsController do
describe 'POST authorize' do describe 'POST authorize' do
it_behaves_like 'handle uploads authorize request' do it_behaves_like 'handle uploads authorize request' do
let(:uploader_class) { ImportExportUploader } let(:uploader_class) { ImportExportUploader }
let(:maximum_size) { Gitlab::CurrentSettings.max_import_size.megabytes }
subject { post authorize_import_gitlab_project_path, headers: workhorse_headers } subject { post authorize_import_gitlab_project_path, headers: workhorse_headers }
end end
......
...@@ -37,6 +37,7 @@ RSpec.shared_examples 'handle uploads authorize request' do ...@@ -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('StoreURL')
expect(json_response['RemoteObject']).to have_key('DeleteURL') expect(json_response['RemoteObject']).to have_key('DeleteURL')
expect(json_response['RemoteObject']).to have_key('MultipartUpload') expect(json_response['RemoteObject']).to have_key('MultipartUpload')
expect(json_response['MaximumSize']).to eq(maximum_size)
end end
end end
...@@ -52,6 +53,7 @@ RSpec.shared_examples 'handle uploads authorize request' do ...@@ -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(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['TempPath']).to eq(uploader_class.workhorse_local_upload_path)
expect(json_response['RemoteObject']).to be_nil expect(json_response['RemoteObject']).to be_nil
expect(json_response['MaximumSize']).to eq(maximum_size)
end end
end 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