aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/epg-tests.el36
1 files changed, 30 insertions, 6 deletions
diff --git a/test/lisp/epg-tests.el b/test/lisp/epg-tests.el
index d249e77fb15..a72a917fe9d 100644
--- a/test/lisp/epg-tests.el
+++ b/test/lisp/epg-tests.el
@@ -42,17 +42,34 @@
42 "2.0") 42 "2.0")
43 prog-alist)) 43 prog-alist))
44 44
45(defvar epg-tests--trace nil)
46
45(defun epg-tests-find-usable-gpg-configuration 47(defun epg-tests-find-usable-gpg-configuration
46 (&optional require-passphrase require-public-key) 48 (&optional require-passphrase require-public-key)
47 ;; Clear config cache because we may be using a different 49 ;; Clear config cache because we may be using a different
48 ;; program-alist. We do want to update the cache, so that 50 ;; program-alist. We do want to update the cache, so that
49 ;; `epg-make-context' can use our result. 51 ;; `epg-make-context' can use our result.
50 (setq epg--configurations nil) 52 (setq epg--configurations nil)
51 (epg-find-configuration 'OpenPGP nil 53 ;; Tracing for Bug#23561, but only do it once per run.
52 ;; The symmetric operations fail on Hydra 54 (when epg-tests--trace
53 ;; with gpg 2.0. 55 (dolist (fun '(epg-find-configuration
54 (if (or (not require-passphrase) require-public-key) 56 executable-find
55 epg-tests--config-program-alist))) 57 epg-check-configuration
58 epg-config--make-gpg-configuration))
59 (trace-function-background fun))
60 (setq epg-tests--trace nil))
61 (prog1 (unwind-protect
62 (epg-find-configuration
63 'OpenPGP nil
64 ;; The symmetric operations fail on Hydra
65 ;; with gpg 2.0.
66 (if (or (not require-passphrase) require-public-key)
67 epg-tests--config-program-alist))
68 (untrace-all))
69 (when (get-buffer "*trace-output*")
70 (princ (with-current-buffer "*trace-output*" (prog1 (buffer-string)
71 (erase-buffer)))
72 #'external-debugging-output))))
56 73
57(defun epg-tests-passphrase-callback (_c _k _d) 74(defun epg-tests-passphrase-callback (_c _k _d)
58 ;; Need to create a copy here, since the string will be wiped out 75 ;; Need to create a copy here, since the string will be wiped out
@@ -65,7 +82,8 @@
65 &rest body) 82 &rest body)
66 "Set up temporary locations and variables for testing." 83 "Set up temporary locations and variables for testing."
67 (declare (indent 1) (debug (sexp body))) 84 (declare (indent 1) (debug (sexp body)))
68 `(let* ((epg-tests-home-directory (make-temp-file "epg-tests-homedir" t)) 85 `(let* ((epg-debug epg-tests--trace)
86 (epg-tests-home-directory (make-temp-file "epg-tests-homedir" t))
69 (process-environment 87 (process-environment
70 (append 88 (append
71 (list "GPG_AGENT_INFO" 89 (list "GPG_AGENT_INFO"
@@ -104,10 +122,15 @@
104 (make-local-variable 'epg-tests-context) 122 (make-local-variable 'epg-tests-context)
105 (setq epg-tests-context context) 123 (setq epg-tests-context context)
106 ,@body)) 124 ,@body))
125 (when epg-debug-buffer
126 (princ (with-current-buffer epg-debug-buffer
127 (prog1 (buffer-string) (erase-buffer)))
128 #'external-debugging-output))
107 (when (file-directory-p epg-tests-home-directory) 129 (when (file-directory-p epg-tests-home-directory)
108 (delete-directory epg-tests-home-directory t))))) 130 (delete-directory epg-tests-home-directory t)))))
109 131
110(ert-deftest epg-decrypt-1 () 132(ert-deftest epg-decrypt-1 ()
133 (setq epg-tests--trace t)
111 (with-epg-tests (:require-passphrase t) 134 (with-epg-tests (:require-passphrase t)
112 (should (equal "test" 135 (should (equal "test"
113 (epg-decrypt-string epg-tests-context "\ 136 (epg-decrypt-string epg-tests-context "\
@@ -119,6 +142,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
119-----END PGP MESSAGE-----"))))) 142-----END PGP MESSAGE-----")))))
120 143
121(ert-deftest epg-roundtrip-1 () 144(ert-deftest epg-roundtrip-1 ()
145 (setq epg-tests--trace t)
122 (with-epg-tests (:require-passphrase t) 146 (with-epg-tests (:require-passphrase t)
123 (let ((cipher (epg-encrypt-string epg-tests-context "symmetric" nil))) 147 (let ((cipher (epg-encrypt-string epg-tests-context "symmetric" nil)))
124 (should (equal "symmetric" 148 (should (equal "symmetric"