diff options
author | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
commit | b4b0c7e72d7eaee2fbfc7022022c9698323203dd (patch) | |
tree | ba4cd21399e412c32fe3737eaa8478e3271509f9 /rt/t/mail/gnupg-reverification.t | |
parent | 2dfda73eeb3eae2d4f894099754794ef07d060dd (diff) |
import rt 3.8.7
Diffstat (limited to 'rt/t/mail/gnupg-reverification.t')
-rw-r--r-- | rt/t/mail/gnupg-reverification.t | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/rt/t/mail/gnupg-reverification.t b/rt/t/mail/gnupg-reverification.t new file mode 100644 index 000000000..f116d9380 --- /dev/null +++ b/rt/t/mail/gnupg-reverification.t @@ -0,0 +1,92 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use RT::Test tests => 120; + +plan skip_all => 'GnuPG required.' + unless eval 'use GnuPG::Interface; 1'; +plan skip_all => 'gpg executable is required.' + unless RT::Test->find_executable('gpg'); + + +use File::Temp qw(tempdir); +my $homedir = tempdir( CLEANUP => 1 ); + +RT->Config->Set( 'GnuPG', + Enable => 1, + OutgoingMessagesFormat => 'RFC' ); + +RT->Config->Set( 'GnuPGOptions', + homedir => $homedir, + passphrase => 'rt-test', + 'no-permission-warning' => undef); + +RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' ); + + +diag "load Everyone group" if $ENV{'TEST_VERBOSE'}; +my $everyone; +{ + $everyone = RT::Group->new( $RT::SystemUser ); + $everyone->LoadSystemInternalGroup('Everyone'); + ok $everyone->id, "loaded 'everyone' group"; +} + +RT::Test->set_rights( + Principal => $everyone, + Right => ['CreateTicket'], +); + + +my ($baseurl, $m) = RT::Test->started_ok; +ok $m->login, 'we get log in'; + +RT::Test->import_gnupg_key('rt-recipient@example.com'); + +my @ticket_ids; + +my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(), + qw(data gnupg emails)); +my @files = glob("$emaildatadir/*-signed-*"); +foreach my $file ( @files ) { + diag "testing $file" if $ENV{'TEST_VERBOSE'}; + + my ($eid) = ($file =~ m{(\d+)[^/\\]+$}); + ok $eid, 'figured id of a file'; + + my $email_content = RT::Test->file_content( $file ); + ok $email_content, "$eid: got content of email"; + + my ($status, $id) = RT::Test->send_via_mailgate( $email_content ); + is $status >> 8, 0, "$eid: the mail gateway exited normally"; + ok $id, "$eid: got id of a newly created ticket - $id"; + + my $ticket = RT::Ticket->new( $RT::SystemUser ); + $ticket->Load( $id ); + ok $ticket->id, "$eid: loaded ticket #$id"; + is $ticket->Subject, "Test Email ID:$eid", "$eid: correct subject"; + + $m->goto_ticket( $id ); + $m->content_like( + qr/Not possible to check the signature, the reason is missing public key/is, + "$eid: signature is not verified", + ); + $m->content_like(qr/This is .*ID:$eid/ims, "$eid: content is there and message is decrypted"); + + push @ticket_ids, $id; +} + +diag "import key into keyring" if $ENV{'TEST_VERBOSE'}; +RT::Test->import_gnupg_key('rt-test@example.com', 'public'); + +foreach my $id ( @ticket_ids ) { + diag "testing ticket #$id" if $ENV{'TEST_VERBOSE'}; + + $m->goto_ticket( $id ); + $m->content_like( + qr/The signature is good/is, + "signature is re-verified and now good", + ); +} + |