diff options
| author | LdBeth | 2023-08-13 18:31:47 +0200 |
|---|---|---|
| committer | Michael Albinus | 2023-08-13 18:31:47 +0200 |
| commit | 14cd2a058e56d63bab08190826559521083a7d05 (patch) | |
| tree | 0c0205ece2e3083be905983bcc246056a6e3d133 /test | |
| parent | ba914bd9c953c3157390a5b535e042ae42cd0179 (diff) | |
| download | emacs-14cd2a058e56d63bab08190826559521083a7d05.tar.gz emacs-14cd2a058e56d63bab08190826559521083a7d05.zip | |
Fix auth-source-macos-keychain (bug#64977)
* lisp/auth-source.el (auth-source-macos-keychain-search)
(auth-source-macos-keychain-search-items): Fix handling of user
and port.
* test/lisp/auth-source-tests.el (test-macos-keychain-search): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/auth-source-tests.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index ef915e5fc5b..ab1a437b303 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -435,5 +435,25 @@ machine c1 port c2 user c3 password c4\n" | |||
| 435 | '((("machine" . "XM") ("login" . "XL") ("password" . "XP")) | 435 | '((("machine" . "XM") ("login" . "XL") ("password" . "XP")) |
| 436 | (("machine" . "YM") ("login" . "YL") ("password" . "YP"))))))) | 436 | (("machine" . "YM") ("login" . "YL") ("password" . "YP"))))))) |
| 437 | 437 | ||
| 438 | (ert-deftest test-macos-keychain-search () | ||
| 439 | "Test if the constructed command line arglist is correct." | ||
| 440 | (let ((auth-sources '(macos-keychain-internet macos-keychain-generic))) | ||
| 441 | ;; Redefine `call-process' to check command line arguments. | ||
| 442 | (cl-letf (((symbol-function 'call-process) | ||
| 443 | (lambda (_program _infile _destination _display | ||
| 444 | &rest args) | ||
| 445 | ;; Arguments must be all strings | ||
| 446 | (should (cl-every #'stringp args)) | ||
| 447 | ;; Argument number should be even | ||
| 448 | (should (cl-evenp (length args))) | ||
| 449 | (should (cond ((string= (car args) "find-internet-password") | ||
| 450 | (let ((protocol (cl-member "-r" args :test #'string=))) | ||
| 451 | (if protocol | ||
| 452 | (= 4 (length (cadr protocol))) | ||
| 453 | t))) | ||
| 454 | ((string= (car args) "find-generic-password") | ||
| 455 | t)))))) | ||
| 456 | (auth-source-search :user '("a" "b") :host '("example.org") :port '("irc" "ftp" "https"))))) | ||
| 457 | |||
| 438 | (provide 'auth-source-tests) | 458 | (provide 'auth-source-tests) |
| 439 | ;;; auth-source-tests.el ends here | 459 | ;;; auth-source-tests.el ends here |