5 use RT::Test::GnuPG tests => 25, gnupg_options => { passphrase => 'rt-test' };
7 use Digest::MD5 qw(md5_hex);
9 RT::Test->import_gnupg_key('rt-recipient@example.com');
10 RT::Test->import_gnupg_key('rt-test@example.com', 'public');
12 my ($baseurl, $m) = RT::Test->started_ok;
14 ok( $m->login, 'we did log in' );
16 # configure key for General queue
18 $m->get( $baseurl.'/Admin/Queues/');
19 $m->follow_link_ok( {text => 'General'} );
22 fields => { CorrespondAddress => 'rt-recipient@example.com' },
24 $m->content_like(qr/rt-recipient\@example.com.* - never/, 'has key info.');
27 ok(my $user = RT::User->new(RT->SystemUser));
28 ok($user->Load('root'), "Loaded user 'root'");
29 $user->SetEmailAddress('recipient@example.com');
32 my $id = send_via_mailgate('quoted_inline_signature.txt');
34 my $tick = RT::Ticket->new( RT->SystemUser );
36 ok ($tick->id, "loaded ticket #$id");
38 my $txn = $tick->Transactions->First;
39 my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
41 is( $msg->GetHeader('X-RT-Privacy'),
43 "no privacy is set as this ticket is not encrypted"
46 my @mail = RT::Test->fetch_caught_mails;
47 is(scalar @mail, 1, "autoreply only");
51 my $id = send_via_mailgate('binary-asc-attach-marked-plain-text.txt');
53 my $tick = RT::Ticket->new( $RT::SystemUser );
55 ok ($tick->id, "loaded ticket #$id");
57 my $txn = $tick->Transactions->First;
58 my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
60 is (scalar @attachs, 3, 'text, attachment and original');
61 my $bin = $attachs[1];
63 (split /;/, $bin->GetHeader('Content-Type'))[0],
64 'application/octet-stream',
67 is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
71 my $id = send_via_mailgate('inline-binary-attachment-with-wrap.txt');
73 my $tick = RT::Ticket->new( $RT::SystemUser );
75 ok ($tick->id, "loaded ticket #$id");
77 my $txn = $tick->Transactions->First;
78 my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
80 is (scalar @attachs, 3, 'text, attachment and original');
81 my $bin = $attachs[1];
83 (split /;/, $bin->GetHeader('Content-Type'))[0],
84 'application/octet-stream',
87 is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
90 sub send_via_mailgate {
92 my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(),
93 qw(data gnupg emails special));
94 my $file = File::Spec->catfile( $emaildatadir, $fname );
95 my $mail = RT::Test->file_content($file);
97 my ($status, $id) = RT::Test->send_via_mailgate($mail);
98 is ($status >> 8, 0, "the mail gateway exited normally");
99 ok ($id, "got id of a newly created ticket - $id");