X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Ft%2Fweb%2Fgnupg-select-keys-on-create.t;h=131f4c5cdf9e560242eacb56abc84a3343094afe;hb=603d84b691c7496bb2ec1cddc549fcc7b80e3e38;hp=8c1ae448c4fd0e6d13a81a29e36955a8b230d11c;hpb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;p=freeside.git diff --git a/rt/t/web/gnupg-select-keys-on-create.t b/rt/t/web/gnupg-select-keys-on-create.t index 8c1ae448c..131f4c5cd 100644 --- a/rt/t/web/gnupg-select-keys-on-create.t +++ b/rt/t/web/gnupg-select-keys-on-create.t @@ -1,7 +1,7 @@ use strict; use warnings; -use RT::Test::GnuPG tests => 83, gnupg_options => { passphrase => 'rt-test' }; +use RT::Test::GnuPG tests => undef, gnupg_options => { passphrase => 'rt-test' }; use RT::Action::SendEmail; my $queue = RT::Test->load_or_create_queue( @@ -37,7 +37,7 @@ diag "check that signing doesn't work if there is no key"; { RT::Test->import_gnupg_key('rt-recipient@example.com'); RT::Test->trust_gnupg_key('rt-recipient@example.com'); - my %res = RT::Crypt::GnuPG::GetKeysInfo('rt-recipient@example.com'); + my %res = RT::Crypt->GetKeysInfo( Key => 'rt-recipient@example.com' ); is $res{'info'}[0]{'TrustTerse'}, 'ultimate', 'ultimately trusted key'; } @@ -66,19 +66,15 @@ diag "check that things don't work if there is no key"; my @mail = RT::Test->fetch_caught_mails; ok !@mail, 'there are no outgoing emails'; - for (1 .. 4) { - $m->next_warning_like(qr/public key not found/) ; - $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); - } - + $m->next_warning_like(qr/public key not found/) for 1 .. 4; $m->no_leftover_warnings_ok; } diag "import first key of rt-test\@example.com"; my $fpr1 = ''; { - RT::Test->import_gnupg_key('rt-test@example.com', 'public'); - my %res = RT::Crypt::GnuPG::GetKeysInfo('rt-test@example.com'); + RT::Test->import_gnupg_key('rt-test@example.com', 'secret'); + my %res = RT::Crypt->GetKeysInfo( Key => 'rt-test@example.com' ); is $res{'info'}[0]{'TrustLevel'}, 0, 'is not trusted key'; $fpr1 = $res{'info'}[0]{'Fingerprint'}; } @@ -126,8 +122,8 @@ diag "check that things still doesn't work if key is not trusted"; diag "import a second key of rt-test\@example.com"; my $fpr2 = ''; { - RT::Test->import_gnupg_key('rt-test@example.com.2', 'public'); - my %res = RT::Crypt::GnuPG::GetKeysInfo('rt-test@example.com'); + RT::Test->import_gnupg_key('rt-test@example.com.2', 'secret'); + my %res = RT::Crypt->GetKeysInfo( Key => 'rt-test@example.com' ); is $res{'info'}[1]{'TrustLevel'}, 0, 'is not trusted key'; $fpr2 = $res{'info'}[2]{'Fingerprint'}; } @@ -174,7 +170,7 @@ diag "check that things still doesn't work if two keys are not trusted"; { RT::Test->lsign_gnupg_key( $fpr1 ); - my %res = RT::Crypt::GnuPG::GetKeysInfo('rt-test@example.com'); + my %res = RT::Crypt->GetKeysInfo( Key => 'rt-test@example.com' ); ok $res{'info'}[0]{'TrustLevel'} > 0, 'trusted key'; is $res{'info'}[1]{'TrustLevel'}, 0, 'is not trusted key'; } @@ -243,37 +239,44 @@ diag "check that key selector works and we can select trusted key"; } diag "check encrypting of attachments"; -{ +for my $encrypt (0, 1) { RT::Test->clean_caught_mails; ok $m->goto_create_ticket( $queue ), "UI -> create ticket"; $m->form_name('TicketCreate'); - $m->tick( Encrypt => 1 ); - $m->field( Requestors => 'rt-test@example.com' ); + $m->tick( Encrypt => 1 ) if $encrypt; + $m->field( Requestors => '' ); + $m->field( Cc => 'rt-test@example.com' ); $m->field( Content => 'Some content' ); $m->field( Attach => $0 ); $m->submit; - $m->content_contains( - 'You are going to encrypt outgoing email messages', - 'problems with keys' - ); - $m->content_contains( - 'There are several keys suitable for encryption', - 'problems with keys' - ); - my $form = $m->form_name('TicketCreate'); - ok my $input = $form->find_input( 'UseKey-rt-test@example.com' ), 'found key selector'; - is scalar $input->possible_values, 2, 'two options'; + if ($encrypt) { + $m->content_contains( + 'You are going to encrypt outgoing email messages', + 'problems with keys' + ); + $m->content_contains( + 'There are several keys suitable for encryption', + 'problems with keys' + ); + + my $form = $m->form_name('TicketCreate'); + ok my $input = $form->find_input( 'UseKey-rt-test@example.com' ), 'found key selector'; + is scalar $input->possible_values, 2, 'two options'; + + $m->select( 'UseKey-rt-test@example.com' => $fpr1 ); + $m->submit; + } - $m->select( 'UseKey-rt-test@example.com' => $fpr1 ); - $m->submit; $m->content_like( qr/Ticket \d+ created in queue/i, 'ticket created' ); my @mail = RT::Test->fetch_caught_mails; ok @mail, 'there are some emails'; - check_text_emails( { Encrypt => 1, Attachment => 1 }, @mail ); + check_text_emails( { Encrypt => $encrypt, Attachment => "Attachment content" }, @mail ); $m->no_warnings_ok; } +undef $m; +done_testing;