Skip to content

Commit

Permalink
Add test that binary uploads fail by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 19, 2024
1 parent abc251e commit 862bd1b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,21 @@ def test_filer_upload_binary_data(self, extra_headers={}):
self.assertEqual(stored_file.original_filename, self.binary_name)
self.assertEqual(stored_file.mime_type, 'application/octet-stream')

def test_filer_upload_binary_data_fails_by_default(self, extra_headers={}):
self.assertEqual(File.objects.count(), 0)
with open(self.binary_filename, 'rb') as fh:
file_obj = django.core.files.File(fh)
url = reverse('admin:filer-ajax_upload')
post_data = {
'Filename': self.binary_name,
'Filedata': file_obj,
'jsessionid': self.client.session.session_key
}
self.client.post(url, post_data, **extra_headers)

self.assertEqual(Image.objects.count(), 0)
self.assertEqual(File.objects.count(), 0)

def test_filer_ajax_upload_file(self):
self.assertEqual(Image.objects.count(), 0)
folder = Folder.objects.create(name='foo')
Expand Down

0 comments on commit 862bd1b

Please sign in to comment.