diff options
author | Sam Steingold <sds@gnu.org> | 2022-01-09 18:30:25 -0500 |
---|---|---|
committer | Sam Steingold <sds@gnu.org> | 2022-01-10 20:52:20 -0500 |
commit | 4d621ffd30749de93519161c5094e40ee1b08fb6 (patch) | |
tree | f9b4d3762085d16ee595554d944436982bce9aa2 | |
parent | 063375e0ed6a9e06c002744384686defeebd0bf2 (diff) | |
download | emacs-4d621ffd30749de93519161c5094e40ee1b08fb6.tar.gz |
Use 'auth-info-password' in tests
* test/lisp/auth-source-tests.el (auth-source-test-searches):
(auth-source-test-secrets-create-secret):
(auth-source-test-netrc-create-secret, auth-source-delete):
Use 'auth-info-password' instead of ad hoc code.
-rw-r--r-- | test/lisp/auth-source-tests.el | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index 7060d9570eb..41f8b6d8c9d 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el @@ -295,11 +295,7 @@ (setq found (apply #'auth-source-search parameters)) (when (listp found) (dolist (f found) - (setf f (plist-put f :secret - (let ((secret (plist-get f :secret))) - (if (functionp secret) - (funcall secret) - secret)))))) + (setf f (plist-put f :secret (auth-info-password f))))) (setq found-as-string (format "%s: %S" testname found)) ;; (message "With parameters %S found: [%s] needed: [%s]" @@ -326,10 +322,7 @@ auth-info (car (auth-source-search :max 1 :host host :require '(:user :secret) :create t)) - auth-passwd (plist-get auth-info :secret) - auth-passwd (if (functionp auth-passwd) - (funcall auth-passwd) - auth-passwd)) + auth-passwd (auth-info-password auth-info)) (should (string-equal (plist-get auth-info :user) (user-login-name))) (should (string-equal (plist-get auth-info :host) host)) (should (equal auth-passwd passwd)) @@ -339,10 +332,7 @@ ;; Check, that the item has been created indeed. (auth-source-forget+ :host t) (setq auth-info (car (auth-source-search :host host)) - auth-passwd (plist-get auth-info :secret) - auth-passwd (if (functionp auth-passwd) - (funcall auth-passwd) - auth-passwd)) + auth-passwd (auth-info-password auth-info)) (if (zerop (length passwd)) (progn (should-not (plist-get auth-info :user)) @@ -377,10 +367,7 @@ auth-info (car (auth-source-search :max 1 :host host :require '(:user :secret) :create t)) - auth-passwd (plist-get auth-info :secret) - auth-passwd (if (functionp auth-passwd) - (funcall auth-passwd) - auth-passwd)) + auth-passwd (auth-info-password auth-info)) (should (string-equal (plist-get auth-info :user) (user-login-name))) (should (string-equal (plist-get auth-info :host) host)) (should (equal auth-passwd passwd)) @@ -391,10 +378,7 @@ (auth-source-forget+ :host t) (setq auth-source-netrc-cache nil) (setq auth-info (car (auth-source-search :host host)) - auth-passwd (plist-get auth-info :secret) - auth-passwd (if (functionp auth-passwd) - (funcall auth-passwd) - auth-passwd)) + auth-passwd (auth-info-password auth-info)) (with-temp-buffer (insert-file-contents netrc-file) (if (zerop (length passwd)) @@ -421,9 +405,7 @@ machine c1 port c2 user c3 password c4\n" (parameters '(:max 1 :host t)) (found (apply #'auth-source-delete parameters))) (dolist (f found) - (let ((s (plist-get f :secret))) - (setf f (plist-put f :secret - (if (functionp s) (funcall s) s))))) + (setf f (plist-put f :secret (auth-info-password f)))) ;; Note: The netrc backend doesn't delete anything, so ;; this is actually the same as `auth-source-search'. (should (equal found expected))))) |