diff options
Diffstat (limited to 'test/lisp/auth-source-tests.el')
-rw-r--r-- | test/lisp/auth-source-tests.el | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index 6f832725754..ab1a437b303 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el @@ -341,13 +341,14 @@ (should (string-equal (plist-get auth-info :user) (user-login-name))) (should (string-equal (plist-get auth-info :host) host)) - (should (string-equal auth-passwd passwd))))) + (should (string-equal auth-passwd passwd)))) - ;; Cleanup. - ;; Should use `auth-source-delete' when implemented for :secrets backend. - (secrets-delete-item - "session" - (format "%s@%s" (plist-get auth-info :user) (plist-get auth-info :host)))))) + ;; Cleanup. + ;; Should use `auth-source-delete' when implemented for :secrets backend. + (secrets-delete-item + "session" + (format + "%s@%s" (plist-get auth-info :user) (plist-get auth-info :host))))))) (ert-deftest auth-source-test-netrc-create-secret () (ert-with-temp-file netrc-file @@ -434,5 +435,25 @@ machine c1 port c2 user c3 password c4\n" '((("machine" . "XM") ("login" . "XL") ("password" . "XP")) (("machine" . "YM") ("login" . "YL") ("password" . "YP"))))))) +(ert-deftest test-macos-keychain-search () + "Test if the constructed command line arglist is correct." + (let ((auth-sources '(macos-keychain-internet macos-keychain-generic))) + ;; Redefine `call-process' to check command line arguments. + (cl-letf (((symbol-function 'call-process) + (lambda (_program _infile _destination _display + &rest args) + ;; Arguments must be all strings + (should (cl-every #'stringp args)) + ;; Argument number should be even + (should (cl-evenp (length args))) + (should (cond ((string= (car args) "find-internet-password") + (let ((protocol (cl-member "-r" args :test #'string=))) + (if protocol + (= 4 (length (cadr protocol))) + t))) + ((string= (car args) "find-generic-password") + t)))))) + (auth-source-search :user '("a" "b") :host '("example.org") :port '("irc" "ftp" "https"))))) + (provide 'auth-source-tests) ;;; auth-source-tests.el ends here |