summaryrefslogtreecommitdiff
path: root/test/lisp/auth-source-tests.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2018-07-17 21:00:27 -0400
committerNoam Postavsky <npostavs@gmail.com>2018-07-17 21:28:26 -0400
commitcb50077b1eb7c1467f2f200e01599b391d025bfa (patch)
tree309f59278873fcda9e73e2149211b0e05f172539 /test/lisp/auth-source-tests.el
parenta4767a662bf360b489059e2cbf028138f2399252 (diff)
downloademacs-cb50077b1eb7c1467f2f200e01599b391d025bfa.tar.gz
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.
Diffstat (limited to 'test/lisp/auth-source-tests.el')
-rw-r--r--test/lisp/auth-source-tests.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index eb93f7488e4..c1ee9093744 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