diff options
author | sunnavy <sunnavy@bestpractical.com> | 2019-12-11 22:16:12 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2021-01-27 00:31:01 +0300 |
commit | 3697842dd86c9eaa5977697d5aebea4a5d81fbaf (patch) | |
tree | e748e8cbdaf16c657b55e6fe714b2075ffb1437f | |
parent | 85a2d919fbf33913f78bd00886cd9ec8399909ea (diff) |
Test treating attached multipart email as files
-rw-r--r-- | t/data/emails/email-file-attachment-2.eml | 67 | ||||
-rw-r--r-- | t/mail/email-file-attachments.t | 19 |
2 files changed, 86 insertions, 0 deletions
diff --git a/t/data/emails/email-file-attachment-2.eml b/t/data/emails/email-file-attachment-2.eml new file mode 100644 index 0000000000..fb58e54431 --- /dev/null +++ b/t/data/emails/email-file-attachment-2.eml @@ -0,0 +1,67 @@ +Return-Path: <user1@example.com> +X-Spam-Flag: NO +X-Spam-Score: -2.449 +X-Spam-Level: +X-Spam-Status: No, score=-2.449 tagged_above=-99.9 required=10 + tests=[AWL=0.250, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, + DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, KHOP_DYNAMIC=0.001, + RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham +X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, + definitions=2017-07-28_05:,, signatures=0 +X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 + clxscore=1034 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 + bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 + engine=8.0.1-1701120000 definitions=main-1707280209 +From: Jim Brandt <user1@example.com> +Content-type: multipart/mixed; + boundary="Apple-Mail=_E5E623A8-7064-4736-9F2E-2A0F35E3635B" +Subject: This is another test +Message-id: <A23A3AC0-D9E3-4965-83DF-F29217AF28F6@mac.com> +Date: Fri, 28 Jul 2017 09:21:48 -0400 +To: rt@example.com +MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\)) +X-Mailer: Apple Mail (2.3124) + + +--Apple-Mail=_E5E623A8-7064-4736-9F2E-2A0F35E3635B +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=us-ascii + +This is a test with a multipart email file attachment. +--Apple-Mail=_E5E623A8-7064-4736-9F2E-2A0F35E3635B +Content-Type: message/rfc822; + charset="ascii"; + name="test-email-2.eml" +Content-Disposition: attachment; filename="test-email-2.eml" +X-RT-Original-Encoding: ascii +Content-Length: 0 + +MIME-Version: 1.0 +To: root@example.com +Date: Thu, 5 Dec 2019 06:12:57 +0000 (UTC) +Content-Type: multipart/alternative; + boundary="===============4845098068763498141==" +Reply-To: root@example.com +Content-Length: 0 + +This is a multi-part message in MIME format... + +--===============4845098068763498141== +Content-Transfer-Encoding: quoted-printable +X-RT-Original-Encoding: utf-8 +Content-Type: text/plain; charset="utf-8" +Content-Length: 11 + +plain text + +--===============4845098068763498141== +X-RT-Original-Encoding: utf-8 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; charset="utf-8" +Content-Length: 18 + +<p>plain text</p> + +--===============4845098068763498141==-- +--Apple-Mail=_E5E623A8-7064-4736-9F2E-2A0F35E3635B-- diff --git a/t/mail/email-file-attachments.t b/t/mail/email-file-attachments.t index 265424e2ba..2580d4355d 100644 --- a/t/mail/email-file-attachments.t +++ b/t/mail/email-file-attachments.t @@ -55,4 +55,23 @@ diag "Process email with an email file attached"; is( $attachment->Filename, 'test-email.eml', 'Got a filename for the attached email file' ); } +diag "Process email with a multipart email file attached"; +{ + my ($ticket) = mail_in_ticket('email-file-attachment-2.eml'); + like( first_txn($ticket)->Content , qr/This is a test with a multipart email file attachment/, "Parsed the email body"); + is( count_attachs($ticket), 3, + "Has three attachments, presumably multipart/mixed, text-plain, message"); + + my $attachments = $ticket->Transactions->First->Attachments; + + my $attachment = $attachments->Next; + is( $attachment->Subject, 'This is another test', 'Subject is correct' ); + + $attachment = $attachments->Next; + is( $attachment->ContentType, 'text/plain', 'Got the first part of the main email' ); + + $attachment = $attachments->Next; + is( $attachment->Filename, 'test-email-2.eml', 'Got a filename for the attached email file' ); +} + done_testing(); |