Skip to content

Commit

Permalink
Add specs for file upload with invalid path
Browse files Browse the repository at this point in the history
  • Loading branch information
texpert committed Aug 9, 2024
1 parent 0449d5e commit 279793a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion spec/helpers/uploader_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,21 @@
expect(upload_file(File.open(@path), { dimension: '50x20?' }).keys.include?(:error)).not_to eql(true)
end

it 'upload a local file invalid format' do
describe 'file upload with invalid path' do
it 'upload a local file with invalid path of a path traversal try' do
expect(upload_file(File.open(@path), { folder: '../../config/initializers' }).keys.include?(:error)).to be(true)
end

it 'upload a local file with invalid URI-like path' do
expect(upload_file(File.open(@path), { folder: 'file:///config/initializers' }).keys.include?(:error)).to be(true)
end

it 'upload a local file with an absolute path' do
expect(upload_file(File.open(@path), { folder: '/tmp/config/initializers' }).keys.include?(:error)).to be(true)
end
end

it 'upload a local file with invalid format' do
expect(upload_file(File.open(@path), { formats: 'audio' }).keys.include?(:error)).to be(true)
end

Expand Down

0 comments on commit 279793a

Please sign in to comment.