emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 cb50077: Fix auth-source-delete (Bug#26184)


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 cb50077: Fix auth-source-delete (Bug#26184)
Date: Tue, 17 Jul 2018 21:31:17 -0400 (EDT)

branch: emacs-26
commit cb50077b1eb7c1467f2f200e01599b391d025bfa
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Fix auth-source-delete (Bug#26184)
    
    * lisp/auth-source.el (auth-source-delete): Fix `auth-source-search'
    call.
    * test/lisp/auth-source-tests.el (auth-source-delete): New test.
---
 lisp/auth-source.el            |  2 +-
 test/lisp/auth-source-tests.el | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index b733054..374b7f1 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -763,7 +763,7 @@ Calls `auth-source-search' with the :delete property in 
SPEC set to t.
 The backend may not actually delete the entries.
 
 Returns the deleted entries."
-  (auth-source-search (plist-put spec :delete t)))
+  (apply #'auth-source-search (plist-put spec :delete t)))
 
 (defun auth-source-search-collection (collection value)
   "Returns t is VALUE is t or COLLECTION is t or COLLECTION contains VALUE."
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index eb93f74..c1ee909 100644
--- a/test/lisp/auth-source-tests.el
+++ b/test/lisp/auth-source-tests.el
@@ -289,5 +289,25 @@
         (should (equal found-as-string (concat testname ": " needed)))))
     (delete-file netrc-file)))
 
+(ert-deftest auth-source-delete ()
+  (let* ((netrc-file (make-temp-file "auth-source-test" nil nil "\
+machine a1 port a2 user a3 password a4
+machine b1 port b2 user b3 password b4
+machine c1 port c2 user c3 password c4\n"))
+         (auth-sources (list netrc-file))
+         (auth-source-do-cache nil)
+         (expected '((:host "a1" :port "a2" :user "a3" :secret "a4")))
+         (parameters '(:max 1 :host t)))
+    (unwind-protect
+        (let ((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)))))
+          ;; Note: The netrc backend doesn't delete anything, so
+          ;; this is actually the same as `auth-source-search'.
+          (should (equal found expected)))
+      (delete-file netrc-file))))
+
 (provide 'auth-source-tests)
 ;;; auth-source-tests.el ends here



reply via email to

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