]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix auth-source-pass to return nil if no entry found
authorMagnus Henoch <magnus.henoch@gmail.com>
Fri, 2 Nov 2018 21:51:59 +0000 (21:51 +0000)
committerDamien Cassou <damien@cassou.me>
Mon, 24 Jun 2019 07:15:39 +0000 (09:15 +0200)
* 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

lisp/auth-source-pass.el
test/lisp/auth-source-pass-tests.el

index 4283ed0392bc5e0a2f94bff045019990ce778de4..c82c90167a07331b739ffc6eab577b02253c0168 100644 (file)
@@ -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."
index d1e486ad6be9e0f16cd123203551af614bf9971f..ab9ef92c1443d52adadaaf0f95d44a2e9ed66370 100644 (file)
@@ -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"))