4 use RT::Test::SMIME tests => undef;
8 RT::Test::SMIME->import_key('sender@example.com');
9 my $queue = RT::Test->load_or_create_queue(
11 CorrespondAddress => 'sender@example.com',
13 ok $queue && $queue->id, 'loaded or created queue';
16 my ($status, $msg) = $queue->SetEncrypt(1);
17 ok $status, "turn on encyption by default"
18 or diag "error: $msg";
23 $root = RT::User->new($RT::SystemUser);
24 ok($root->LoadByEmail('root@localhost'), "Loaded user 'root'");
25 ok($root->Load('root'), "Loaded user 'root'");
26 is($root->EmailAddress, 'root@localhost');
28 RT::Test::SMIME->import_key( 'root@example.com.crt' => $root );
33 $bad_user = RT::Test->load_or_create_user(
35 EmailAddress => 'baduser@example.com',
37 ok $bad_user && $bad_user->id, 'created a user without key';
40 RT::Test->clean_caught_mails;
45 my $ticket = RT::Ticket->new(RT->SystemUser);
46 my ($status, undef, $msg) = $ticket->Create( Queue => $queue->id, Requestor => [$root->id, $bad_user->id] );
47 ok $status, "created a ticket" or diag "error: $msg";
49 my @mails = RT::Test->fetch_caught_mails;
50 is scalar @mails, 3, "autoreply, to bad user, to RT owner";
52 like $mails[0], qr{To: baduser\@example\.com}, "notification to bad user";
53 like $mails[1], qr{To: root}, "notification to RT owner";
54 like $mails[1], qr{Recipient 'baduser\@example\.com' is unusable, the reason is 'Key not found'},
55 "notification to owner has error";
56 } [qr{Recipient 'baduser\@example\.com' is unusable, the reason is 'Key not found'}];