Skip to content

Commit

Permalink
dev-perl/GnuPG-Interface: Add Debian patchset
Browse files Browse the repository at this point in the history
Package-Manager: Portage-2.3.6, Repoman-2.3.2
  • Loading branch information
akhuettel committed May 28, 2017
1 parent 9b32ce8 commit b3c40ee
Show file tree
Hide file tree
Showing 20 changed files with 1,740 additions and 0 deletions.
58 changes: 58 additions & 0 deletions dev-perl/GnuPG-Interface/GnuPG-Interface-0.520.0-r2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

DIST_AUTHOR=ALEXMV
DIST_VERSION=0.52
inherit perl-module

DESCRIPTION="Perl module interface to interacting with GnuPG"

SLOT="0"
KEYWORDS="~amd64 ~hppa ~ppc ~x86"
IUSE="test"

RDEPEND="
>=app-crypt/gnupg-1.2.1-r1
virtual/perl-autodie
>=virtual/perl-Math-BigInt-1.780.0
>=dev-perl/Moo-0.91.11
>=dev-perl/MooX-HandlesVia-0.1.4
>=dev-perl/MooX-late-0.14.0
"
DEPEND="${RDEPEND}
>=virtual/perl-ExtUtils-MakeMaker-6.360.0
"

PATCHES=(
"${FILESDIR}/${P}"-0001-fix-spelling-error-settting-should-be-setting.patch
"${FILESDIR}/${P}"-0002-Generalize-the-test-suite.patch
"${FILESDIR}/${P}"-0003-subkey-validity-of-an-key-when-we-have-established-n.patch
"${FILESDIR}/${P}"-0004-ensure-that-test-covers-all-signatures.patch
"${FILESDIR}/${P}"-0005-add-gpg_is_modern-to-test-suite.patch
"${FILESDIR}/${P}"-0006-Modern-GnuPG-2.1-reports-more-detail-about-secret-ke.patch
"${FILESDIR}/${P}"-0007-test-suite-match-plaintext-output-across-versions-of.patch
"${FILESDIR}/${P}"-0008-fix-test_default_key_passphrase-when-passphrase-come.patch
"${FILESDIR}/${P}"-0009-clean-up-trailing-whitespace.patch
"${FILESDIR}/${P}"-0010-fix-capitalization-of-GnuPG.patch
"${FILESDIR}/${P}"-0011-ommand_args-should-be-command_args.patch
"${FILESDIR}/${P}"-0012-use-fingerprints-as-inputs-during-tests-to-demonstra.patch
"${FILESDIR}/${P}"-0013-move-key-files-to-generic-names.patch
"${FILESDIR}/${P}"-0014-fix-spelling-s-convience-convenience.patch
"${FILESDIR}/${P}"-0015-added-new-secret-key-with-different-passphrase.patch
"${FILESDIR}/${P}"-0016-Test-use-of-gpg-without-explicit-passphrase-agent-pi.patch
"${FILESDIR}/${P}"-0017-Kill-any-GnuPG-agent-before-and-after-the-test-suite.patch
"${FILESDIR}/${P}"-0018-Use-a-short-temporary-homedir-during-the-test-suite.patch
"${FILESDIR}/${P}"-0019-Make-things-work-with-gpg1-assuming-plain-gpg-is-mod.patch
)

DIST_TEST=skip
# Nearly all tests succeed with this patchset and GnuPG 2.1 when running outside the
# emerge sandbox. However, the agent architecture is not really sandbox-friendly, so...
#
# Test Summary Report
# -------------------
# t/decrypt.t (Wstat: 0 Tests: 6 Failed: 2)
# Failed tests: 5-6
# Failed 1/22 test programs. 2/56 subtests failed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From: Daniel Kahn Gillmor <[email protected]>
Date: Tue, 13 Sep 2016 07:26:00 +0200
Subject: fix spelling error ("settting" should be "setting")

---
README | 2 +-
lib/GnuPG/Interface.pm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README b/README
index fcb982a..f457577 100644
--- a/README
+++ b/README
@@ -6,7 +6,7 @@ SYNOPSIS
use IO::Handle;
use GnuPG::Interface;

- # settting up the situation
+ # setting up the situation
my $gnupg = GnuPG::Interface->new();
$gnupg->options->hash_init( armor => 1,
homedir => '/home/foobar' );
diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index f952f3e..83a4b1a 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -834,7 +834,7 @@ GnuPG::Interface - Perl interface to GnuPG
use IO::Handle;
use GnuPG::Interface;

- # settting up the situation
+ # setting up the situation
my $gnupg = GnuPG::Interface->new();
$gnupg->options->hash_init( armor => 1,
homedir => '/home/foobar' );
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
From: Daniel Kahn Gillmor <[email protected]>
Date: Tue, 13 Sep 2016 10:38:12 -0400
Subject: Generalize the test suite

The test suite currently assumes it knows something about the internal
state of GnuPG's homedir.

It's safer and less brittle to rely explicitly on the public interface
that GnuPG has committed to, such as --import-keys and --list-keys,
rather than assuming that certain files are in certain places in the
GnuPG homedir.

It's also better to create a fresh homedir and allow GnuPG to populate
it during the test suite, cleaning it up at the end, rather than hope
that GnuPG will leave a pre-existing homedir untouched.

With this change, many more of the tests pass when /usr/bin/gpg is
provided by GnuPG 2.1.
---
t/000_setup.t | 28 ++++++++++++++++++++++++++++
t/MyTestSpecific.pm | 2 +-
t/zzz_cleanup.t | 17 +++++++++++++++++
test/fake-pinentry.pl | 28 ++++++++++++++++++++++++++++
test/{options => gpg.conf} | 0
test/secret-keys/1.0.test | 4 ++--
6 files changed, 76 insertions(+), 3 deletions(-)
create mode 100644 t/000_setup.t
create mode 100644 t/zzz_cleanup.t
create mode 100755 test/fake-pinentry.pl
rename test/{options => gpg.conf} (100%)

diff --git a/t/000_setup.t b/t/000_setup.t
new file mode 100644
index 0000000..7f7f7b0
--- /dev/null
+++ b/t/000_setup.t
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+
+use strict;
+use English qw( -no_match_vars );
+
+use lib './t';
+use MyTest;
+use MyTestSpecific;
+use Cwd;
+use File::Path qw (make_path);
+use File::Copy;
+
+TEST
+{
+ make_path('test/gnupghome', { mode => 0700 });
+ my $agentconf = IO::File->new( "> test/gnupghome/gpg-agent.conf" );
+ $agentconf->write("pinentry-program " . getcwd() . "/test/fake-pinentry.pl\n");
+ $agentconf->close();
+ copy('test/gpg.conf', 'test/gnupghome/gpg.conf');
+ reset_handles();
+
+ my $pid = $gnupg->import_keys(command_args => [ 'test/pubring.gpg', 'test/secring.gpg' ],
+ options => [ 'batch'],
+ handles => $handles);
+ waitpid $pid, 0;
+
+ return $CHILD_ERROR == 0;
+};
diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm
index 053b749..1af98ae 100644
--- a/t/MyTestSpecific.pm
+++ b/t/MyTestSpecific.pm
@@ -40,7 +40,7 @@ use vars qw( @ISA @EXPORT

$gnupg = GnuPG::Interface->new( passphrase => 'test' );

-$gnupg->options->hash_init( homedir => 'test',
+$gnupg->options->hash_init( homedir => 'test/gnupghome',
armor => 1,
meta_interactive => 0,
meta_signing_key_id => '0xF950DA9C',
diff --git a/t/zzz_cleanup.t b/t/zzz_cleanup.t
new file mode 100644
index 0000000..5c03a72
--- /dev/null
+++ b/t/zzz_cleanup.t
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+
+use strict;
+use English qw( -no_match_vars );
+
+use lib './t';
+use MyTest;
+use MyTestSpecific;
+use File::Path qw (remove_tree);
+
+# this is actually no test, just cleanup.
+TEST
+{
+ my $err = [];
+ remove_tree('test/gnupghome', {error => \$err});
+ return ! @$err;
+};
diff --git a/test/fake-pinentry.pl b/test/fake-pinentry.pl
new file mode 100755
index 0000000..12d3611
--- /dev/null
+++ b/test/fake-pinentry.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+# Use this for your test suites when a perl interpreter is available.
+#
+# The encrypted keys in your test suite that you expect to work must
+# be locked with a passphrase of "test"
+#
+# Author: Daniel Kahn Gillmor <[email protected]>
+#
+# License: This trivial work is hereby explicitly placed into the
+# public domain. Anyone may reuse it, modify it, redistribute it for
+# any purpose.
+
+use strict;
+use warnings;
+
+# turn off buffering
+$| = 1;
+
+print "OK This is only for test suites, and should never be used in production\n";
+while (<STDIN>) {
+ chomp;
+ next if (/^$/);
+ next if (/^#/);
+ print ("D test\n") if (/^getpin/i);
+ print "OK\n";
+ exit if (/^bye/i);
+}
+1;
diff --git a/test/options b/test/gpg.conf
similarity index 100%
rename from test/options
rename to test/gpg.conf
diff --git a/test/secret-keys/1.0.test b/test/secret-keys/1.0.test
index 5999484..129d472 100644
--- a/test/secret-keys/1.0.test
+++ b/test/secret-keys/1.0.test
@@ -1,5 +1,5 @@
-test/secring.gpg
-----------------
+test/gnupghome/secring.gpg
+--------------------------
sec 1024D/F950DA9C 2000-02-06
uid GnuPG test key (for testing purposes only)
uid Foo Bar (1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From: Daniel Kahn Gillmor <[email protected]>
Date: Tue, 13 Sep 2016 11:35:31 -0400
Subject: subkey validity of an key when we have established no trust anchors

This apparently isn't tested by deep comparisons, though, so it was
never caught.
---
t/get_public_keys.t | 2 +-
t/get_secret_keys.t | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/get_public_keys.t b/t/get_public_keys.t
index 53db021..73e320b 100644
--- a/t/get_public_keys.t
+++ b/t/get_public_keys.t
@@ -175,7 +175,7 @@ TEST
];

my $subkey = GnuPG::SubKey->new
- ( validity => 'u',
+ ( validity => '-',
length => 768,
algo_num => 16,
hex_id => 'ADB99D9C2E854A6B',
diff --git a/t/get_secret_keys.t b/t/get_secret_keys.t
index 3a1d99f..7bba083 100644
--- a/t/get_secret_keys.t
+++ b/t/get_secret_keys.t
@@ -48,7 +48,7 @@ TEST


my $subkey = GnuPG::SubKey->new
- ( validity => 'u',
+ ( validity => '-',
length => 768,
algo_num => 16,
hex_id => 'ADB99D9C2E854A6B',
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From: Daniel Kahn Gillmor <[email protected]>
Date: Tue, 13 Sep 2016 11:39:04 -0400
Subject: ensure that test covers all signatures

The earlier test wasn't reporting on one of the known self-sigs for
the test key for some reason.

This change ensures that all known signatures are present.
---
t/get_public_keys.t | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/t/get_public_keys.t b/t/get_public_keys.t
index 73e320b..9e96f7d 100644
--- a/t/get_public_keys.t
+++ b/t/get_public_keys.t
@@ -83,7 +83,17 @@ TEST
date_string => '2000-02-06',
hex_id => '53AE596EF950DA9C',
sig_class => 0x13,
- validity => '!'));
+ validity => '!'),
+ GnuPG::Signature->new(
+ date => 1177086329,
+ algo_num => 17,
+ is_exportable => 1,
+ user_id_string => 'GnuPG test key (for testing purposes only)',
+ date_string => '2007-04-20',
+ hex_id => '53AE596EF950DA9C',
+ sig_class => 0x13,
+ validity => '!'),
+ );

my $uid1 = GnuPG::UserId->new( as_string => 'Foo Bar (1)',
validity => '-');
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From: Daniel Kahn Gillmor <[email protected]>
Date: Tue, 13 Sep 2016 14:31:38 -0400
Subject: add $gpg_is_modern to test suite

MyTestSpecific.pm now produces a new variable indicating whether it
the version of GnuPG we run against is from the "Modern" line of GnuPG
development (2.1 or later). This will be useful when comparing output
that we can't expect from earlier versions.
---
t/MyTestSpecific.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm
index 1af98ae..a309698 100644
--- a/t/MyTestSpecific.pm
+++ b/t/MyTestSpecific.pm
@@ -29,17 +29,20 @@ use GnuPG::Handles;
use vars qw( @ISA @EXPORT
$stdin $stdout $stderr
$gpg_program $handles $gnupg
- %texts
+ %texts $gpg_is_modern
);

@ISA = qw( Exporter );
@EXPORT = qw( stdin stdout stderr
gnupg_program handles reset_handles
- texts file_match
+ texts file_match gpg_is_modern
);

$gnupg = GnuPG::Interface->new( passphrase => 'test' );

+my @version = split('\.', $gnupg->version());
+$gpg_is_modern = ($version[0] > 2 || ($version[0] == 2 && $version[1] >= 1));
+
$gnupg->options->hash_init( homedir => 'test/gnupghome',
armor => 1,
meta_interactive => 0,
Loading

0 comments on commit b3c40ee

Please sign in to comment.