4 use RT::Test::GnuPG tests => 232, gnupg_options => { passphrase => 'rt-test' };
6 diag "load Everyone group";
9 $everyone = RT::Group->new( RT->SystemUser );
10 $everyone->LoadSystemInternalGroup('Everyone');
11 ok $everyone->id, "loaded 'everyone' group";
14 my ($baseurl, $m) = RT::Test->started_ok;
15 ok $m->login, 'we get log in';
17 RT::Test->import_gnupg_key('rt-recipient@example.com');
21 my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(),
22 qw(data gnupg emails));
23 my @files = glob("$emaildatadir/*-signed-*");
24 foreach my $file ( @files ) {
27 my ($eid) = ($file =~ m{(\d+)[^/\\]+$});
28 ok $eid, 'figured id of a file';
30 my $email_content = RT::Test->file_content( $file );
31 ok $email_content, "$eid: got content of email";
37 # We don't use Test::Warn here because we get multi-line
38 # warnings, which Test::Warn only records the first line of.
39 local $SIG{__WARN__} = sub {
43 ($status, $id) = RT::Test->send_via_mailgate( $email_content );
46 is $status >> 8, 0, "$eid: the mail gateway exited normally";
47 ok $id, "$eid: got id of a newly created ticket - $id";
49 like($warnings, qr/Had a problem during decrypting and verifying/);
50 like($warnings, qr/public key not found/);
52 my $ticket = RT::Ticket->new( RT->SystemUser );
54 ok $ticket->id, "$eid: loaded ticket #$id";
55 is $ticket->Subject, "Test Email ID:$eid", "$eid: correct subject";
57 $m->goto_ticket( $id );
59 "Not possible to check the signature, the reason is missing public key",
60 "$eid: signature is not verified",
62 $m->content_like(qr/This is .*ID:$eid/ims, "$eid: content is there and message is decrypted");
64 $m->next_warning_like(qr/public key not found/);
65 $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/);
67 # some mails contain multiple signatures
68 if ($eid == 5 || $eid == 17 || $eid == 18) {
69 $m->next_warning_like(qr/public key not found/);
70 $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/);
73 $m->no_leftover_warnings_ok;
75 push @ticket_ids, $id;
78 diag "import key into keyring";
79 RT::Test->import_gnupg_key('rt-test@example.com', 'public');
81 foreach my $id ( @ticket_ids ) {
82 diag "testing ticket #$id";
84 $m->goto_ticket( $id );
86 "The signature is good",
87 "signature is re-verified and now good",