Commit c408f973 authored by Stan Hu's avatar Stan Hu

Merge branch '212632-add-LFS-workhorse-upload-path' into 'master'

Add LFS workhorse upload path

Closes #212632

See merge request gitlab-org/gitlab!31794
parents 5803f031 0e945670
---
title: Add LFS workhorse upload path to allowed upload paths
merge_request: 31794
author:
type: fixed
...@@ -30,9 +30,11 @@ describe Gitlab::Middleware::Multipart do ...@@ -30,9 +30,11 @@ describe Gitlab::Middleware::Multipart do
RSpec.shared_examples 'not allowing the multipart upload when package upload path is used' do RSpec.shared_examples 'not allowing the multipart upload when package upload path is used' do
it 'does not allow files to be uploaded' do it 'does not allow files to be uploaded' do
with_tmp_dir('tmp/uploads', storage_path) do |dir, env| with_tmp_dir('tmp/uploads', storage_path) do |dir, env|
# with_tmp_dir set the same workhorse_upload_path for all Uploaders, # with_tmp_dir sets the same workhorse_upload_path for all Uploaders,
# so we have to prevent JobArtifactUploader to allow the tested path # so we have to prevent JobArtifactUploader and LfsObjectUploader to
# allow the tested path
allow(JobArtifactUploader).to receive(:workhorse_upload_path).and_return(Dir.tmpdir) allow(JobArtifactUploader).to receive(:workhorse_upload_path).and_return(Dir.tmpdir)
allow(LfsObjectUploader).to receive(:workhorse_upload_path).and_return(Dir.tmpdir)
status, headers, body = middleware.call(env) status, headers, body = middleware.call(env)
......
...@@ -110,6 +110,7 @@ module Gitlab ...@@ -110,6 +110,7 @@ module Gitlab
::FileUploader.root, ::FileUploader.root,
Gitlab.config.uploads.storage_path, Gitlab.config.uploads.storage_path,
JobArtifactUploader.workhorse_upload_path, JobArtifactUploader.workhorse_upload_path,
LfsObjectUploader.workhorse_upload_path,
File.join(Rails.root, 'public/uploads/tmp') File.join(Rails.root, 'public/uploads/tmp')
] ]
end end
......
...@@ -195,6 +195,17 @@ describe Gitlab::Middleware::Multipart do ...@@ -195,6 +195,17 @@ describe Gitlab::Middleware::Multipart do
end end
end end
it 'allows files in the lfs upload path' do
with_tmp_dir('lfs-objects') do |dir, env|
expect(LfsObjectUploader).to receive(:workhorse_upload_path).and_return(File.join(dir, 'lfs-objects'))
expect(app).to receive(:call) do |env|
expect(get_params(env)['file']).to be_a(::UploadedFile)
end
middleware.call(env)
end
end
it 'allows symlinks for uploads dir' do it 'allows symlinks for uploads dir' do
Tempfile.open('two-levels') do |tempfile| Tempfile.open('two-levels') do |tempfile|
symlinked_dir = '/some/dir/uploads' symlinked_dir = '/some/dir/uploads'
......
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