4 use RT::Test::GnuPG tests => 25, gnupg_options => { passphrase => 'rt-test' };
6 use Digest::MD5 qw(md5_hex);
8 RT::Test->import_gnupg_key('rt-recipient@example.com');
9 RT::Test->import_gnupg_key('rt-test@example.com', 'public');
11 my ($baseurl, $m) = RT::Test->started_ok;
13 ok( $m->login, 'we did log in' );
15 # configure key for General queue
17 $m->get( $baseurl.'/Admin/Queues/');
18 $m->follow_link_ok( {text => 'General'} );
21 fields => { CorrespondAddress => 'rt-recipient@example.com' },
23 $m->content_like(qr/rt-recipient\@example.com.* - never/, 'has key info.');
26 ok(my $user = RT::User->new(RT->SystemUser));
27 ok($user->Load('root'), "Loaded user 'root'");
28 $user->SetEmailAddress('recipient@example.com');
31 my $id = send_via_mailgate('quoted_inline_signature.txt');
33 my $tick = RT::Ticket->new( RT->SystemUser );
35 ok ($tick->id, "loaded ticket #$id");
37 my $txn = $tick->Transactions->First;
38 my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
40 is( $msg->GetHeader('X-RT-Privacy'),
42 "no privacy is set as this ticket is not encrypted"
45 my @mail = RT::Test->fetch_caught_mails;
46 is(scalar @mail, 1, "autoreply only");
50 my $id = send_via_mailgate('binary-asc-attach-marked-plain-text.txt');
52 my $tick = RT::Ticket->new( $RT::SystemUser );
54 ok ($tick->id, "loaded ticket #$id");
56 my $txn = $tick->Transactions->First;
57 my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
59 is (scalar @attachs, 3, 'text, attachment and original');
60 my $bin = $attachs[1];
62 (split /;/, $bin->GetHeader('Content-Type'))[0],
63 'application/octet-stream',
66 is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
70 my $id = send_via_mailgate('inline-binary-attachment-with-wrap.txt');
72 my $tick = RT::Ticket->new( $RT::SystemUser );
74 ok ($tick->id, "loaded ticket #$id");
76 my $txn = $tick->Transactions->First;
77 my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
79 is (scalar @attachs, 3, 'text, attachment and original');
80 my $bin = $attachs[1];
82 (split /;/, $bin->GetHeader('Content-Type'))[0],
83 'application/octet-stream',
86 is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
89 sub send_via_mailgate {
91 my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(),
92 qw(data gnupg emails special));
93 my $file = File::Spec->catfile( $emaildatadir, $fname );
94 my $mail = RT::Test->file_content($file);
96 my ($status, $id) = RT::Test->send_via_mailgate($mail);
97 is ($status >> 8, 0, "the mail gateway exited normally");
98 ok ($id, "got id of a newly created ticket - $id");