[Bps-public-commit] GnuPG-Interface branch, work-with-both-gnupgs, updated. 0.52-47-g4cf8081

Aaron Trevena ast at bestpractical.com
Tue May 5 11:55:14 EDT 2020


The branch, work-with-both-gnupgs has been updated
       via  4cf80811f5acb687334251e28dbad9917ab98ed5 (commit)
      from  743c5bada58ae0eb51b1012be37ca5ca1253f991 (commit)

Summary of changes:
 t/get_public_keys.t | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

- Log -----------------------------------------------------------------
commit 4cf80811f5acb687334251e28dbad9917ab98ed5
Author: Aaron Trevena <aaron at aarontrevena.co.uk>
Date:   Tue May 5 16:55:03 2020 +0100

    workaround for some gpg2.2.x expired sig behaviour in keys test

diff --git a/t/get_public_keys.t b/t/get_public_keys.t
index aa1be93..300c81c 100644
--- a/t/get_public_keys.t
+++ b/t/get_public_keys.t
@@ -218,5 +218,40 @@ TEST
 
 TEST
 {
+    # Some versions of GnuPG 2.2.x give same user_id and validity for expired sig as 1.4
+    # this forces them to be consistent and still test them with 2.2 codepath
+    no warnings qw(redefine once);
+    local *GnuPG::Signature::compare = sub {
+        my ($self, $other) = @_;
+        if ($gnupg->cmp_version($gnupg->version, '2.2') > 0) {
+            if ( defined $self->user_id_string and
+                     $self->user_id_string eq 'Frank J. Tobin <ftobin at neverending.org>') {
+                $self->user_id_string('');
+                $self->validity('?');
+            }
+        }
+
+        my @compared_fields = qw(
+                                    validity
+                                    algo_num
+                                    hex_id
+                                    date
+                                    date_string
+                                    sig_class
+                                    is_exportable
+                            );
+
+        foreach my $field ( @compared_fields ) {
+            return 0 unless $self->$field eq $other->$field;
+        }
+        # check for expiration if present?
+        return 0 unless (defined $self->expiration_date) == (defined $other->expiration_date);
+        if (defined $self->expiration_date) {
+            return 0 unless (($self->expiration_date == $other->expiration_date) ||
+                                 ($self->expiration_date_string eq $other->expiration_date_string));
+        }
+        return 1;
+    };
+
     $handmade_key->compare( $given_key, 1 );
 };

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list