From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#58985: 29.0.50; Have auth-source-pass behave more like other back ends Date: Wed, 07 Dec 2022 06:30:09 -0800 Message-ID: <87o7sf477y.fsf__19365.8100486331$1670423480$gmane$org@neverwas.me> References: <87wn8cb0ym.fsf@neverwas.me> <874jvdardn.fsf__3771.40490324877$1667692584$gmane$org@neverwas.me> <87pme09vis.fsf@gmx.de> <87a653z7dl.fsf@neverwas.me> <878rkjl1vd.fsf@disroot.org> <877d026uym.fsf@neverwas.me> <87tu35eehq.fsf@disroot.org> <87bkpcu74w.fsf@neverwas.me> <875yfkdwlm.fsf@disroot.org> <874jv3nwmc.fsf@disroot.org> <875yfiq3d8.fsf@neverwas.me> <87mt8uvxkp.fsf@disroot.org> <877czxlgd4.fsf@neverwas.me> <87edu5toi6.fsf@disroot.org> <87a64s99ka.fsf@neverwas.me> <87bkp4z6xg.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16256"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Damien Cassou , =?UTF-8?Q?Bj=C3=B6rn?= Bidar , emacs-erc@gnu.org, Michael Albinus , Akib Azmain Turja To: 58985-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 07 15:31:14 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2vS5-00046s-Qf for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Dec 2022 15:31:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2vRw-0004oL-PA; Wed, 07 Dec 2022 09:31:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2vRv-0004o4-N3 for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:31:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2vRu-0006QG-IH for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:31:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2vRu-0001Ty-EZ for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Dec 2022 14:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58985 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58985-done@debbugs.gnu.org id=D58985.16704234265685 (code D ref 58985); Wed, 07 Dec 2022 14:31:02 +0000 Original-Received: (at 58985-done) by debbugs.gnu.org; 7 Dec 2022 14:30:26 +0000 Original-Received: from localhost ([127.0.0.1]:50519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2vRJ-0001Td-4w for submit@debbugs.gnu.org; Wed, 07 Dec 2022 09:30:26 -0500 Original-Received: from mail-108-mta101.mxroute.com ([136.175.108.101]:43041) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2vRF-0001TX-Dv for 58985-done@debbugs.gnu.org; Wed, 07 Dec 2022 09:30:23 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta101.mxroute.com (ZoneMTA) with ESMTPSA id 184ecfe88a70001d7e.002 for <58985-done@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 07 Dec 2022 14:30:14 +0000 X-Zone-Loop: 96f24a69ec9f8ee0578e8b1068d1c59daf27792e9df8 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=I/R3ipf++cLQ7BuwNMwYG49uF7oPSkCAvWcR9t/ag0Q=; b=h78dl/iODKOHCHuGt8njuRgI4Q keQ+YiBoTBj0wiz15QJPxV/lw0ZL4aOGRMFGJM+QYxxizVY/LVse07Ps1xC07QlSiTVQwVWKZfSQh 9vNG7Q2yUtyCndxUjI8hp05De/YQlq+sdsgpo4bgcjn0X5XOVXA4ffxCeWrbCsW0v8pKnvDZyBuCA Z0vI41mwbFbnpdSHatbOS6kgRqCYLRXX/GOSFKY7jXKmFemA1ZmWHjFfgDa2y5zZCDnjXGhGG7Cj6 bYyo6Irrzk35LTEVKI6RoNEn9FdHwWX9+hxKKTq34dDlB8ZBM6FaepV7l4qQxGA3IQT/dT7UjQgld /y3KVd8Q==; In-Reply-To: <87bkp4z6xg.fsf@neverwas.me> (J. P.'s message of "Fri, 18 Nov 2022 06:14:03 -0800") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250194 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "J.P." writes: > Because I am easily swayed (or maybe just a liar), I've gone ahead and > enabled it by default [1]. I've also informed Nicolas Petton of the > change. I guess Bj=C3=B6rn was too busy or annoyed by my pestering to keep > up, which is understandable. > > Thanks, everyone, for your help with this (especially Akib, who I pray > will consider contributing to ERC in the future). And please remember to > complain if you encounter any related ugliness. In the meantime, I am > closing this bug. A couple updates for anyone who cares: 1. As you may have noticed, due to various complaints here on the tracker, the new option `auth-source-pass-extra-query-keywords' is now disabled by default. 2. The changes currently installed contain a bug involving spaces in file names. Basically, all other back ends allow spaces in an entry's user and host fields. The second (throwaway) patch below demonstrates this, and the first attempts to make things right. In my mind, item #2 is a bug that needs fixing on the release branch, and I plan on doing so in the coming days. If there are questions or concerns, please let them be known. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-spaces-in-auth-source-pass-match-regexp.patch >From 85f00ef178b59573f91f0389f67c69585742a6e2 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 24 Nov 2022 21:03:03 -0800 Subject: [PATCH 1/2] Allow spaces in auth-source-pass--match-regexp * lisp/auth-source-pass.el (auth-source-pass--match-regexp): Allow spaces in host and user components because all other backends do. * lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass--retrieve-parsed): Allow spaces in host and user components in auth-source-pass regexp. * test/lisp/auth-source-pass-tests.el (auth-source-pass-any-host): Silence warning message re wildcards from `auth-source-pass-search'. (auth-source-pass-extra-query-keywords--suffixed-user): Add spaces to users and hosts of some entries. (Bug#58985.) --- lisp/auth-source-pass.el | 12 +++++------ lisp/erc/erc-compat.el | 8 ++++---- test/lisp/auth-source-pass-tests.el | 31 +++++++++++++++-------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 74d3808448..3262880c47 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -111,12 +111,12 @@ auth-source-pass--match-regexp (defun auth-source-pass--match-regexp (s) (rx-to-string ; autoloaded `(: (or bot "/") - (or (: (? (group-n 20 (+ (not (in ?\ ?/ ,s)))) "@") - (group-n 10 (+ (not (in ?\ ?/ ?@ ,s)))) - (? ,s (group-n 30 (+ (not (in ?\ ?/ ,s)))))) - (: (group-n 11 (+ (not (in ?\ ?/ ?@ ,s)))) - (? ,s (group-n 31 (+ (not (in ?\ ?/ ,s))))) - (? "/" (group-n 21 (+ (not (in ?\ ?/ ,s))))))) + (or (: (? (group-n 20 (+ (not (in ?/ ,s)))) "@") ; user pfx + (group-n 10 (+ (not (in ?/ ?@ ,s)))) ; host + (? ,s (group-n 30 (+ (not (in ?\s ?/ ,s)))))) ; port + (: (group-n 11 (+ (not (in ?/ ?@ ,s)))) ; host + (? ,s (group-n 31 (+ (not (in ?\s ?/ ,s))))) ; port + (? "/" (group-n 21 (+ (not (in ?/ ,s))))))) ; user sfx eot) 'no-group)) diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index abbaafcd93..bd93254758 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -176,12 +176,12 @@ auth-source-backend-parser-functions ;; This hard codes `auth-source-pass-port-separator' to ":" (defun erc-compat--29-auth-source-pass--retrieve-parsed (seen e port-number-p) (when (string-match (rx (or bot "/") - (or (: (? (group-n 20 (+ (not (in " /:")))) "@") - (group-n 10 (+ (not (in " /:@")))) + (or (: (? (group-n 20 (+ (not (in "/:")))) "@") + (group-n 10 (+ (not (in "/:@")))) (? ":" (group-n 30 (+ (not (in " /:")))))) - (: (group-n 11 (+ (not (in " /:@")))) + (: (group-n 11 (+ (not (in "/:@")))) (? ":" (group-n 31 (+ (not (in " /:"))))) - (? "/" (group-n 21 (+ (not (in " /:"))))))) + (? "/" (group-n 21 (+ (not (in "/:"))))))) eot) e) (puthash e `( :host ,(or (match-string 10 e) (match-string 11 e)) diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el index 1107e09b51..d6d42ce942 100644 --- a/test/lisp/auth-source-pass-tests.el +++ b/test/lisp/auth-source-pass-tests.el @@ -175,7 +175,8 @@ auth-source-pass-match-any-entry-p (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)))) + (let ((inhibit-message t)) ; silence "... does not handle host wildcards." + (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")) @@ -697,29 +698,29 @@ auth-source-pass-extra-query-keywords--ambiguous-user-host ;; with slightly more realistic and less legible values. (ert-deftest auth-source-pass-extra-query-keywords--suffixed-user () - (let ((store (sort (copy-sequence '(("x.com:42/b@r" (secret . "a")) - ("b@r@x.com" (secret . "b")) + (let ((store (sort (copy-sequence '(("x.com:42/s p@m" (secret . "a")) + ("s p@m@x.com" (secret . "b")) ("x.com" (secret . "?")) - ("b@r@y.org" (secret . "c")) - ("fake.com" (secret . "?")) - ("fake.com/b@r" (secret . "d")) - ("y.org/b@r" (secret . "?")) - ("b@r@fake.com" (secret . "e")))) + ("s p@m@y.org" (secret . "c")) + ("fa ke" (secret . "?")) + ("fa ke/s p@m" (secret . "d")) + ("y.org/s p@m" (secret . "?")) + ("s p@m@fa ke" (secret . "e")))) (lambda (&rest _) (zerop (random 2)))))) (auth-source-pass--with-store store (auth-source-pass-enable) (let* ((auth-source-pass-extra-query-keywords t) - (results (auth-source-search :host '("x.com" "fake.com" "y.org") - :user "b@r" + (results (auth-source-search :host '("x.com" "fa ke" "y.org") + :user "s p@m" :require '(:user) :max 5))) (dolist (result results) (setf (plist-get result :secret) (auth-info-password result))) (should (equal results - '((:host "x.com" :user "b@r" :secret "b") - (:host "x.com" :user "b@r" :port "42" :secret "a") - (:host "fake.com" :user "b@r" :secret "e") - (:host "fake.com" :user "b@r" :secret "d") - (:host "y.org" :user "b@r" :secret "c")))))))) + '((:host "x.com" :user "s p@m" :secret "b") + (:host "x.com" :user "s p@m" :port "42" :secret "a") + (:host "fa ke" :user "s p@m" :secret "e") + (:host "fa ke" :user "s p@m" :secret "d") + (:host "y.org" :user "s p@m" :secret "c")))))))) ;; This is a more distilled version of `suffixed-user', above. It ;; better illustrates that search order takes precedence over "/user" -- 2.38.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-POC-Demo-spaces-in-hosts-users-among-auth-source-bac.patch >From c379523c177ea0188f8c270585efc6077901479a Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 24 Nov 2022 21:03:03 -0800 Subject: [PATCH 2/2] [POC] Demo spaces in hosts/users among auth-source backends --- test/lisp/auth-source-pass-tests.el | 255 ++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el index d6d42ce942..59a0c1252f 100644 --- a/test/lisp/auth-source-pass-tests.el +++ b/test/lisp/auth-source-pass-tests.el @@ -752,6 +752,261 @@ auth-source-pass-extra-query-keywords--user-priorities (:host "g" :user "u" :port 2 :secret "@") ; ** (:host "g" :user "u" :port 2 :secret "/")))))))) +;;;; Whitespace demo + +;; These demonstrate that all back ends support spaces in host and +;; user fields. + +;; netrc + +(ert-deftest auth-source-pass-extra-query-keywords--ws-host-netrc () + (ert-with-temp-file netrc-file + :text "\ +machine \"hello world\" password a +machine localhost password b +" + (let* ((auth-sources (list netrc-file)) + (auth-source-do-cache nil) + (results (auth-source-search :host "hello world"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '((:host "hello world" :secret "a"))))))) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-user-netrc () + (ert-with-temp-file netrc-file + :text "\ +machine localhost login onetwo password a +machine localhost login \"one two\" password b +" + (let* ((auth-sources (list netrc-file)) + (auth-source-do-cache nil) + (results (auth-source-search :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :host "localhost" + :user "one two" + :secret "b"))))))) + +;; plstore + +(require 'epg) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-host-plstore () + (ert-with-temp-file plstore-file + :suffix ".plist" + :text "\ +;;; public entries -*- mode: plstore -*- +((\"8faf07aac16e46c49857598b6cd6dd809762c5cb\" + :secret-secret t :host \"hello world\") + (\"12d4700ff04a5dbadec60b55319ff3f473d026fa\" + :secret-secret t :host \"localhost\")) +;;; secret entries +((\"8faf07aac16e46c49857598b6cd6dd809762c5cb\" :secret \"a\") + (\"12d4700ff04a5dbadec60b55319ff3f473d026fa\" :secret \"b\")) +" + (cl-letf (((symbol-function 'epg-decrypt-string) + (lambda (&rest r) (prin1-to-string (cadr r)))) + ((symbol-function 'epg-find-configuration) + (lambda (&rest _) '((program . "/bin/true"))))) + (let* ((auth-sources (list plstore-file)) + (auth-source-do-cache nil) + (results (auth-source-search :host "hello world"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :login nil + :port nil + :secret "a" + :host "hello world")))))))) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-user-plstore () + (ert-with-temp-file plstore-file + :suffix ".plist" + :text "\ +;;; public entries -*- mode: plstore -*- +((\"8b23ccce4b95bee4b9a8676409a7f196f1adc59e\" + :secret-secret t + :host \"localhost\" + :user \"onetwo\") + (\"e4c4fcb6c505d389ff72a58314571f37fb936365\" + :secret-secret t + :host \"localhost\" + :user \"one two\")) +;;; secret entries +((\"8b23ccce4b95bee4b9a8676409a7f196f1adc59e\" :secret \"a\") + (\"e4c4fcb6c505d389ff72a58314571f37fb936365\" :secret \"b\")) +" + (cl-letf (((symbol-function 'epg-decrypt-string) + (lambda (&rest r) (prin1-to-string (cadr r)))) + ((symbol-function 'epg-find-configuration) + (lambda (&rest _) '((program . "/bin/true"))))) + (let* ((auth-sources (list plstore-file)) + (auth-source-do-cache nil) + (results (auth-source-search :host "localhost" + :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :login nil + :port nil + :secret "b" + :host "localhost" + :user "one two")))))))) + +;; json + +(ert-deftest auth-source-pass-extra-query-keywords--ws-host-json () + (ert-with-temp-file json-store + :suffix ".json" + :text "\ +[{\"host\":\"hello world\",\"secret\":\"a\"}, + {\"host\":\"localhost\",\"secret\":\"b\"}] +" + (let* ((auth-sources (list json-store)) + (auth-source-do-cache nil) + (results (auth-source-search :host "hello world"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results + '(( :host "hello world" + :secret "a"))))))) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-user-json () + (ert-with-temp-file json-store + :suffix ".json" + :text "\ +[{\"host\":\"localhost\", + \"user\":\"onetwo\", + \"secret\":\"a\"}, + {\"host\":\"localhost\", + \"user\":\"one two\", + \"secret\":\"b\"}] +" + (let* ((auth-sources (list json-store)) + (auth-source-do-cache nil) + (results (auth-source-search :host "localhost" :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results + '(( :host "localhost" + :user "one two" + :secret "b"))))))) + +;; secrets + +(require 'secrets) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-host-secrets () + (let ((auth-sources '("secrets:Test")) + (auth-source-do-cache nil) + (entries '(("nil@hello world:nil" + (:host . "hello world") + (:xdg:schema . "org.freedesktop.Secret.Generic")) + ("nil@localhost:nil" + (:host . "localhost") + (:xdg:schema . "org.freedesktop.Secret.Generic")))) + (secrets '(("nil@hello world:nil" . "a") + ("nil@localhost:nil" . "b")))) + + (cl-letf (((symbol-function 'secrets-search-items) + (lambda (_ &rest r) + (mapcan (lambda (s) + (and (seq-every-p (pcase-lambda (`(,k . ,v)) + (equal v (alist-get k (cdr s)))) + (map-pairs r)) + (list (car s)))) + entries))) + ((symbol-function 'secrets-get-secret) + (lambda (_ label) (assoc-default label secrets))) + ((symbol-function 'secrets-get-attributes) + (lambda (_ label) (assoc-default label entries)))) + + (let ((results (auth-source-search :host "hello world"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results + '(( :login nil + :port nil + :secret "a" + :host "hello world" + :xdg:schema "org.freedesktop.Secret.Generic")))))))) + +(ert-deftest auth-source-pass-extra-query-keywords--secrets-joao-user () + (let ((auth-sources '("secrets:Test")) + (auth-source-do-cache nil) + (entries '(("onetwo@localhost:nil" + (:host . "localhost") + (:user . "onetwo") + (:xdg:schema . "org.freedesktop.Secret.Generic")) + ("one two@localhost:nil" + (:host . "localhost") + (:user . "one two") + (:xdg:schema . "org.freedesktop.Secret.Generic")))) + (secrets '(("onetwo@localhost:nil" . "a") + ("one two@localhost:nil" . "b")))) + + (cl-letf (((symbol-function 'secrets-search-items) + (lambda (_ &rest r) + (mapcan (lambda (s) + (and (seq-every-p (pcase-lambda (`(,k . ,v)) + (equal v (alist-get k (cdr s)))) + (map-pairs r)) + (list (car s)))) + entries))) + ((symbol-function 'secrets-get-secret) + (lambda (_ label) (assoc-default label secrets))) + ((symbol-function 'secrets-get-attributes) + (lambda (_ label) (assoc-default label entries)))) + + (let ((results (auth-source-search :host "localhost" :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results + '(( :login nil + :port nil + :secret "b" + :host "localhost" + :user "one two" + :xdg:schema "org.freedesktop.Secret.Generic")))))))) + +;; Pass + +(ert-deftest auth-source-pass-extra-query-keywords--ws-host-pass () + (auth-source-pass--with-store '(("hello world:80" (secret . "a")) + ("localhost:80" (secret . "b"))) + (auth-source-pass-enable) + (let* ((auth-source-pass-extra-query-keywords t) + (results (auth-source-search :host "hello world"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :host "hello world" + :port "80" + :secret "a"))))))) + +(ert-deftest auth-source-pass-extra-query-keywords--ws-user-pass () + ;; "suffix" syntax + (auth-source-pass--with-store '(("localhost:80/onetwo" (secret . "a")) + ("localhost:80/one two" (secret . "b"))) + (auth-source-pass-enable) + (let* ((auth-source-pass-extra-query-keywords t) + (results (auth-source-search :host "localhost" :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :host "localhost" + :user "one two" + :port "80" + :secret "b")))))) + ;; "prefix" syntax + (auth-source-pass--with-store '(("onetwo@localhost:80" (secret . "a")) + ("one two@localhost:80" (secret . "b"))) + (auth-source-pass-enable) + (let* ((auth-source-pass-extra-query-keywords t) + (results (auth-source-search :host "localhost" :user "one two"))) + (dolist (result results) + (setf (plist-get result :secret) (auth-info-password result))) + (should (equal results '(( :host "localhost" + :user "one two" + :port "80" + :secret "b"))))))) + (provide 'auth-source-pass-tests) ;;; auth-source-pass-tests.el ends here -- 2.38.1 --=-=-=--