[Rt-commit] r8720 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: t/web

sartak at bestpractical.com sartak at bestpractical.com
Fri Aug 24 14:22:49 EDT 2007


Author: sartak
Date: Fri Aug 24 14:22:49 2007
New Revision: 8720

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

Log:
 r19879 at onn:  sartak | 2007-08-24 14:21:35 -0400
 Begin adding tests for checking the encryption on RT's mail


Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t	Fri Aug 24 14:22:49 2007
@@ -41,6 +41,7 @@
 RT->Config->Set( 'GnuPGOptions',
                  homedir => $homedir,
                  'no-permission-warning' => undef);
+RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
 
 RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
 
@@ -82,8 +83,52 @@
 my $mail = file_content_unlink('t/mailbox');
 my @mail = grep {/\S/} split /%% split me! %%/, $mail;
 ok(@mail, "got some mail");
-for (@mail) {
-    unlike $_, qr/Some content/, "outgoing mail was encrypted";
+for my $mail (@mail) {
+    unlike $mail, qr/Some content/, "outgoing mail was encrypted";
+
+    my ($content_type) = $mail =~ /^(Content-Type: .*)/m;
+    my ($mime_version) = $mail =~ /^(MIME-Version: .*)/m;
+    my $body = strip_headers($mail);
+
+    $mail = << "MAIL";
+Subject: RT mail sent back into RT
+From: general\@example.com
+To: recipient\@example.com
+$mime_version
+$content_type
+
+$body
+MAIL
+    
+    my ($status, $id) = RT::Test->send_via_mailgate($mail);
+    is ($status >> 8, 0, "The mail gateway exited normally");
+    ok ($id, "got id of a newly created ticket - $id");
+
+    my $tick = RT::Ticket->new( $RT::SystemUser );
+    $tick->Load( $id );
+    ok ($tick->id, "loaded ticket #$id");
+
+    is ($tick->Subject,
+        "RT mail sent back into RT",
+        "Correct subject"
+    );
+
+    my $txn = $tick->Transactions->First;
+    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
+
+    is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+        'Success',
+        "RT's outgoing mail looks encrypted"
+    );
+    is( $msg->GetHeader('X-RT-Privacy'),
+        'PGP',
+        "RT's outgoing mail looks encrypted"
+    );
+
+    like( $msg->Content,
+            qr/Some content/,
+            "incoming mail did NOT have original body"
+    );
     my ($content_type) = /(Content-Type: .*)/;
     my ($mime_version) = /(MIME-Version: .*)/;
     $_ = strip_headers($_);
@@ -168,7 +213,6 @@
 sub strip_headers
 {
     my $mail = shift;
-    $mail =~ s/^.*?\n\n//s;
+    $mail =~ s/.*?\n\n//s;
     return $mail;
 }
-


More information about the Rt-commit mailing list