diff options
| author | Noam Postavsky | 2018-07-17 21:00:27 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-07-17 21:28:26 -0400 |
| commit | cb50077b1eb7c1467f2f200e01599b391d025bfa (patch) | |
| tree | 309f59278873fcda9e73e2149211b0e05f172539 | |
| parent | a4767a662bf360b489059e2cbf028138f2399252 (diff) | |
| download | emacs-cb50077b1eb7c1467f2f200e01599b391d025bfa.tar.gz emacs-cb50077b1eb7c1467f2f200e01599b391d025bfa.zip | |
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.
| -rw-r--r-- | lisp/auth-source.el | 2 | ||||
| -rw-r--r-- | test/lisp/auth-source-tests.el | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el index b733054ae5f..374b7f1e86c 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. | |||
| 763 | The backend may not actually delete the entries. | 763 | The backend may not actually delete the entries. |
| 764 | 764 | ||
| 765 | Returns the deleted entries." | 765 | Returns the deleted entries." |
| 766 | (auth-source-search (plist-put spec :delete t))) | 766 | (apply #'auth-source-search (plist-put spec :delete t))) |
| 767 | 767 | ||
| 768 | (defun auth-source-search-collection (collection value) | 768 | (defun auth-source-search-collection (collection value) |
| 769 | "Returns t is VALUE is t or COLLECTION is t or COLLECTION contains VALUE." | 769 | "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 eb93f7488e4..c1ee9093744 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -289,5 +289,25 @@ | |||
| 289 | (should (equal found-as-string (concat testname ": " needed))))) | 289 | (should (equal found-as-string (concat testname ": " needed))))) |
| 290 | (delete-file netrc-file))) | 290 | (delete-file netrc-file))) |
| 291 | 291 | ||
| 292 | (ert-deftest auth-source-delete () | ||
| 293 | (let* ((netrc-file (make-temp-file "auth-source-test" nil nil "\ | ||
| 294 | machine a1 port a2 user a3 password a4 | ||
| 295 | machine b1 port b2 user b3 password b4 | ||
| 296 | machine c1 port c2 user c3 password c4\n")) | ||
| 297 | (auth-sources (list netrc-file)) | ||
| 298 | (auth-source-do-cache nil) | ||
| 299 | (expected '((:host "a1" :port "a2" :user "a3" :secret "a4"))) | ||
| 300 | (parameters '(:max 1 :host t))) | ||
| 301 | (unwind-protect | ||
| 302 | (let ((found (apply #'auth-source-delete parameters))) | ||
| 303 | (dolist (f found) | ||
| 304 | (let ((s (plist-get f :secret))) | ||
| 305 | (setf f (plist-put f :secret | ||
| 306 | (if (functionp s) (funcall s) s))))) | ||
| 307 | ;; Note: The netrc backend doesn't delete anything, so | ||
| 308 | ;; this is actually the same as `auth-source-search'. | ||
| 309 | (should (equal found expected))) | ||
| 310 | (delete-file netrc-file)))) | ||
| 311 | |||
| 292 | (provide 'auth-source-tests) | 312 | (provide 'auth-source-tests) |
| 293 | ;;; auth-source-tests.el ends here | 313 | ;;; auth-source-tests.el ends here |