[Rt-commit] r8795 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 28 14:44:30 EDT 2007
Author: ruz
Date: Tue Aug 28 14:44:30 2007
New Revision: 8795
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t
Log:
r8728 at cubic-pc (orig r8727): sartak | 2007-08-25 00:11:24 +0400
r19919 at onn: sartak | 2007-08-24 16:10:41 -0400
Add real tests for signature verification
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:44:30 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