aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2017-02-21 20:46:15 -0500
committerNoam Postavsky2017-02-28 19:57:35 -0500
commitb7250496bd2d681a7a7f3c958eb3f0047b5c0a22 (patch)
tree45ade9b45313fcca74a6c018d186dc4d24a2f681 /test
parent7b5e1c8238ef961fd3305b1dce053b9bced684ba (diff)
downloademacs-b7250496bd2d681a7a7f3c958eb3f0047b5c0a22.tar.gz
emacs-b7250496bd2d681a7a7f3c958eb3f0047b5c0a22.zip
Fix epg-tests with dummy-pinentry program (Bug#23619)
* test/data/epg/dummy-pinentry: New file. * test/lisp/epg-tests.el (with-epg-tests): Add it to gpg-agent.conf when a passphrase is required. Add debug declaration. Set GPG_AGENT_INFO non-destructively.
Diffstat (limited to 'test')
-rwxr-xr-xtest/data/epg/dummy-pinentry22
-rw-r--r--test/lisp/epg-tests.el18
2 files changed, 34 insertions, 6 deletions
diff --git a/test/data/epg/dummy-pinentry b/test/data/epg/dummy-pinentry
new file mode 100755
index 00000000000..2228dfb0c6d
--- /dev/null
+++ b/test/data/epg/dummy-pinentry
@@ -0,0 +1,22 @@
1#! /bin/bash
2# Dummy pinentry
3#
4# Copyright 2008 g10 Code GmbH
5#
6# This file is free software; as a special exception the author gives
7# unlimited permission to copy and/or distribute it, with or without
8# modifications, as long as this notice is preserved.
9#
10# This file is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
12# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13# PURPOSE.
14
15echo OK Your orders please
16
17while read cmd; do
18 case $cmd in
19 GETPIN) echo D test0123456789; echo OK;;
20 *) echo OK;;
21 esac
22done
diff --git a/test/lisp/epg-tests.el b/test/lisp/epg-tests.el
index ea2b62c3584..c61527207ff 100644
--- a/test/lisp/epg-tests.el
+++ b/test/lisp/epg-tests.el
@@ -52,8 +52,9 @@
52 require-secret-key) 52 require-secret-key)
53 &rest body) 53 &rest body)
54 "Set up temporary locations and variables for testing." 54 "Set up temporary locations and variables for testing."
55 (declare (indent 1)) 55 (declare (indent 1) (debug (sexp body)))
56 `(let ((epg-tests-home-directory (make-temp-file "epg-tests-homedir" t))) 56 `(let ((epg-tests-home-directory (make-temp-file "epg-tests-homedir" t))
57 (process-environment (cons "GPG_AGENT_INFO" process-environment)))
57 (unwind-protect 58 (unwind-protect
58 (let ((context (epg-make-context 'OpenPGP))) 59 (let ((context (epg-make-context 'OpenPGP)))
59 (setf (epg-context-program context) 60 (setf (epg-context-program context)
@@ -63,11 +64,16 @@
63 `'require-passphrase)))) 64 `'require-passphrase))))
64 (setf (epg-context-home-directory context) 65 (setf (epg-context-home-directory context)
65 epg-tests-home-directory) 66 epg-tests-home-directory)
66 (setenv "GPG_AGENT_INFO")
67 ,(if require-passphrase 67 ,(if require-passphrase
68 `(epg-context-set-passphrase-callback 68 `(with-temp-file (expand-file-name
69 context 69 "gpg-agent.conf" epg-tests-home-directory)
70 #'epg-tests-passphrase-callback)) 70 (insert "pinentry-program "
71 (expand-file-name "dummy-pinentry"
72 epg-tests-data-directory)
73 "\n")
74 (epg-context-set-passphrase-callback
75 context
76 #'epg-tests-passphrase-callback)))
71 ,(if require-public-key 77 ,(if require-public-key
72 `(epg-import-keys-from-file 78 `(epg-import-keys-from-file
73 context 79 context