[Pkg-privacy-commits] [msva-perl] 312/356: Add gpg key generation from rfc822 template file.

Ximin Luo infinity0 at moszumanska.debian.org
Mon Aug 24 07:42:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository msva-perl.

commit f86f7052663258161c4b9db4f10678c4216a9b84
Author: David Bremner <bremner at unb.ca>
Date:   Sat Mar 19 08:22:35 2011 -0300

    Add gpg key generation from rfc822 template file.
    
    This is pretty much translated from tests/basic.  It is unfortunately
    a bit more verbose in perl. It could be made shorter by avoiding
    GnuPG::Interface.
---
 unit-tests/keys.txt     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 unit-tests/run-tests.pl | 30 ++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/unit-tests/keys.txt b/unit-tests/keys.txt
new file mode 100644
index 0000000..61e6563
--- /dev/null
+++ b/unit-tests/keys.txt
@@ -0,0 +1,47 @@
+# For use with gpg --batch --gen-key
+
+Key-Type: DSA
+Key-Length: 1024
+Subkey-Type: ELG-E
+Subkey-Length: 1024
+Name-Real: Joe Tester
+Name-Email: joe at example.net
+Expire-Date: 0
+
+Key-Type: RSA
+Key-Length: 2048
+Key-Usage: sign
+Subkey-Type: RSA
+Subkey-Length: 1024
+Subkey-Usage: auth
+Name-Real: Joe Tester
+Name-Email: joe at example.net
+Expire-Date: 0
+
+Key-Type: RSA
+Key-Length: 2048
+Key-Usage: sign
+Subkey-Type: RSA
+Subkey-Length: 1024
+Subkey-Usage: sign
+Name-Real: Joe Tester
+Name-Email: joe at example.net
+Expire-Date: 0
+
+Key-Type: RSA
+Key-Length: 2048
+Key-Usage: auth
+Name-Real: Joe Tester
+Name-Email: joe at example.net
+Expire-Date: 0
+
+Key-Type: RSA
+Key-Length: 2048
+Key-Usage: encrypt
+Subkey-Type: RSA
+Subkey-Length: 1024
+Subkey-Usage: auth
+Name-Real: Joe Tester
+Name-Email: jojo at example.net
+Expire-Date: 0
+
diff --git a/unit-tests/run-tests.pl b/unit-tests/run-tests.pl
index 4c3731c..0764b65 100644
--- a/unit-tests/run-tests.pl
+++ b/unit-tests/run-tests.pl
@@ -4,9 +4,39 @@ use strict;
 use TAP::Harness;
 use File::Find;
 use FindBin;
+use GnuPG::Interface;
+use GnuPG::Handles;
+use File::Temp qw(tempdir);
+
 my $BINDIR;
 BEGIN { $BINDIR = $FindBin::Bin; }
 
+
+{ 
+# Generate Keys from template file
+
+  my $tempdir = tempdir("/tmp/test-gnupgXXXXX", CLEANUP=> 1);
+  my $gnupg = new GnuPG::Interface();
+  $gnupg->options->hash_init(homedir=>$tempdir,batch=>1);
+
+  my $GPGQR='';
+  if (system qw(gpg --quick-random --version) ==0) {
+    $GPGQR='--quick-random';
+  } elsif (system qw(gpg --debug-quick-random --version) ==0) {
+    $GPGQR='--debug-quick-random';
+  }
+
+  print STDERR "WARNING: no quick random option found. Tests may hang!\n" 
+    unless(scalar $GPGQR);
+
+  my $pid = $gnupg->wrap_call( commands=>[qw(--gen-key --batch),$GPGQR],
+			       command_args=>[$BINDIR.'/keys.txt'],
+			       handles=>new GnuPG::Handles() );
+  waitpid $pid,0;
+
+  $ENV{GNUPGHOME}=$tempdir;
+}
+
 my @dirs = scalar(@ARGV) > 0 ? @ARGV : ($BINDIR);
 
 my @tests;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/msva-perl.git



More information about the Pkg-privacy-commits mailing list