[Pkg-gnupg-commit] [gnupg2] 46/292: tests: Port the quick key manipulation test to Scheme.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:24 UTC 2016


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

dkg pushed a commit to branch master
in repository gnupg2.

commit 6c4c0e3ac2aeafba7a2b7c2dd92a18be8aec92b1
Author: Justus Winter <justus at g10code.com>
Date:   Tue Sep 20 14:33:16 2016 +0200

    tests: Port the quick key manipulation test to Scheme.
    
    * tests/openpgp/Makefile.am (XTESTS): Add new test.
    * tests/openpgp/quick-key-manipulation.scm: New file.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/openpgp/Makefile.am                |  1 +
 tests/openpgp/quick-key-manipulation.scm | 66 ++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index 43de31e..67fb2bc 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -82,6 +82,7 @@ XTESTS = \
 	default-key.scm \
 	export.scm \
 	ssh.scm \
+	quick-key-manipulation.scm \
 	issue2015.scm \
 	issue2346.scm \
 	issue2417.scm \
diff --git a/tests/openpgp/quick-key-manipulation.scm b/tests/openpgp/quick-key-manipulation.scm
new file mode 100755
index 0000000..f2b8766
--- /dev/null
+++ b/tests/openpgp/quick-key-manipulation.scm
@@ -0,0 +1,66 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "defs.scm"))
+
+ ;; XXX because of --always-trust, the trustdb is not created.
+ ;; Therefore, we redefine GPG without --always-trust.
+(define GPG `(,(tool 'gpg) --no-permission-warning))
+
+(define (exact id)
+  (string-append "=" id))
+
+(define (count-uids-of-secret-key id)
+  (length (filter (lambda (x) (and (string=? "uid" (car x))
+				   (string=? "u" (cadr x))))
+		  (gpg-with-colons
+		   `(--with-fingerprint
+		     --list-secret-keys ,(exact id))))))
+
+(define old-home (getenv "GNUPGHOME"))
+(define alpha "Alpha <alpha at example.net>")
+(define bravo "Bravo <bravo at example.net>")
+
+(with-temporary-working-directory
+ (file-copy (path-join old-home "gpg.conf") "gpg.conf")
+ (file-copy (path-join old-home "gpg-agent.conf") "gpg-agent.conf")
+ (setenv "GNUPGHOME" "." #t)
+ (setenv "PINENTRY_USER_DATA" "test" #t)
+
+ (info "Checking quick key generation...")
+ (call-check `(, at GPG --quick-gen-key ,alpha))
+
+ (call-check `(, at GPG --check-trustdb)) ; XXX why?
+
+ (assert (= 1 (count-uids-of-secret-key alpha)))
+
+ (info "Checking that we can add a user ID...")
+ (call-check `(, at GPG --quick-adduid ,(exact alpha) ,bravo))
+
+ (call-check `(, at GPG --check-trustdb)) ; XXX why?
+
+ (assert (= 2 (count-uids-of-secret-key alpha)))
+ (assert (= 2 (count-uids-of-secret-key bravo)))
+
+ (info "Checking that we can revoke a user ID...")
+ (call-check `(, at GPG --quick-revuid ,(exact bravo) ,alpha))
+
+ (call-check `(, at GPG --check-trustdb)) ; XXX why?
+
+ (assert (= 1 (count-uids-of-secret-key bravo))))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list