summaryrefslogtreecommitdiff
path: root/test/lisp/auth-source-pass-tests.el
diff options
context:
space:
mode:
authorIku Iwasa <iku.iwasa@gmail.com>2021-06-27 17:36:00 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-07-02 12:53:35 +0200
commitb09ee1406205e8b6298411b9a18c1cd26e201689 (patch)
tree34e7f4f5930c6bcac08800fb2c729b7287153e32 /test/lisp/auth-source-pass-tests.el
parentbb455d0daad89f5d895232f66c26a7fee6bb9bc8 (diff)
downloademacs-b09ee1406205e8b6298411b9a18c1cd26e201689.tar.gz
lisp/auth-source-pass.el: Support multiple hosts in search spec
* lisp/auth-source-pass.el (auth-source-pass-search): Accept a list of strings for argument HOST. (auth-source-pass--build-result): Rename argument HOST to HOSTS. Also return value "host" from entry if it exists. (auth-source-pass--find-match): Rename argument HOST to HOSTS. Iterate over each host in HOSTS. * test/lisp/auth-source-pass-tests.el: Add corresponding tests
Diffstat (limited to 'test/lisp/auth-source-pass-tests.el')
-rw-r--r--test/lisp/auth-source-pass-tests.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index bfbef53db97..a2f84f20e8e 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -424,21 +424,37 @@ HOSTNAME, USER and PORT are passed unchanged to
(auth-source-pass--with-store-find-foo
'(("foo" ("secret" . "foo password")))
(let ((result (auth-source-pass--build-result "foo" 512 "user")))
+ (should (equal (plist-get result :host) "foo"))
(should (equal (plist-get result :port) 512))
(should (equal (plist-get result :user) "user")))))
(ert-deftest auth-source-pass-build-result-return-entry-values ()
(auth-source-pass--with-store-find-foo '(("foo" ("port" . 512) ("user" . "anuser")))
(let ((result (auth-source-pass--build-result "foo" nil nil)))
+ (should (equal (plist-get result :host) "foo"))
(should (equal (plist-get result :port) 512))
(should (equal (plist-get result :user) "anuser")))))
(ert-deftest auth-source-pass-build-result-entry-takes-precedence ()
- (auth-source-pass--with-store-find-foo '(("foo" ("port" . 512) ("user" . "anuser")))
+ (auth-source-pass--with-store-find-foo '(("foo" ("host" . "bar") ("port" . 512) ("user" . "anuser")))
(let ((result (auth-source-pass--build-result "foo" 1024 "anotheruser")))
+ (should (equal (plist-get result :host) "bar"))
(should (equal (plist-get result :port) 512))
(should (equal (plist-get result :user) "anuser")))))
+(ert-deftest auth-source-pass-build-result-with-multiple-hosts ()
+ (auth-source-pass--with-store-find-foo
+ '(("foo" ("secret" . "foo password")))
+ (let ((result (auth-source-pass--build-result '("bar" "foo") 512 "user")))
+ (should (equal (plist-get result :host) "foo"))
+ (should (equal (plist-get result :port) 512))
+ (should (equal (plist-get result :user) "user")))))
+
+(ert-deftest auth-source-pass-build-result-with-multiple-hosts-no-match ()
+ (auth-source-pass--with-store-find-foo
+ '(("foo" ("secret" . "foo password")))
+ (should-not (auth-source-pass--build-result '("bar" "baz") 512 "user"))))
+
(ert-deftest auth-source-pass-can-start-from-auth-source-search ()
(auth-source-pass--with-store '(("gitlab.com" ("user" . "someone")))
(auth-source-pass-enable)