[Rt-commit] rt branch, 4.4/work-with-both-gnupgs,	created. rt-4.4.2-101-g294af5fb3
    Brian Duggan 
    brian at bestpractical.com
       
    Thu Apr  5 16:56:36 EDT 2018
    
    
  
The branch, 4.4/work-with-both-gnupgs has been created
        at  294af5fb36568ef6f266abb542e933f20ff218ed (commit)
- Log -----------------------------------------------------------------
commit 294af5fb36568ef6f266abb542e933f20ff218ed
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu Mar 15 16:03:38 2018 -0400
    Test modern gpg signing failure warnings
    
    The t/crypt/no-signer-address.t test tries to sign data when gpg has no
    signing key to use. Classic GPG only emitted one warning for this
    failure. Previously, this test checked only for that warning.
    
    Modern GPG emits all the warnings its documentation says it should
    emit. This change checks for those warnings, too.
    
    It's unclear why classic didn't emit these warnings when modern gpg
    does. The warnings are documented in the GnuPG source under doc/DETAILS
    in both classic and modern tags. Try 1.4.18 vs 2.1.18, the versions I
    tested with.
diff --git a/t/crypt/no-signer-address.t b/t/crypt/no-signer-address.t
index 31ba5ebc2..c90fb43c1 100644
--- a/t/crypt/no-signer-address.t
+++ b/t/crypt/no-signer-address.t
@@ -1,6 +1,8 @@
 use strict;
 use warnings;
 
+use GnuPG::Interface;
+
 use RT::Test::GnuPG
   tests         => undef,
   gnupg_options => {
@@ -9,6 +11,8 @@ use RT::Test::GnuPG
   }
 ;
 
+my $gnupg = GnuPG::Interface->new();
+
 my $queue;
 {
     $queue = RT::Test->load_or_create_queue(
@@ -35,8 +39,30 @@ my ($status, undef, $msg) = $ticket->Create(
 );
 ok( $status, "created ticket" ) or diag "error: $msg";
 
-is( scalar @warnings, 1, "Got a warning" );
-like( $warnings[0], qr{signing failed: secret key not available},
-    "Found warning of no secret key");
+# Classic GnuPG doesn't emit the latter two warnings. Modern GnuPG
+# does. Test with:
+# 
+# $ touch a-file
+# $ gpg --status-file gpg-status --default-key "bob at example.com" --sign a-file
+# $ cat gpg-status
+my @gnupg_versions = split /\./, $gnupg->version;
+if ($gnupg_versions[0] >= 2 && $gnupg_versions[1] >= 1) {
+    is( scalar @warnings, 3, "Got warnings" );
+
+    like( $warnings[0], qr{signing failed: No secret key},
+         "Found warning of no secret key");
+
+    like( $warnings[1], qr{INV_SGNR},
+         "Found warning of no usable senders");
+
+    like( $warnings[2], qr{FAILURE},
+         "Found warning of failure");
+}
+else {
+    is( scalar @warnings, 1, "Got a warning" );
+
+    like( $warnings[0], qr{signing failed: secret key not available},
+         "Found warning of no secret key");
+}
 
 done_testing;
-----------------------------------------------------------------------
    
    
More information about the rt-commit
mailing list