aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2018-07-15 09:37:59 -0400
committerNoam Postavsky2018-07-15 16:26:22 -0400
commit7acb87ab97082026e692e1d1d679df2313148343 (patch)
tree19842b8c3c003a01e953b17445d5b11c49518598 /test
parent95931085fafc67aebc62ec0c672d29bfbecd1e8a (diff)
downloademacs-7acb87ab97082026e692e1d1d679df2313148343.tar.gz
emacs-7acb87ab97082026e692e1d1d679df2313148343.zip
Don't test symmetric operations on gpg 2.0 (Bug#23561)
On the Hydra test machines, which have gpg 2.0, the symmetric tests fail. * test/lisp/epg-tests.el (with-epg-tests): Pass REQUIRE-PUBLIC-KEY to `epg-tests-find-usable-gpg-configuration' and call it before `epg-make-context' so that the latter uses the resulting cached config. (epg-tests-find-usable-gpg-configuration): Only allow gpg 2.0 for symmetric operations. Clear `epg--configurations' and don't pass NO-CACHE to `epg-find-configuration'. (epg-tests--config-program-alist): Use copy-tree to avoid modifying the epg-config--program-alist cons values. * test/lisp/emacs-lisp/package-tests.el (package-test-signed): Allow running with gpg 2.0.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/package-tests.el12
-rw-r--r--test/lisp/epg-tests.el33
2 files changed, 31 insertions, 14 deletions
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index b1adfabe525..f08bc92ff2a 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -473,7 +473,17 @@ Must called from within a `tar-mode' buffer."
473 (let ((process-environment 473 (let ((process-environment
474 (cons (concat "HOME=" homedir) 474 (cons (concat "HOME=" homedir)
475 process-environment))) 475 process-environment)))
476 (epg-find-configuration 'OpenPGP)) 476 (epg-find-configuration
477 'OpenPGP nil
478 ;; By default we require gpg2 2.1+ due to some
479 ;; practical problems with pinentry. But this
480 ;; test works fine with 2.0 as well.
481 (let ((prog-alist (copy-tree epg-config--program-alist)))
482 (setf (alist-get "gpg2"
483 (alist-get 'OpenPGP prog-alist)
484 nil nil #'equal)
485 "2.0")
486 prog-alist)))
477 (delete-directory homedir t)))) 487 (delete-directory homedir t))))
478 (let* ((keyring (expand-file-name "key.pub" package-test-data-dir)) 488 (let* ((keyring (expand-file-name "key.pub" package-test-data-dir))
479 (package-test-data-dir 489 (package-test-data-dir
diff --git a/test/lisp/epg-tests.el b/test/lisp/epg-tests.el
index c34e589a4ac..d249e77fb15 100644
--- a/test/lisp/epg-tests.el
+++ b/test/lisp/epg-tests.el
@@ -33,17 +33,26 @@
33 33
34(defconst epg-tests--config-program-alist 34(defconst epg-tests--config-program-alist
35 ;; The default `epg-config--program-alist' requires gpg2 2.1 or 35 ;; The default `epg-config--program-alist' requires gpg2 2.1 or
36 ;; greater due to some practical problems with pinentry. But the 36 ;; greater due to some practical problems with pinentry. But most
37 ;; tests here all work fine with 2.0 as well. 37 ;; tests here work fine with 2.0 as well.
38 (let ((prog-alist (copy-sequence epg-config--program-alist))) 38 (let ((prog-alist (copy-tree epg-config--program-alist)))
39 (setf (alist-get "gpg2" 39 (setf (alist-get "gpg2"
40 (alist-get 'OpenPGP prog-alist) 40 (alist-get 'OpenPGP prog-alist)
41 nil nil #'equal) 41 nil nil #'equal)
42 "2.0") 42 "2.0")
43 prog-alist)) 43 prog-alist))
44 44
45(defun epg-tests-find-usable-gpg-configuration (&optional _require-passphrase) 45(defun epg-tests-find-usable-gpg-configuration
46 (epg-find-configuration 'OpenPGP 'no-cache epg-tests--config-program-alist)) 46 (&optional require-passphrase require-public-key)
47 ;; Clear config cache because we may be using a different
48 ;; program-alist. We do want to update the cache, so that
49 ;; `epg-make-context' can use our result.
50 (setq epg--configurations nil)
51 (epg-find-configuration 'OpenPGP nil
52 ;; The symmetric operations fail on Hydra
53 ;; with gpg 2.0.
54 (if (or (not require-passphrase) require-public-key)
55 epg-tests--config-program-alist)))
47 56
48(defun epg-tests-passphrase-callback (_c _k _d) 57(defun epg-tests-passphrase-callback (_c _k _d)
49 ;; Need to create a copy here, since the string will be wiped out 58 ;; Need to create a copy here, since the string will be wiped out
@@ -63,14 +72,12 @@
63 (format "GNUPGHOME=%s" epg-tests-home-directory)) 72 (format "GNUPGHOME=%s" epg-tests-home-directory))
64 process-environment))) 73 process-environment)))
65 (unwind-protect 74 (unwind-protect
66 (let ((context (epg-make-context 'OpenPGP)) 75 ;; GNUPGHOME is needed to find a usable gpg, so we can't
67 (epg-config (epg-tests-find-usable-gpg-configuration 76 ;; check whether to skip any earlier (Bug#23561).
68 ,(if require-passphrase 77 (let ((epg-config (or (epg-tests-find-usable-gpg-configuration
69 `'require-passphrase)))) 78 ,require-passphrase ,require-public-key)
70 ;; GNUPGHOME is needed to find a usable gpg, so we can't 79 (ert-skip "No usable gpg config")))
71 ;; check whether to skip any earlier (Bug#23561). 80 (context (epg-make-context 'OpenPGP)))
72 (unless epg-config
73 (ert-skip "No usable gpg config"))
74 (setf (epg-context-program context) 81 (setf (epg-context-program context)
75 (alist-get 'program epg-config)) 82 (alist-get 'program epg-config))
76 (setf (epg-context-home-directory context) 83 (setf (epg-context-home-directory context)