[Rt-commit] r8475 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: .

sartak at bestpractical.com sartak at bestpractical.com
Thu Aug 9 12:07:38 EDT 2007


Author: sartak
Date: Thu Aug  9 12:07:38 2007
New Revision: 8475

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/   (props changed)
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gnupg-realmail.t

Log:
 r37127 at gorgoroth:  sartak | 2007-08-08 14:40:36 -0400
 Various gnupg-realmail.t changes


Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gnupg-realmail.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gnupg-realmail.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gnupg-realmail.t	Thu Aug  9 12:07:38 2007
@@ -8,6 +8,8 @@
 use String::ShellQuote 'shell_quote';
 use IPC::Run3 'run3';
 
+require "lib/t/utils.pl";
+
 my $homedir = File::Spec->catdir( getcwd(), qw(lib t data crypt-gnupg) );
 
 RT->Config->Set( LogToScreen => 'debug' );
@@ -25,14 +27,14 @@
 ok($user->Load('root'), "Loaded user 'root'");
 $user->SetEmailAddress('recipient at example.com');
 
-my $id = 0;
+my $eid = 0;
 for my $usage (qw/signed encrypted signed&encrypted/)
 {
     for my $format (qw/MIME inline/)
     {
         for my $attachment (qw/plain text-attachment binary-attachment/)
         {
-            my $ok = email_ok(++$id, $usage, $format, $attachment);
+            my $ok = email_ok(++$eid, $usage, $format, $attachment);
             ok($ok, "$usage, $attachment email with $format key");
         }
     }
@@ -40,11 +42,11 @@
 
 sub get_contents
 {
-    my $id = shift;
+    my $eid = shift;
 
-    my $file = glob("lib/t/data/mail/$id-*");
+    my $file = glob("lib/t/data/mail/$eid-*");
     defined $file
-        or do { diag "Unable to find lib/t/data/mail/$id-*"; return };
+        or do { diag "Unable to find lib/t/data/mail/$eid-*"; return };
 
     open my $mailhandle, '<', $file
         or do { diag "Unable to read $file: $!"; return };
@@ -56,23 +58,22 @@
 
 sub email_ok
 {
-    my ($id, $usage, $format, $attachment) = @_;
+    my ($eid, $usage, $format, $attachment) = @_;
 
-    my $mail = get_contents($id)
-        or return 0;
+    my $mail = get_contents($eid);
+#        or return 0;
 
-    my $mailgate = RT::Test->open_mailgate_ok($baseurl);
-    print $mailgate $mail;
-    RT::Test->close_mailgate_ok($mailgate);
+    my ($status, $id) = create_ticket_via_gate($mail);
+    is ($status >> 8, 0, "The mail gateway exited normally");
 
     my $tick = get_latest_ticket_ok();
     is( $tick->Subject,
-        "Email $id",
+        "Email $eid",
         "Created the ticket"
     );
 
     my $txn = $tick->Transactions->First;
-    my ($msg, $attach) = @{$txn->Attachments->ItemsArrayRef};
+    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
 
     if ($usage =~ /encrypted/)
     {
@@ -84,15 +85,21 @@
             'PGP',
             'recorded incoming mail that is encrypted'
         );
+
+        #XXX: maybe RT will have already decrypted this for us
+        unlike($msg->Content,
+               qr/body text/,
+               'incoming mail did NOT have original body');
     }
     else
     {
-        like(
-            $txn->Attachments->First->Headers,
-            qr/^X-RT-Incoming-Encryption: Not encrypted/m,
+        is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+            'Not encrypted',
             'recorded incoming mail that is not encrypted'
         );
-        like( $txn->Attachments->First->Content, qr/!!!/);
+        like($msg->Content,
+             qr/body text/,
+             'incoming mail had original body');
     }
 
     if ($usage =~ /signed/)
@@ -102,6 +109,22 @@
     {
     }
 
+    if ($attachment =~ /attachment/)
+    {
+        my $attachment = $attachments[0];
+        ok ($attachment->Id, 'loaded attachment object');
+        my $acontent = $attachment->Content;
+        is ($acontent, $file, 'The attachment isn\'t screwed up in the database.');
+
+        # signed messages should sign each attachment too
+        if ($usage =~ /signed/)
+        {
+            my $sig = $attachments[1];
+            ok ($attachment->Id, 'loaded attachment.sig object');
+            my $acontent = $attachment->Content;
+        }
+    }
+
     return 0;
 }
 


More information about the Rt-commit mailing list