Reject email attachments of size 0
Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -26,7 +26,8 @@ from .literals import (
|
||||
TEST_EMAIL_ATTACHMENT_AND_INLINE, TEST_EMAIL_BASE64_FILENAME,
|
||||
TEST_EMAIL_BASE64_FILENAME_FROM, TEST_EMAIL_BASE64_FILENAME_SUBJECT,
|
||||
TEST_EMAIL_INLINE_IMAGE, TEST_EMAIL_NO_CONTENT_TYPE,
|
||||
TEST_EMAIL_NO_CONTENT_TYPE_STRING, TEST_WATCHFOLDER_SUBFOLDER
|
||||
TEST_EMAIL_NO_CONTENT_TYPE_STRING, TEST_WATCHFOLDER_SUBFOLDER,
|
||||
TEST_EMAIL_ZERO_LENGTH_ATTACHMENT
|
||||
)
|
||||
|
||||
|
||||
@@ -105,6 +106,17 @@ class EmailFilenameDecodingTestCase(BaseTestCase):
|
||||
TEST_EMAIL_NO_CONTENT_TYPE_STRING in Document.objects.first().open().read()
|
||||
)
|
||||
|
||||
def test_decode_email_zero_length_attachment(self):
|
||||
self._create_email_source()
|
||||
self.source.store_body=False
|
||||
self.source.save()
|
||||
|
||||
EmailBaseModel.process_message(
|
||||
source=self.source, message_text=TEST_EMAIL_ZERO_LENGTH_ATTACHMENT
|
||||
)
|
||||
|
||||
self.assertEqual(Document.objects.count(), 0)
|
||||
|
||||
def test_decode_email_with_inline_image(self):
|
||||
self._create_email_source()
|
||||
EmailBaseModel.process_message(
|
||||
@@ -130,7 +142,6 @@ class EmailFilenameDecodingTestCase(BaseTestCase):
|
||||
self.assertQuerysetEqual(
|
||||
ordered=False, qs=Document.objects.all(), values=(
|
||||
'<Document: test-01.png>', '<Document: email_body.html>',
|
||||
'<Document: test-02.png>'
|
||||
),
|
||||
)
|
||||
|
||||
@@ -175,8 +186,8 @@ class EmailFilenameDecodingTestCase(BaseTestCase):
|
||||
source=self.source, message_text=TEST_EMAIL_ATTACHMENT_AND_INLINE
|
||||
)
|
||||
|
||||
# Only two attachments, no body document
|
||||
self.assertEqual(2, Document.objects.count())
|
||||
# Only one attachment, no body document
|
||||
self.assertEqual(1, Document.objects.count())
|
||||
|
||||
def test_document_upload_with_body(self):
|
||||
self._create_email_source()
|
||||
@@ -189,7 +200,7 @@ class EmailFilenameDecodingTestCase(BaseTestCase):
|
||||
)
|
||||
|
||||
# Only two attachments and a body document
|
||||
self.assertEqual(3, Document.objects.count())
|
||||
self.assertEqual(2, Document.objects.count())
|
||||
|
||||
|
||||
class POP3SourceTestCase(BaseTestCase):
|
||||
|
||||
Reference in New Issue
Block a user