Commit 0e945670 authored by Jennifer Louie's avatar Jennifer Louie Committed by Stan Hu

Fix the failing spec example

Prevent LfsObjectUploader from allowing the tested path
parent 4e5e26a0
---
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
RSpec.shared_examples 'not allowing the multipart upload when package upload path is used' do
it 'does not allow files to be uploaded' do
with_tmp_dir('tmp/uploads', storage_path) do |dir, env|
# with_tmp_dir set the same workhorse_upload_path for all Uploaders,
# so we have to prevent JobArtifactUploader to allow the tested path
# with_tmp_dir sets the same workhorse_upload_path for all Uploaders,
# 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(LfsObjectUploader).to receive(:workhorse_upload_path).and_return(Dir.tmpdir)
status, headers, body = middleware.call(env)
......
......@@ -110,6 +110,7 @@ module Gitlab
::FileUploader.root,
Gitlab.config.uploads.storage_path,
JobArtifactUploader.workhorse_upload_path,
LfsObjectUploader.workhorse_upload_path,
File.join(Rails.root, 'public/uploads/tmp')
]
end
......
......@@ -195,6 +195,17 @@ describe Gitlab::Middleware::Multipart do
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
Tempfile.open('two-levels') do |tempfile|
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