[Rt-commit] rt branch, 4.0/rfc822-attachment, updated. rt-4.0.0-208-g7854511

? sunnavy sunnavy at bestpractical.com
Tue May 10 01:06:18 EDT 2011


The branch, 4.0/rfc822-attachment has been updated
       via  7854511b23e35d28d118a59b7c3d8985a76cd607 (commit)
      from  fb3da9fe4760193e0e227a01da43c9cfafd19e50 (commit)

Summary of changes:
 t/mail/rfc822-attachment.t |   79 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 t/mail/rfc822-attachment.t

- Log -----------------------------------------------------------------
commit 7854511b23e35d28d118a59b7c3d8985a76cd607
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 10 13:03:47 2011 +0800

    test rfc822 attachment
    
    currently we don't handle att of att of mail, so what we got from
    txn->ContentAsMIME is a top entity with a list of flattened att, all the
    multiple/... parts from original mail are skipped

diff --git a/t/mail/rfc822-attachment.t b/t/mail/rfc822-attachment.t
new file mode 100644
index 0000000..ad3d767
--- /dev/null
+++ b/t/mail/rfc822-attachment.t
@@ -0,0 +1,79 @@
+use strict;
+use warnings;
+
+use RT::Test;
+my ($baseurl, $m) = RT::Test->started_ok;
+
+use MIME::Entity;
+
+diag "simple rfc822 attachment";
+{
+
+    my $top = MIME::Entity->build(
+        From    => 'root at localhost',
+        To      => 'rt at localhost',
+        Subject => 'this is top',
+        Data    => ['top mail'],
+    );
+
+    my $rfc822 = MIME::Entity->build(
+        From    => 'foo at localhost',
+        To      => 'bar at localhost',
+        Subject => 'rfc822',
+        Data    => ['rfc822 attachment'],
+    );
+
+    $top->attach(
+        Data => $rfc822->stringify,
+        Type => 'message/rfc822',
+    );
+    like( $top->stringify, qr/foo\@localhost/,
+        'original mail has rfc822 att header' );
+
+    test_mail( $top );
+}
+
+diag "multipart rfc822 attachment";
+{
+
+    my $top = MIME::Entity->build(
+        From    => 'root at localhost',
+        To      => 'rt at localhost',
+        Subject => 'this is top',
+        Data    => ['top mail'],
+    );
+
+    my $rfc822 = MIME::Entity->build(
+        From    => 'foo at localhost',
+        To      => 'bar at localhost',
+        Subject => 'rfc822',
+        Data    => ['rfc822 attachment'],
+    );
+
+    $rfc822->attach(
+        Data => 'attachment of rfc822 attachment',
+        Type => 'text/plain',
+    );
+
+    $top->attach(
+        Data => $rfc822->stringify,
+        Type => 'message/rfc822',
+    );
+    like( $top->stringify, qr/foo\@localhost/,
+        'original mail has rfc822 att header' );
+
+    test_mail( $top );
+}
+
+sub test_mail {
+    my $entity = shift;
+    my ( $status, $id ) = RT::Test->send_via_mailgate($entity);
+    is( $status >> 8, 0, "The mail gateway exited normally" );
+    ok( $id, "created ticket" );
+    my $ticket = RT::Test->last_ticket;
+
+    my $txn = $ticket->Transactions->First;
+    like( $txn->ContentAsMIME->stringify,
+        qr/foo\@localhost/, 'txn content has rfc822 att header' );
+
+}

-----------------------------------------------------------------------


More information about the Rt-commit mailing list