[Bps-public-commit] GnuPG-Interface branch, update-version-if-call-is-updated, created. 0.52-57-gfc26385
Dianne Skoll
dianne at bestpractical.com
Tue Aug 11 11:05:05 EDT 2020
The branch, update-version-if-call-is-updated has been created
at fc26385e0d65b71bed96294f0ea18133d9fce735 (commit)
- Log -----------------------------------------------------------------
commit fc26385e0d65b71bed96294f0ea18133d9fce735
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Tue Aug 11 11:01:30 2020 -0400
Make $gnupg->call('foo') update the internal GnuPG version number.
Before, if you set the GPG executable using call(), and the
version was different from the version used in the constructor,
GnuPG::Interface would pass the wrong options to the program.
This patch makes sure the executable and the version number
are always in sync.
diff --git a/MANIFEST b/MANIFEST
index 7c04bb9..8b9c4a4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -50,10 +50,13 @@ t/sign.t
t/sign_and_encrypt.t
t/UserId.t
t/verify.t
+t/version_updates.t
t/wrap_call.t
t/zzz_cleanup.t
test/encrypted.1.gpg
test/encrypted.2.gpg
+test/fake-gpg-v1
+test/fake-gpg-v2
test/fake-pinentry.pl
test/gpg.conf
test/key.1.asc
diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index b11e4d2..8625707 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -30,11 +30,18 @@ use GnuPG::Handles;
$VERSION = '1.00';
-has $_ => (
+has passphrase => (
isa => 'Any',
is => 'rw',
- clearer => 'clear_' . $_,
-) for qw(call passphrase);
+ clearer => 'clear_passphrase',
+);
+
+has call => (
+ isa => 'Any',
+ is => 'rw',
+ trigger => 1,
+ clearer => 'clear_call',
+);
# NB: GnuPG versions
#
@@ -82,6 +89,12 @@ struct(
}
);
+# Update version if "call" is updated
+sub _trigger_call {
+ my ($self, $gpg) = @_;
+ $self->_set_version($self->_version());
+}
+
#################################################################
# real worker functions
diff --git a/t/Interface.t b/t/Interface.t
index 6d97956..6cd0eb9 100644
--- a/t/Interface.t
+++ b/t/Interface.t
@@ -24,6 +24,12 @@ TEST
# deprecation test
TEST
{
- $gnupg->gnupg_call( $v2 );
+ # We wrap the next call in an "eval" because
+ # setting call tries to execute the program
+ # to figure out the version, which will
+ # fail if "gnupg" is not found... but we
+ # don't care about the version for the
+ # purpose of this test.
+ eval { $gnupg->gnupg_call( $v2 ); };
$gnupg->call() eq $v2;
};
diff --git a/t/version_updates.t b/t/version_updates.t
new file mode 100644
index 0000000..f00e58e
--- /dev/null
+++ b/t/version_updates.t
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+#
+# $Id: wrap_call.t,v 1.1 2001/05/03 07:32:34 ftobin Exp $
+#
+
+use strict;
+
+use lib './t';
+use MyTest;
+use MyTestSpecific;
+
+TEST
+{
+ my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v1');
+ return ($gpg->version() eq '1.4.23');
+};
+
+
+TEST
+{
+ my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v2');
+ return ($gpg->version() eq '2.2.12');
+};
+
+TEST
+{
+ my $gpg = GnuPG::Interface->new(call => './test/fake-gpg-v1');
+ my $v1 = $gpg->version();
+ $gpg->call('./test/fake-gpg-v2');
+ my $v2 = $gpg->version();
+
+ return ($v1 eq '1.4.23' && $v2 eq '2.2.12');
+}
diff --git a/test/fake-gpg-v1 b/test/fake-gpg-v1
new file mode 100755
index 0000000..0a2a68f
--- /dev/null
+++ b/test/fake-gpg-v1
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'gpg (GnuPG) 1.4.23'
diff --git a/test/fake-gpg-v2 b/test/fake-gpg-v2
new file mode 100755
index 0000000..2578a44
--- /dev/null
+++ b/test/fake-gpg-v2
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'gpg (GnuPG) 2.2.12'
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list