[Rt-commit] r8790 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 28 14:43:24 EDT 2007
Author: ruz
Date: Tue Aug 28 14:43:24 2007
New Revision: 8790
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t
Log:
r8721 at cubic-pc (orig r8720): sartak | 2007-08-24 22:22:49 +0400
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/t/web/crypt-gnupg.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t (original)
+++ rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t Tue Aug 28 14:43:24 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