5 use RT::Test tests => 11;
7 plan skip_all => 'GnuPG required.'
8 unless eval 'use GnuPG::Interface; 1';
9 plan skip_all => 'gpg executable is required.'
10 unless RT::Test->find_executable('gpg');
12 use File::Temp qw(tempdir);
13 my $homedir = tempdir( CLEANUP => 1 );
15 # catch any outgoing emails
16 RT::Test->set_mail_catcher;
18 RT->Config->Set( 'GnuPG',
20 OutgoingMessagesFormat => 'RFC' );
22 RT->Config->Set( 'GnuPGOptions',
24 'no-permission-warning' => undef);
26 RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
28 RT::Test->import_gnupg_key('rt-recipient@example.com');
29 RT::Test->import_gnupg_key('rt-test@example.com', 'public');
31 my ($baseurl, $m) = RT::Test->started_ok;
33 ok( $m->login, 'we did log in' );
35 # configure key for General queue
37 $m->get( $baseurl.'/Admin/Queues/');
38 $m->follow_link_ok( {text => 'General'} );
41 fields => { CorrespondAddress => 'rt-recipient@example.com' },
43 $m->content_like(qr/rt-recipient\@example.com.* - never/, 'has key info.');
46 ok(my $user = RT::User->new($RT::SystemUser));
47 ok($user->Load('root'), "Loaded user 'root'");
48 $user->SetEmailAddress('recipient@example.com');
51 Principal => 'Everyone',
52 Right => ['CreateTicket'],
56 my $id = send_via_mailgate('quoted_inline_signature.txt');
58 my $tick = RT::Ticket->new( $RT::SystemUser );
60 ok ($tick->id, "loaded ticket #$id");
62 my $txn = $tick->Transactions->First;
63 my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
65 is( $msg->GetHeader('X-RT-Privacy'),
67 "no privacy is set as this ticket is not encrypted"
70 my @mail = RT::Test->fetch_caught_mails;
71 is(scalar @mail, 1, "autoreply only");
74 sub send_via_mailgate {
76 my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(),
77 qw(data gnupg emails special));
78 my $file = File::Spec->catfile( $emaildatadir, $fname );
79 my $mail = RT::Test->file_content($file);
81 my ($status, $id) = RT::Test->send_via_mailgate($mail);
82 is ($status >> 8, 0, "the mail gateway exited normally");
83 ok ($id, "got id of a newly created ticket - $id");