From: Magnus Henoch Date: Fri, 2 Nov 2018 21:51:59 +0000 (+0000) Subject: Fix auth-source-pass to return nil if no entry found X-Git-Tag: emacs-27.0.90~2288 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=527efaf798ad73878f6df03f5af9d9b0ba517b9d;p=emacs.git Fix auth-source-pass to return nil if no entry found * lisp/auth-source-pass.el (auth-source-pass-search): If there is no matching entry, auth-source-pass-search should return nil, not (nil). This lets auth-source fall back to other backends in the auth-sources list. * test/lisp/auth-source-pass-tests.el: Add corresponding test. Copyright-paperwork-exempt: yes --- diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 4283ed0392b..c82c90167a0 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -56,7 +56,8 @@ See `auth-source-search' for details on SPEC." ;; Do not build a result, as none will match when HOST is nil nil) (t - (list (auth-source-pass--build-result host port user))))) + (when-let ((result (auth-source-pass--build-result host port user))) + (list result))))) (defun auth-source-pass--build-result (host port user) "Build auth-source-pass entry matching HOST, PORT and USER." diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el index d1e486ad6be..ab9ef92c144 100644 --- a/test/lisp/auth-source-pass-tests.el +++ b/test/lisp/auth-source-pass-tests.el @@ -83,6 +83,11 @@ This function is intended to be set to `auth-source-debug`." ("bar")) (should-not (auth-source-pass-search :host nil)))) +(ert-deftest auth-source-pass-not-found () + (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" . "foo-user")) + ("bar")) + (should-not (auth-source-pass-search :host "baz")))) + (ert-deftest auth-source-pass-find-match-matching-at-entry-name () (auth-source-pass--with-store '(("foo"))