aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaiki Ueno2016-05-20 19:34:06 +0900
committerDaiki Ueno2016-05-20 19:34:06 +0900
commitdadfc30dae9529282a05720155d4aa1c5bd749b1 (patch)
tree89df0bbe7ab1346d6998ff122549deb647beb144 /test
parente41a5cbae9d208a191884e634f77ab6ccc990e64 (diff)
downloademacs-dadfc30dae9529282a05720155d4aa1c5bd749b1.tar.gz
emacs-dadfc30dae9529282a05720155d4aa1c5bd749b1.zip
Revert "epg: Add a way to detect gpg1 executable for tests"
This reverts commit d4ae6d7033b34e8b75c59aaf1584131e439ef2d5.
Diffstat (limited to 'test')
-rw-r--r--test/automated/epg-tests.el42
1 files changed, 18 insertions, 24 deletions
diff --git a/test/automated/epg-tests.el b/test/automated/epg-tests.el
index d51ab23f71e..4a317974ef5 100644
--- a/test/automated/epg-tests.el
+++ b/test/automated/epg-tests.el
@@ -30,17 +30,16 @@
30 (expand-file-name "data/epg" (getenv "EMACS_TEST_DIRECTORY")) 30 (expand-file-name "data/epg" (getenv "EMACS_TEST_DIRECTORY"))
31 "Directory containing epg test data.") 31 "Directory containing epg test data.")
32 32
33(defconst epg-tests-program-alist-for-passphrase-callback 33(defun epg-tests-gpg-usable (&optional require-passphrase)
34 '((OpenPGP 34 (and (executable-find epg-gpg-program)
35 nil 35 (condition-case nil
36 ("gpg" . "1.4.3")))) 36 (progn
37 37 (epg-check-configuration (epg-configuration))
38(defun epg-tests-find-usable-gpg-configuration (&optional require-passphrase) 38 (if require-passphrase
39 (epg-find-configuration 39 (string-match "\\`1\\."
40 'OpenPGP 40 (cdr (assq 'version (epg-configuration))))
41 'no-cache 41 t))
42 (if require-passphrase 42 (error nil))))
43 epg-tests-program-alist-for-passphrase-callback)))
44 43
45(defun epg-tests-passphrase-callback (_c _k _d) 44(defun epg-tests-passphrase-callback (_c _k _d)
46 ;; Need to create a copy here, since the string will be wiped out 45 ;; Need to create a copy here, since the string will be wiped out
@@ -53,14 +52,9 @@
53 &rest body) 52 &rest body)
54 "Set up temporary locations and variables for testing." 53 "Set up temporary locations and variables for testing."
55 (declare (indent 1)) 54 (declare (indent 1))
56 `(let ((epg-tests-home-directory (make-temp-file "epg-tests-homedir" t))) 55 `(let* ((epg-tests-home-directory (make-temp-file "epg-tests-homedir" t)))
57 (unwind-protect 56 (unwind-protect
58 (let ((context (epg-make-context 'OpenPGP))) 57 (let ((context (epg-make-context 'OpenPGP)))
59 (setf (epg-context-program context)
60 (alist-get 'program
61 (epg-tests-find-usable-gpg-configuration
62 ,(if require-passphrase
63 `'require-passphrase))))
64 (setf (epg-context-home-directory context) 58 (setf (epg-context-home-directory context)
65 epg-tests-home-directory) 59 epg-tests-home-directory)
66 (setenv "GPG_AGENT_INFO") 60 (setenv "GPG_AGENT_INFO")
@@ -84,7 +78,7 @@
84 (delete-directory epg-tests-home-directory t))))) 78 (delete-directory epg-tests-home-directory t)))))
85 79
86(ert-deftest epg-decrypt-1 () 80(ert-deftest epg-decrypt-1 ()
87 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 81 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
88 (with-epg-tests (:require-passphrase t) 82 (with-epg-tests (:require-passphrase t)
89 (should (equal "test" 83 (should (equal "test"
90 (epg-decrypt-string epg-tests-context "\ 84 (epg-decrypt-string epg-tests-context "\
@@ -96,14 +90,14 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
96-----END PGP MESSAGE-----"))))) 90-----END PGP MESSAGE-----")))))
97 91
98(ert-deftest epg-roundtrip-1 () 92(ert-deftest epg-roundtrip-1 ()
99 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 93 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
100 (with-epg-tests (:require-passphrase t) 94 (with-epg-tests (:require-passphrase t)
101 (let ((cipher (epg-encrypt-string epg-tests-context "symmetric" nil))) 95 (let ((cipher (epg-encrypt-string epg-tests-context "symmetric" nil)))
102 (should (equal "symmetric" 96 (should (equal "symmetric"
103 (epg-decrypt-string epg-tests-context cipher)))))) 97 (epg-decrypt-string epg-tests-context cipher))))))
104 98
105(ert-deftest epg-roundtrip-2 () 99(ert-deftest epg-roundtrip-2 ()
106 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 100 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
107 (with-epg-tests (:require-passphrase t 101 (with-epg-tests (:require-passphrase t
108 :require-public-key t 102 :require-public-key t
109 :require-secret-key t) 103 :require-secret-key t)
@@ -114,7 +108,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
114 (epg-decrypt-string epg-tests-context cipher)))))) 108 (epg-decrypt-string epg-tests-context cipher))))))
115 109
116(ert-deftest epg-sign-verify-1 () 110(ert-deftest epg-sign-verify-1 ()
117 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 111 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
118 (with-epg-tests (:require-passphrase t 112 (with-epg-tests (:require-passphrase t
119 :require-public-key t 113 :require-public-key t
120 :require-secret-key t) 114 :require-secret-key t)
@@ -128,7 +122,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
128 (should (eq 'good (epg-signature-status (car verify-result))))))) 122 (should (eq 'good (epg-signature-status (car verify-result)))))))
129 123
130(ert-deftest epg-sign-verify-2 () 124(ert-deftest epg-sign-verify-2 ()
131 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 125 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
132 (with-epg-tests (:require-passphrase t 126 (with-epg-tests (:require-passphrase t
133 :require-public-key t 127 :require-public-key t
134 :require-secret-key t) 128 :require-secret-key t)
@@ -144,7 +138,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
144 (should (eq 'good (epg-signature-status (car verify-result))))))) 138 (should (eq 'good (epg-signature-status (car verify-result)))))))
145 139
146(ert-deftest epg-sign-verify-3 () 140(ert-deftest epg-sign-verify-3 ()
147 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 141 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
148 (with-epg-tests (:require-passphrase t 142 (with-epg-tests (:require-passphrase t
149 :require-public-key t 143 :require-public-key t
150 :require-secret-key t) 144 :require-secret-key t)
@@ -159,7 +153,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
159 (should (eq 'good (epg-signature-status (car verify-result))))))) 153 (should (eq 'good (epg-signature-status (car verify-result)))))))
160 154
161(ert-deftest epg-import-1 () 155(ert-deftest epg-import-1 ()
162 (skip-unless (epg-tests-find-usable-gpg-configuration 'require-passphrase)) 156 (skip-unless (epg-tests-gpg-usable 'require-passphrase))
163 (with-epg-tests (:require-passphrase nil) 157 (with-epg-tests (:require-passphrase nil)
164 (should (= 0 (length (epg-list-keys epg-tests-context)))) 158 (should (= 0 (length (epg-list-keys epg-tests-context))))
165 (should (= 0 (length (epg-list-keys epg-tests-context nil t))))) 159 (should (= 0 (length (epg-list-keys epg-tests-context nil t)))))