[Rt-commit] rt branch, 4.4/work-with-both-gnupgs, created. rt-4.4.2-99-g0836db8df

Brian Duggan brian at bestpractical.com
Thu Mar 15 16:19:43 EDT 2018


The branch, 4.4/work-with-both-gnupgs has been created
        at  0836db8df3ff45538e42d52fee34014f674f6710 (commit)

- Log -----------------------------------------------------------------
commit 0836db8df3ff45538e42d52fee34014f674f6710
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..64c526697 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,29 @@ 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
+if ($gnupg->is_modern) {
+    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