[Rt-commit] r8816 - in rt/branches/3.7-EXPERIMENTAL: .
sartak at bestpractical.com
sartak at bestpractical.com
Tue Aug 28 16:05:11 EDT 2007
Author: sartak
Date: Tue Aug 28 16:05:10 2007
New Revision: 8816
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-incoming.t
Log:
r37591 at onn: sartak | 2007-08-28 16:04:55 -0400
Fix one of the gnupg-incoming failures by catching mail the way t/web/crypt-gnupg does it
Modified: rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-incoming.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-incoming.t (original)
+++ rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-incoming.t Tue Aug 28 16:05:10 2007
@@ -9,6 +9,21 @@
my $homedir = File::Spec->catdir( getcwd(), qw(lib t data crypt-gnupg) );
+# catch any outgoing emails
+unlink "t/mailbox";
+
+sub capture_mail {
+ my $MIME = shift;
+
+ open my $handle, '>>', 't/mailbox'
+ or die "Unable to open t/mailbox for appending: $!";
+
+ $MIME->print($handle);
+ print $handle "%% split me! %%\n";
+ close $handle;
+}
+
+
RT->Config->Set( LogToScreen => 'debug' );
RT->Config->Set( 'GnuPG',
Enable => 1,
@@ -17,6 +32,7 @@
RT->Config->Set( 'GnuPGOptions',
homedir => $homedir,
'no-permission-warning' => undef);
+RT->Config->Set( MailCommand => \&capture_mail);
RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
@@ -265,14 +281,6 @@
# test for badly encrypted mail
{
-my $outgoing_mail = 0;
-local *RT::Action::SendEmail::OutputMIMEObject = sub {
- my ($self, $mime_obj) = @_;
- diag $mime_obj->as_string;
- ++$outgoing_mail;
- # XXX: check signature as wel
-};
-
$buf = '';
run3(
@@ -285,6 +293,8 @@
\$buf,
\*STDOUT
);
+
+unlink 't/mailbox';
$mail = RT::Test->open_mailgate_ok($baseurl);
print $mail <<"EOF";
From: recipient\@example.com
@@ -294,7 +304,9 @@
$buf
EOF
RT::Test->close_mailgate_ok($mail);
-ok($outgoing_mail, 'got rejection mail.');
+my $mails = file_content_unlink('t/mailbox');
+my @mail = grep {/\S/} split /%% split me! %%/, $mails;
+is(@mail, 1, 'caught outgoing mail.');
}
{
@@ -313,3 +325,14 @@
return $tick;
}
+sub file_content_unlink
+{
+ my $path = shift;
+ diag "reading content of '$path'" if $ENV{'TEST_VERBOSE'};
+ open my $fh, "<:raw", $path or die "couldn't open file '$path': $!";
+ local $/;
+ my $content = <$fh>;
+ close $fh;
+ unlink $path;
+ return $content;
+}
More information about the Rt-commit
mailing list