4 use RT::Test::SMIME tests => undef;
5 my $test = 'RT::Test::SMIME';
8 use RT::Interface::Email;
10 my ($url, $m) = RT::Test->started_ok;
11 ok $m->login, "logged in";
13 my $queue = RT::Test->load_or_create_queue(
15 CorrespondAddress => 'sender@example.com',
16 CommentAddress => 'sender@example.com',
18 ok $queue && $queue->id, 'loaded or created queue';
21 my ($status, $msg) = $queue->SetEncrypt(1);
22 ok $status, "turn on encyption by default"
23 or diag "error: $msg";
28 $user = RT::User->new($RT::SystemUser);
29 ok($user->LoadByEmail('root@localhost'), "Loaded user 'root'");
30 ok($user->Load('root'), "Loaded user 'root'");
31 is($user->EmailAddress, 'root@localhost');
33 RT::Test::SMIME->import_key( 'root@example.com.crt' => $user );
36 RT::Test->clean_caught_mails;
42 Subject: This is a test of new ticket creation as an unknown user
49 my ($status, $id) = RT::Test->send_via_mailgate(
50 $mail, queue => $queue->Name,
52 is $status >> 8, 0, "successfuly executed mailgate";
54 my $ticket = RT::Ticket->new($RT::SystemUser);
56 ok ($ticket->id, "found ticket ". $ticket->id);
60 my @mails = RT::Test->fetch_caught_mails;
61 is scalar @mails, 1, "autoreply";
67 qw(openssl smime -decrypt -passin pass:123456),
68 '-inkey', $test->key_path('root@example.com.key'),
69 '-recip', $test->key_path('root@example.com.crt')
70 ], \$mails[0], \$buf, \$err )
75 diag "Error code: $?" if $?;
76 like($buf, qr'This message has been automatically generated in response');