Control: tag -1 patch

On Wed, Jun 20, 2018 at 11:39:27PM +0300, Niko Tyni wrote:

> There's still the 2.2.8 / --ignore-mdc-error regression to fix.

Here's a patch for adapting the test suite to that one too.

I can't see an easy way to inject --ignore-mdc-error to the
decrypt() call, and possibly that's for the best. I don't
really want to add a secret method for doing that, so
I've just mangled the test suite instead.

Possibly we should test for an exit code != 0 rather than
the specific 2 we get at the moment but oh well.
-- 
Niko
>From 958e8aa6812b4d6c2e9d66203073dd348c3d8f04 Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Sun, 24 Jun 2018 16:19:25 +0300
Subject: [PATCH] Fix test suite for GnuPG >= 2.2.8 compatibility

GnuPG 2.2.8 onwards issues a hard failure when decrypting
messages not using the MDC mode.

Bug-Debian: https://bugs.debian.org/900051
---
 t/decrypt.t | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/t/decrypt.t b/t/decrypt.t
index b2639ed..f7d9132 100644
--- a/t/decrypt.t
+++ b/t/decrypt.t
@@ -6,6 +6,7 @@
 use strict;
 use English qw( -no_match_vars );
 use File::Compare;
+use version;
 
 use lib './t';
 use MyTest;
@@ -13,6 +14,8 @@ use MyTestSpecific;
 
 my $compare;
 
+my $gnupg_version = version->parse($gnupg->version);
+
 TEST
 {
     reset_handles();
@@ -26,7 +29,13 @@ TEST
     close $stdout;
     waitpid $pid, 0;
 
-    return $CHILD_ERROR == 0;;
+    if ($gnupg_version < version->parse('2.2.8')) {
+        return $CHILD_ERROR == 0;;
+    } else {
+        local $/ = undef;
+        my $errstr = <$stderr>;
+        return (($CHILD_ERROR >> 8 == 2) and ($errstr =~ /ignore-mdc-error/));
+    }
 };
 
 
@@ -50,7 +59,13 @@ TEST
 
     waitpid $pid, 0;
 
-    return $CHILD_ERROR == 0;
+    if ($gnupg_version < version->parse('2.2.8')) {
+        return $CHILD_ERROR == 0;
+    } else {
+        local $/ = undef;
+        my $errstr = <$stderr>;
+        return (($CHILD_ERROR >> 8 == 2) and ($errstr =~ /ignore-mdc-error/));
+    }
 };
 
 
-- 
2.17.1

Reply via email to