emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4d621ffd30 2/2: Use 'auth-info-password' in tests


From: Sam Steingold
Subject: master 4d621ffd30 2/2: Use 'auth-info-password' in tests
Date: Mon, 10 Jan 2022 20:53:07 -0500 (EST)

branch: master
commit 4d621ffd30749de93519161c5094e40ee1b08fb6
Author: Sam Steingold <sds@gnu.org>
Commit: Sam Steingold <sds@gnu.org>

    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.
---
 test/lisp/auth-source-tests.el | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index 7060d9570e..41f8b6d8c9 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)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]