X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Flib%2FRT%2FTest%2FGnuPG.pm;h=fc162aa84e7c2edd69231318ec7a09ef21d70391;hb=187086c479a09629b7d180eec513fb7657f4e291;hp=ec446724ecf50e87d877055477a2faf233335e94;hpb=7588a4ac90a9b07c08a3107cd1107d773be1c991;p=freeside.git diff --git a/rt/lib/RT/Test/GnuPG.pm b/rt/lib/RT/Test/GnuPG.pm index ec446724e..fc162aa84 100644 --- a/rt/lib/RT/Test/GnuPG.pm +++ b/rt/lib/RT/Test/GnuPG.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -64,13 +64,12 @@ sub import { my %args = @_; my $t = $class->builder; - $t->plan( skip_all => 'GnuPG required.' ) - unless eval { require GnuPG::Interface; 1 }; - $t->plan( skip_all => 'gpg executable is required.' ) + RT::Test::plan( skip_all => 'GnuPG required.' ) + unless GnuPG::Interface->require; + RT::Test::plan( skip_all => 'gpg executable is required.' ) unless RT::Test->find_executable('gpg'); $class->SUPER::import(%args); - require RT::Crypt::GnuPG; return $class->export_to_level(1) if $^C; @@ -107,7 +106,7 @@ Set(\%GnuPG, ( OutgoingMessagesFormat => 'RFC', )); Set(\%GnuPGOptions => \%{ $dumped_gnupg_options }); -Set(\@MailPlugins => qw(Auth::MailFrom Auth::GnuPG)); +Set(\@MailPlugins => qw(Auth::MailFrom Auth::Crypt)); }; } @@ -167,7 +166,7 @@ sub update_ticket { $m->click('SubmitTicket'); is $m->status, 200, "request successful"; - $m->content_contains("Message recorded", 'Message recorded') or diag $m->content; + $m->content_contains("Correspondence added", 'Correspondence added') or diag $m->content; my @mail = RT::Test->fetch_caught_mails; @@ -205,13 +204,17 @@ sub check_text_emails { my $content = $type eq 'email' ? "Some content" - : "Attachment content"; + : $args{Attachment}; if ( $args{'Encrypt'} ) { - unlike $mail, qr/$content/, "outgoing $type was encrypted"; + unlike $mail, qr/$content/, "outgoing $type is not in plaintext"; + my $entity = RT::Test::parse_mail($mail); + my @res = RT::Crypt->VerifyDecrypt(Entity => $entity); + like $res[0]{'status'}, qr/DECRYPTION_OKAY/, "Decrypts OK"; + like $entity->as_string, qr/$content/, "outgoing decrypts to contain $type content"; } else { like $mail, qr/$content/, "outgoing $type was not encrypted"; - } + } next unless $type eq 'email'; @@ -231,7 +234,7 @@ sub cleanup_headers { # strip id from subject to create new ticket $mail =~ s/^(Subject:)\s*\[.*?\s+#\d+\]\s*/$1 /m; # strip several headers - foreach my $field ( qw(Message-ID X-RT-Original-Encoding RT-Originator RT-Ticket X-RT-Loop-Prevention) ) { + foreach my $field ( qw(Message-ID RT-Originator RT-Ticket X-RT-Loop-Prevention) ) { $mail =~ s/^$field:.*?\n(?! |\t)//gmsi; } return $mail; @@ -276,7 +279,7 @@ sub send_email_and_check_transaction { "RT's outgoing mail looks not signed"; } elsif ( $type eq 'signed' ) { - is $msg->GetHeader('X-RT-Privacy'), 'PGP', + is $msg->GetHeader('X-RT-Privacy'), 'GnuPG', "RT's outgoing mail has crypto"; is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Not encrypted', "RT's outgoing mail looks not encrypted"; @@ -285,7 +288,7 @@ sub send_email_and_check_transaction { "RT's outgoing mail looks signed"; } elsif ( $type eq 'encrypted' ) { - is $msg->GetHeader('X-RT-Privacy'), 'PGP', + is $msg->GetHeader('X-RT-Privacy'), 'GnuPG', "RT's outgoing mail has crypto"; is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success', "RT's outgoing mail looks encrypted"; @@ -294,7 +297,7 @@ sub send_email_and_check_transaction { } elsif ( $type eq 'signed_encrypted' ) { - is $msg->GetHeader('X-RT-Privacy'), 'PGP', + is $msg->GetHeader('X-RT-Privacy'), 'GnuPG', "RT's outgoing mail has crypto"; is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success', "RT's outgoing mail looks encrypted";