-#!/usr/bin/perl
use strict;
use warnings;
}
use RT::Test::GnuPG
- tests => 41,
+ tests => 53,
actual_server => 1,
gnupg_options => {
passphrase => 'rt-test',
use String::ShellQuote 'shell_quote';
use IPC::Run3 'run3';
+use MIME::Base64;
my ($baseurl, $m) = RT::Test->started_ok;
$m->get( $baseurl.'/Admin/Queues/');
$m->follow_link_ok( {text => 'General'} );
$m->submit_form( form_number => 3,
- fields => { CorrespondAddress => 'general@example.com' } );
+ fields => { CorrespondAddress => 'general@example.com' } );
$m->content_like(qr/general\@example.com.* - never/, 'has key info.');
ok(my $user = RT::User->new(RT->SystemUser));
'--default-key' => 'recipient@example.com',
'--homedir' => $homedir,
'--passphrase' => 'recipient',
+ '--no-permission-warning',
),
\"fnord\r\n",
\$buf,
'--default-key' => 'recipient@example.com',
'--homedir' => $homedir,
'--passphrase' => 'recipient',
+ '--no-permission-warning',
),
\"clearfnord\r\n",
\$buf,
'--default-key' => 'recipient@example.com',
'--homedir' => $homedir,
'--passphrase' => 'recipient',
+ '--no-permission-warning',
),
\"orzzzzzz\r\n",
\$buf,
'recorded incoming mail that is encrypted'
);
is( $msg->GetHeader('X-RT-Privacy'),
- 'PGP',
+ 'GnuPG',
+ 'recorded incoming mail that is encrypted'
+ );
+ like( $attach->Content, qr/orz/);
+
+ is( $orig->GetHeader('Content-Type'), 'application/x-rt-original-message');
+ ok(index($orig->Content, $buf) != -1, 'found original msg');
+}
+
+
+# test that if it gets base64 transfer-encoded, we still get the content out
+$buf = encode_base64($buf);
+$mail = RT::Test->open_mailgate_ok($baseurl);
+print $mail <<"EOF";
+From: recipient\@example.com
+To: general\@$RT::rtname
+Content-transfer-encoding: base64
+Subject: Encrypted message for queue
+
+$buf
+EOF
+RT::Test->close_mailgate_ok($mail);
+
+{
+ my $tick = RT::Test->last_ticket;
+ is( $tick->Subject, 'Encrypted message for queue',
+ "Created the ticket"
+ );
+
+ my $txn = $tick->Transactions->First;
+ my ($msg, $attach, $orig) = @{$txn->Attachments->ItemsArrayRef};
+
+ is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+ 'Success',
+ 'recorded incoming mail that is encrypted'
+ );
+ is( $msg->GetHeader('X-RT-Privacy'),
+ 'GnuPG',
'recorded incoming mail that is encrypted'
);
like( $attach->Content, qr/orz/);
'--default-key' => 'rt@example.com',
'--homedir' => $homedir,
'--passphrase' => 'test',
+ '--no-permission-warning',
),
\"alright\r\n",
\$buf,
qw(gpg --batch --no-tty --armor --encrypt),
'--recipient' => 'random@localhost',
'--homedir' => $homedir,
+ '--no-permission-warning',
),
\"should not be there either\r\n",
\$buf,
qw(gpg --batch --no-tty --armor --encrypt),
'--recipient' => 'rt@example.com',
'--homedir' => $homedir,
+ '--no-permission-warning',
),
\"really should not be there either\r\n",
\$buf,
unlike( ($attach ? $attach->Content : ''), qr/really should not be there either/);
}
+
+# test that if it gets base64 transfer-encoded long mail then it doesn't hang
+{
+ local $SIG{ALRM} = sub {
+ ok 0, "timed out, web server is probably in deadlock";
+ exit;
+ };
+ alarm 30;
+ $buf = encode_base64('a'x(250*1024));
+ $mail = RT::Test->open_mailgate_ok($baseurl);
+ print $mail <<"EOF";
+From: recipient\@example.com
+To: general\@$RT::rtname
+Content-transfer-encoding: base64
+Subject: Long not encrypted message for queue
+
+$buf
+EOF
+ RT::Test->close_mailgate_ok($mail);
+ alarm 0;
+
+ my $tick = RT::Test->last_ticket;
+ is( $tick->Subject, 'Long not encrypted message for queue',
+ "Created the ticket"
+ );
+ my $content = $tick->Transactions->First->Content;
+ like $content, qr/a{1024,}/, 'content is not lost';
+}