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

sartak at bestpractical.com sartak at bestpractical.com
Fri Aug 24 16:11:26 EDT 2007


Author: sartak
Date: Fri Aug 24 16:11:24 2007
New Revision: 8727

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

Log:
 r19919 at onn:  sartak | 2007-08-24 16:10:41 -0400
 Add real tests for signature verification


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 16:11:24 2007
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 
-use Test::More tests => 29;
+use Test::More tests => 38;
 use RT::Test;
 use RT::Action::SendEmail;
 
@@ -157,9 +157,55 @@
 $mails = file_content_unlink('t/mailbox');
 @mail = grep {/\S/} split /%% split me! %%/, $mails;
 ok(@mail, "got some mail");
-for (@mail) {
-    like $_, qr/Some other content/, "outgoing mail was not encrypted";
-    like $_, qr/-----BEGIN PGP SIGNATURE-----[\s\S]+-----END PGP SIGNATURE-----/, "data has some kind of signature";
+for my $mail (@mail) {
+    like $mail, qr/Some other content/, "outgoing mail was not encrypted";
+    like $mail, qr/-----BEGIN PGP SIGNATURE-----[\s\S]+-----END PGP SIGNATURE-----/, "data has some kind of signature";
+
+    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-Privacy'),
+        'PGP',
+        "RT's outgoing mail has crypto"
+    );
+    is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+        'Not encrypted',
+        "RT's outgoing mail looks unencrypted"
+    );
+    is( $msg->GetHeader('X-RT-Incoming-Signature'),
+        'general <general at example.com>',
+        "recorded incoming mail that is signed"
+    );
+
+    like($attachments[0]->Content, qr/Some other content/, "RT's mail includes copy of ticket text");
+    like($attachments[0]->Content, qr/$RT::rtname/, "RT's mail includes this instance's name");
 }
 
 sub file_content_unlink


More information about the Rt-commit mailing list