[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1d2551f 07/14: Fix auth-source-pass.el to properly
From: |
Nicolas Petton |
Subject: |
[Emacs-diffs] master 1d2551f 07/14: Fix auth-source-pass.el to properly handle special inputs |
Date: |
Tue, 5 Jun 2018 09:53:57 -0400 (EDT) |
branch: master
commit 1d2551f8e70ab80a6f57ee11ab70f54aa916adcd
Author: Jelle Licht <address@hidden>
Commit: Nicolas Petton <address@hidden>
Fix auth-source-pass.el to properly handle special inputs
* lisp/auth-source-pass.el (auth-source-pass-search): Warn when
passing multiple hosts in SPEC. Early return and warn when passing a
wildcard as host in SPEC. Early return when host is nil.
* test/lisp/auth-source-pass-tests.el (auth-source-pass-any-host,
auth-source-pass-undefined-host): Add corresponding tests.
---
lisp/auth-source-pass.el | 12 ++++++++++--
test/lisp/auth-source-pass-tests.el | 11 +++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 96aefc8..461cba0 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -45,10 +45,18 @@
See `auth-source-search' for details on SPEC."
(cl-assert (or (null type) (eq type (oref backend type)))
t "Invalid password-store search: %s %s")
- (when (listp host)
+ (when (consp host)
+ (warn "auth-source-pass ignores all but first host in spec.")
;; Take the first non-nil item of the list of hosts
(setq host (seq-find #'identity host)))
- (list (auth-source-pass--build-result host port user)))
+ (cond ((eq host t)
+ (warn "auth-source-pass does not handle host wildcards.")
+ nil)
+ ((null host)
+ ;; Do not build a result, as none will match when HOST is nil
+ nil)
+ (t
+ (list (auth-source-pass--build-result host port user)))))
(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 0f07259..431e4e4 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -73,6 +73,17 @@ This function is intended to be set to `auth-source-debug`."
(auth-source-pass--debug-log nil))
,@body)))
+(ert-deftest auth-source-pass-any-host ()
+ (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" .
"foo-user"))
+ ("bar"))
+ (should-not (auth-source-pass-search :host t))))
+
+(ert-deftest auth-source-pass-undefined-host ()
+ (auth-source-pass--with-store '(("foo" ("port" . "foo-port") ("host" .
"foo-user"))
+ ("bar"))
+ (should-not (auth-source-pass-search :host nil))))
+
+
(ert-deftest auth-source-pass-find-match-matching-at-entry-name ()
(auth-source-pass--with-store '(("foo"))
(should (equal (auth-source-pass--find-match "foo" nil nil)
- [Emacs-diffs] master updated (7c1fa17 -> 5d23382), Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 59d44b5 02/14: * test/lisp/auth-source-pass-tests.el: Add assertions for host:port, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master a6b1cb0 01/14: * lisp/auth-source-pass.el: Fix headers., Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 53f044c 03/14: Fix indentation in auth-source-pass-tests.el, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 5b31e6d 04/14: Add a test to auth-source-pass-tests.el, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master a52661b 05/14: Add missing test cases to auth-source-pass-tests.el, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 7b2d475 09/14: * lisp/auth-source-pass.el: Update version to 3.0.0, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 1d2551f 07/14: Fix auth-source-pass.el to properly handle special inputs,
Nicolas Petton <=
- [Emacs-diffs] master a6cbdd4 11/14: * lisp/auth-source-pass.el: Update version to 4.0.0, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 5d23382 14/14: * lisp/auth-source-pass.el: Update version to 4.0.1, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 24cbb65 08/14: Silence byte compiler warning in auth-source-pass, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master a613326 10/14: Fix prefix messages of auth-source-pass debug messages, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 03c50fc 12/14: Make sure auth-source-pass is compatible with Emacs 25, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master 47ccee2 13/14: Test checking that auth-source-pass backend is correctly installed, Nicolas Petton, 2018/06/05
- [Emacs-diffs] master b43ed61 06/14: auth-source-pass: Take care of matching hosts when port is provided, Nicolas Petton, 2018/06/05