all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#31639: 26.1; [PATCH] Update auth-source-pass
@ 2018-05-29 12:31 Damien Cassou
  2018-05-29 13:52 ` Nicolas Petton
  2018-06-05 13:55 ` Nicolas Petton
  0 siblings, 2 replies; 3+ messages in thread
From: Damien Cassou @ 2018-05-29 12:31 UTC (permalink / raw)
  To: 31639

[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]

This series of patches update auth-source-pass to its latest version.

Alex Branham (1):
  Silence byte compiler warning in auth-source-pass

Damien Cassou (11):
  * lisp/auth-source-pass.el: Fix headers.
  Fix indentation in auth-source-pass-tests.el
  Add a test to auth-source-pass-tests.el
  Add missing test cases to auth-source-pass-tests.el
  auth-source-pass: Take care of matching hosts when port is provided
  * lisp/auth-source-pass.el: Update version to 3.0.0
  Fix prefix messages of auth-source-pass debug messages
  * lisp/auth-source-pass.el: Update version to 4.0.0
  Make sure auth-source-pass is compatible with Emacs 25
  Test checking that auth-source-pass backend is correctly installed
  * lisp/auth-source-pass.el: Update version to 4.0.1

Edison Ibañez (1):
  * test/lisp/auth-source-pass-tests.el: Add assertions for host:port

Jelle Licht (1):
  Fix auth-source-pass.el to properly handle special inputs

 lisp/auth-source-pass.el            | 94 +++++++++++++++--------------
 test/lisp/auth-source-pass-tests.el | 84 +++++++++++++++++---------
 2 files changed, 102 insertions(+), 76 deletions(-)


-- 
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-auth-source-pass.el-Fix-headers.patch --]
[-- Type: text/x-patch, Size: 876 bytes --]

From f6db365f62fc9e02c89098f68524c82ec535852c Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Thu, 22 Feb 2018 17:58:07 +0100
Subject: [PATCH 01/14] * lisp/auth-source-pass.el: Fix headers.

---
 lisp/auth-source-pass.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 3e6a9cccbc..1785ca3255 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -5,9 +5,9 @@
 ;; Author: Damien Cassou <damien@cassou.me>,
 ;;         Nicolas Petton <nicolas@petton.fr>
 ;; Version: 2.0.0
-;; Package-Requires: ((emacs "24.4")
+;; Package-Requires: ((emacs "25"))
+;; Url: https://github.com/DamienCassou/auth-password-store
 ;; Created: 07 Jun 2015
-;; Keywords: pass password-store auth-source username password login
 
 ;; This file is part of GNU Emacs.
 
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-test-lisp-auth-source-pass-tests.el-Add-assertions-f.patch --]
[-- Type: text/x-patch, Size: 1441 bytes --]

From 4f5cd8ce6d6784c941450e00d8c3b91838071d61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= <arkhan.xxx@gmail.com>
Date: Tue, 7 Nov 2017 09:00:43 +0100
Subject: [PATCH 02/14] * test/lisp/auth-source-pass-tests.el: Add assertions
 for host:port

---
 test/lisp/auth-source-pass-tests.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index 86f59e5166..557a34ff59 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -166,11 +166,13 @@ auth-source-pass--with-store
                    "host.com"))))
 
 (ert-deftest auth-source-pass-hostname ()
+  (should (equal (auth-source-pass--hostname "https://foo.bar:443") "foo.bar"))
   (should (equal (auth-source-pass--hostname "https://foo.bar") "foo.bar"))
   (should (equal (auth-source-pass--hostname "http://foo.bar") "foo.bar"))
   (should (equal (auth-source-pass--hostname "https://SomeUser@foo.bar") "foo.bar")))
 
 (ert-deftest auth-source-pass-hostname-with-user ()
+  (should (equal (auth-source-pass--hostname-with-user "https://foo.bar:443") "foo.bar"))
   (should (equal (auth-source-pass--hostname-with-user "https://foo.bar") "foo.bar"))
   (should (equal (auth-source-pass--hostname-with-user "http://foo.bar") "foo.bar"))
   (should (equal (auth-source-pass--hostname-with-user "https://SomeUser@foo.bar") "SomeUser@foo.bar")))
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Fix-indentation-in-auth-source-pass-tests.el.patch --]
[-- Type: text/x-patch, Size: 1617 bytes --]

From 68eac649d8deaf02219ce4d5c3896ec98b62edb1 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Tue, 7 Nov 2017 09:33:22 +0100
Subject: [PATCH 03/14] Fix indentation in auth-source-pass-tests.el

* test/lisp/auth-source-pass-tests.el
(auth-source-pass-only-return-entries-that-can-be-open): Fix indentation.
---
 test/lisp/auth-source-pass-tests.el | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index 557a34ff59..adb0b5d93f 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -206,12 +206,10 @@ auth-source-pass--with-store-find-foo
 
 (ert-deftest auth-source-pass-only-return-entries-that-can-be-open ()
   (cl-letf (((symbol-function 'auth-source-pass-entries)
-             (lambda () '("foo.site.com" "bar.site.com"
-                     "mail/baz.site.com/scott")))
+             (lambda () '("foo.site.com" "bar.site.com" "mail/baz.site.com/scott")))
             ((symbol-function 'auth-source-pass--entry-valid-p)
              ;; only foo.site.com and "mail/baz.site.com/scott" are valid
-             (lambda (entry) (member entry '("foo.site.com"
-                                        "mail/baz.site.com/scott")))))
+             (lambda (entry) (member entry '("foo.site.com" "mail/baz.site.com/scott")))))
     (should (equal (auth-source-pass--find-all-by-entry-name "foo.site.com" "someuser")
                    '("foo.site.com")))
     (should (equal (auth-source-pass--find-all-by-entry-name "bar.site.com" "someuser")
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-Add-a-test-to-auth-source-pass-tests.el.patch --]
[-- Type: text/x-patch, Size: 1440 bytes --]

From a1bc5d5db43018da2c3954c9207536095475bb00 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Tue, 7 Nov 2017 09:32:30 +0100
Subject: [PATCH 04/14] Add a test to auth-source-pass-tests.el

* test/lisp/auth-source-pass-tests.el
(auth-source-pass-build-result-passes-full-host-to-find-match): Add
test making sure find-match is called with full host.
---
 test/lisp/auth-source-pass-tests.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index adb0b5d93f..2ddbcab233 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -204,6 +204,13 @@ auth-source-pass--with-store-find-foo
       (should (equal (plist-get result :port) 512))
       (should (equal (plist-get result :user) "anuser")))))
 
+(ert-deftest auth-source-pass-build-result-passes-full-host-to-find-match ()
+  (let (passed-host)
+    (cl-letf (((symbol-function 'auth-source-pass--find-match)
+               (lambda (host _user) (setq passed-host host))))
+      (auth-source-pass--build-result "https://user@host.com:123" nil nil)
+      (should (equal passed-host "https://user@host.com:123")))))
+
 (ert-deftest auth-source-pass-only-return-entries-that-can-be-open ()
   (cl-letf (((symbol-function 'auth-source-pass-entries)
              (lambda () '("foo.site.com" "bar.site.com" "mail/baz.site.com/scott")))
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-Add-missing-test-cases-to-auth-source-pass-tests.el.patch --]
[-- Type: text/x-patch, Size: 1571 bytes --]

From 5ee76ac04967f311c329af6867dd569dbfb6888f Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Tue, 7 Nov 2017 09:48:50 +0100
Subject: [PATCH 05/14] Add missing test cases to auth-source-pass-tests.el

* test/lisp/auth-source-pass-tests.el
(auth-source-pass-build-result-passes-full-host-to-find-match): Add
missing test cases.
---
 test/lisp/auth-source-pass-tests.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index 2ddbcab233..6d471f4e34 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -209,7 +209,13 @@ auth-source-pass--with-store-find-foo
     (cl-letf (((symbol-function 'auth-source-pass--find-match)
                (lambda (host _user) (setq passed-host host))))
       (auth-source-pass--build-result "https://user@host.com:123" nil nil)
-      (should (equal passed-host "https://user@host.com:123")))))
+      (should (equal passed-host "https://user@host.com:123"))
+      (auth-source-pass--build-result "https://user@host.com" nil nil)
+      (should (equal passed-host "https://user@host.com"))
+      (auth-source-pass--build-result "user@host.com" nil nil)
+      (should (equal passed-host "user@host.com"))
+      (auth-source-pass--build-result "user@host.com:443" nil nil)
+      (should (equal passed-host "user@host.com:443")))))
 
 (ert-deftest auth-source-pass-only-return-entries-that-can-be-open ()
   (cl-letf (((symbol-function 'auth-source-pass-entries)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-auth-source-pass-Take-care-of-matching-hosts-when-po.patch --]
[-- Type: text/x-patch, Size: 13320 bytes --]

From 82a1f5229fb2314105b7c5e67c5519408f6bdb8d Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Thu, 9 Nov 2017 10:40:19 +0100
Subject: [PATCH 06/14] auth-source-pass: Take care of matching hosts when port
 is provided

* lisp/auth-source-pass.el (auth-source-pass--find-match): Add PORT
parameter and reorganize code by extracting `find-match-unambiguous'.
(auth-source-pass--find-match-unambiguous): New function.
(auth-source-pass--build-result): Fix the call to `find-match'.
(auth-source-pass--hostname, auth-source-pass--hostname-with-user,
auth-source-pass--user): Remove functions.
* test/lisp/auth-source-pass-tests.el: Fix the calls to `find-match'.
(auth-source-pass-find-host-without-port) Add corresponding test.
---
 lisp/auth-source-pass.el            | 68 +++++++++++++----------------
 test/lisp/auth-source-pass-tests.el | 51 ++++++++++------------
 2 files changed, 52 insertions(+), 67 deletions(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 1785ca3255..96aefc8dd7 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -52,7 +52,7 @@
 
 (defun auth-source-pass--build-result (host port user)
   "Build auth-source-pass entry matching HOST, PORT and USER."
-  (let ((entry (auth-source-pass--find-match host user)))
+  (let ((entry (auth-source-pass--find-match host user port)))
     (when entry
       (let ((retval (list
                      :host host
@@ -139,26 +139,6 @@ auth-source-pass--parse-data
                                     (mapconcat #'identity (cdr pair) ":")))))
                         (cdr lines)))))
 
-(defun auth-source-pass--hostname (host)
-  "Extract hostname from HOST."
-  (let ((url (url-generic-parse-url host)))
-    (or (url-host url) host)))
-
-(defun auth-source-pass--hostname-with-user (host)
-  "Extract hostname and user from HOST."
-  (let* ((url (url-generic-parse-url host))
-         (user (url-user url))
-         (hostname (url-host url)))
-    (cond
-     ((and user hostname) (format "%s@%s" user hostname))
-     (hostname hostname)
-     (t host))))
-
-(defun auth-source-pass--user (host)
-  "Extract user from HOST and return it.
-Return nil if no match was found."
-  (url-user (url-generic-parse-url host)))
-
 (defun auth-source-pass--do-debug (&rest msg)
   "Call `auth-source-do-debug` with MSG and a prefix."
   (apply #'auth-source-do-debug
@@ -230,27 +210,39 @@ auth-source-pass--find-one-by-entry-name
          (car matching-entries))
       (_ (auth-source-pass--select-one-entry matching-entries user)))))
 
-(defun auth-source-pass--find-match (host user)
-  "Return a password-store entry name matching HOST and USER.
-If many matches are found, return the first one.  If no match is
-found, return nil."
+(defun auth-source-pass--find-match (host user port)
+  "Return a password-store entry name matching HOST, USER and PORT.
+
+Disambiguate between user provided inside HOST (e.g., user@server.com) and
+inside USER by giving priority to USER.  Same for PORT."
+  (let* ((url (url-generic-parse-url (if (string-match-p ".*://" host)
+                                         host
+                                       (format "https://%s" host)))))
+    (auth-source-pass--find-match-unambiguous
+     (or (url-host url) host)
+     (or user (url-user url))
+     ;; url-port returns 443 (because of the https:// above) by default
+     (or port (number-to-string (url-port url))))))
+
+(defun auth-source-pass--find-match-unambiguous (hostname user port)
+  "Return a password-store entry name matching HOSTNAME, USER and PORT.
+If many matches are found, return the first one.  If no match is found,
+return nil.
+
+HOSTNAME should not contain any username or port number."
   (or
-   (if (auth-source-pass--user host)
-       ;; if HOST contains a user (e.g., "user@host.com"), <HOST>
-       (auth-source-pass--find-one-by-entry-name (auth-source-pass--hostname-with-user host) user)
-     ;; otherwise, if USER is provided, search for <USER>@<HOST>
-     (when (stringp user)
-       (auth-source-pass--find-one-by-entry-name (concat user "@" (auth-source-pass--hostname host)) user)))
-   ;; if that didn't work, search for HOST without its user component, if any
-   (auth-source-pass--find-one-by-entry-name (auth-source-pass--hostname host) user)
-   ;; if that didn't work, search for HOST with user extracted from it
-   (auth-source-pass--find-one-by-entry-name
-    (auth-source-pass--hostname host) (auth-source-pass--user host))
+   (and user port (auth-source-pass--find-one-by-entry-name (format "%s@%s:%s" user hostname port) user))
+   (and user (auth-source-pass--find-one-by-entry-name (format "%s@%s" user hostname) user))
+   (and port (auth-source-pass--find-one-by-entry-name (format "%s:%s" hostname port) nil))
+   (auth-source-pass--find-one-by-entry-name hostname user)
    ;; if that didn't work, remove subdomain: foo.bar.com -> bar.com
-   (let ((components (split-string host "\\.")))
+   (let ((components (split-string hostname "\\.")))
      (when (= (length components) 3)
        ;; start from scratch
-       (auth-source-pass--find-match (mapconcat 'identity (cdr components) ".") user)))))
+       (auth-source-pass--find-match-unambiguous
+        (mapconcat 'identity (cdr components) ".")
+        user
+        port)))))
 
 (provide 'auth-source-pass)
 ;;; auth-source-pass.el ends here
diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index 6d471f4e34..0f072592d0 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -75,107 +75,100 @@ auth-source-pass--with-store
 
 (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)
+    (should (equal (auth-source-pass--find-match "foo" nil nil)
                    "foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-part ()
   (auth-source-pass--with-store '(("foo"))
-    (should (equal (auth-source-pass--find-match "https://foo" nil)
+    (should (equal (auth-source-pass--find-match "https://foo" nil nil)
                    "foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-ignoring-user ()
   (auth-source-pass--with-store '(("foo"))
-    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil)
+    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil nil)
                    "foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-with-user ()
   (auth-source-pass--with-store '(("SomeUser@foo"))
-    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil)
+    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil nil)
                    "SomeUser@foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-prefer-full ()
   (auth-source-pass--with-store '(("SomeUser@foo") ("foo"))
-    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil)
+    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil nil)
                    "SomeUser@foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-prefer-full-reversed ()
   (auth-source-pass--with-store '(("foo") ("SomeUser@foo"))
-    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil)
+    (should (equal (auth-source-pass--find-match "https://SomeUser@foo" nil nil)
                    "SomeUser@foo"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-without-subdomain ()
   (auth-source-pass--with-store '(("bar.com"))
-    (should (equal (auth-source-pass--find-match "foo.bar.com" nil)
+    (should (equal (auth-source-pass--find-match "foo.bar.com" nil nil)
                    "bar.com"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-without-subdomain-with-user ()
   (auth-source-pass--with-store '(("someone@bar.com"))
-    (should (equal (auth-source-pass--find-match "foo.bar.com" "someone")
+    (should (equal (auth-source-pass--find-match "foo.bar.com" "someone" nil)
                    "someone@bar.com"))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-without-subdomain-with-bad-user ()
   (auth-source-pass--with-store '(("someoneelse@bar.com"))
-    (should (equal (auth-source-pass--find-match "foo.bar.com" "someone")
+    (should (equal (auth-source-pass--find-match "foo.bar.com" "someone" nil)
                    nil))))
 
 (ert-deftest auth-source-pass-find-match-matching-at-entry-name-without-subdomain-prefer-full ()
   (auth-source-pass--with-store '(("bar.com") ("foo.bar.com"))
-    (should (equal (auth-source-pass--find-match "foo.bar.com" nil)
+    (should (equal (auth-source-pass--find-match "foo.bar.com" nil nil)
                    "foo.bar.com"))))
 
 (ert-deftest auth-source-pass-dont-match-at-folder-name ()
   (auth-source-pass--with-store '(("foo.bar.com/foo"))
-    (should (equal (auth-source-pass--find-match "foo.bar.com" nil)
+    (should (equal (auth-source-pass--find-match "foo.bar.com" nil nil)
                    nil))))
 
 (ert-deftest auth-source-pass-find-match-matching-extracting-user-from-host ()
   (auth-source-pass--with-store '(("foo.com/bar"))
-    (should (equal (auth-source-pass--find-match "https://bar@foo.com" nil)
+    (should (equal (auth-source-pass--find-match "https://bar@foo.com" nil nil)
                    "foo.com/bar"))))
 
 (ert-deftest auth-source-pass-search-with-user-first ()
   (auth-source-pass--with-store '(("foo") ("user@foo"))
-    (should (equal (auth-source-pass--find-match "foo" "user")
+    (should (equal (auth-source-pass--find-match "foo" "user" nil)
                    "user@foo"))
     (auth-source-pass--should-have-message-containing "Found 1 match")))
 
 (ert-deftest auth-source-pass-give-priority-to-desired-user ()
   (auth-source-pass--with-store '(("foo") ("subdir/foo" ("user" . "someone")))
-    (should (equal (auth-source-pass--find-match "foo" "someone")
+    (should (equal (auth-source-pass--find-match "foo" "someone" nil)
                    "subdir/foo"))
     (auth-source-pass--should-have-message-containing "Found 2 matches")
     (auth-source-pass--should-have-message-containing "matching user field")))
 
 (ert-deftest auth-source-pass-give-priority-to-desired-user-reversed ()
   (auth-source-pass--with-store '(("foo" ("user" . "someone")) ("subdir/foo"))
-    (should (equal (auth-source-pass--find-match "foo" "someone")
+    (should (equal (auth-source-pass--find-match "foo" "someone" nil)
                    "foo"))
     (auth-source-pass--should-have-message-containing "Found 2 matches")
     (auth-source-pass--should-have-message-containing "matching user field")))
 
 (ert-deftest auth-source-pass-return-first-when-several-matches ()
   (auth-source-pass--with-store '(("foo") ("subdir/foo"))
-    (should (equal (auth-source-pass--find-match "foo" nil)
+    (should (equal (auth-source-pass--find-match "foo" nil nil)
                    "foo"))
     (auth-source-pass--should-have-message-containing "Found 2 matches")
     (auth-source-pass--should-have-message-containing "the first one")))
 
 (ert-deftest auth-source-pass-make-divansantana-happy ()
   (auth-source-pass--with-store '(("host.com"))
-    (should (equal (auth-source-pass--find-match "smtp.host.com" "myusername@host.co.za")
+    (should (equal (auth-source-pass--find-match "smtp.host.com" "myusername@host.co.za" nil)
                    "host.com"))))
 
-(ert-deftest auth-source-pass-hostname ()
-  (should (equal (auth-source-pass--hostname "https://foo.bar:443") "foo.bar"))
-  (should (equal (auth-source-pass--hostname "https://foo.bar") "foo.bar"))
-  (should (equal (auth-source-pass--hostname "http://foo.bar") "foo.bar"))
-  (should (equal (auth-source-pass--hostname "https://SomeUser@foo.bar") "foo.bar")))
-
-(ert-deftest auth-source-pass-hostname-with-user ()
-  (should (equal (auth-source-pass--hostname-with-user "https://foo.bar:443") "foo.bar"))
-  (should (equal (auth-source-pass--hostname-with-user "https://foo.bar") "foo.bar"))
-  (should (equal (auth-source-pass--hostname-with-user "http://foo.bar") "foo.bar"))
-  (should (equal (auth-source-pass--hostname-with-user "https://SomeUser@foo.bar") "SomeUser@foo.bar")))
+(ert-deftest auth-source-pass-find-host-without-port ()
+  (auth-source-pass--with-store '(("host.com"))
+    (should (equal (auth-source-pass--find-match "host.com:8888" "someuser" nil)
+                   "host.com"))))
 
 (defmacro auth-source-pass--with-store-find-foo (store &rest body)
   "Use STORE while executing BODY.  \"foo\" is the matched entry."
@@ -207,7 +200,7 @@ auth-source-pass--with-store-find-foo
 (ert-deftest auth-source-pass-build-result-passes-full-host-to-find-match ()
   (let (passed-host)
     (cl-letf (((symbol-function 'auth-source-pass--find-match)
-               (lambda (host _user) (setq passed-host host))))
+               (lambda (host _user _port) (setq passed-host host))))
       (auth-source-pass--build-result "https://user@host.com:123" nil nil)
       (should (equal passed-host "https://user@host.com:123"))
       (auth-source-pass--build-result "https://user@host.com" nil nil)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-Fix-auth-source-pass.el-to-properly-handle-special-i.patch --]
[-- Type: text/x-patch, Size: 2724 bytes --]

From 5218790e76c665b070730b892ad2196edf42defe Mon Sep 17 00:00:00 2001
From: Jelle Licht <jlicht@fsfe.org>
Date: Mon, 8 Jan 2018 17:34:38 +0100
Subject: [PATCH 07/14] 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 96aefc8dd7..461cba02dd 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 0f072592d0..431e4e411d 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -73,6 +73,17 @@ auth-source-pass--with-store
            (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)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-Silence-byte-compiler-warning-in-auth-source-pass.patch --]
[-- Type: text/x-patch, Size: 927 bytes --]

From b361ce235589208ee26d13f3c4ace3927ac54599 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
Date: Mon, 12 Feb 2018 13:28:20 -0600
Subject: [PATCH 08/14] Silence byte compiler warning in auth-source-pass

* lisp/auth-source-pass.el (auth-source-pass-backend): Silence byte
compiler warning by only passing a parameter to `auth-source-backend'
in Emacs <= 25.
---
 lisp/auth-source-pass.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 461cba02dd..ec0fe8c432 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -81,7 +81,7 @@ auth-source-pass-enable
 
 (defvar auth-source-pass-backend
   (auth-source-backend
-   (format "Password store")
+   (when (<= emacs-major-version 25) "password-store")
    :source "." ;; not used
    :type 'password-store
    :search-function #'auth-source-pass-search)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-lisp-auth-source-pass.el-Update-version-to-3.0.0.patch --]
[-- Type: text/x-patch, Size: 756 bytes --]

From 24755e95ce19aa925580ac90d826c3d3a5e194d0 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Wed, 14 Feb 2018 14:51:25 +0100
Subject: [PATCH 09/14] * lisp/auth-source-pass.el: Update version to 3.0.0

---
 lisp/auth-source-pass.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index ec0fe8c432..c8722a5579 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -4,7 +4,7 @@
 
 ;; Author: Damien Cassou <damien@cassou.me>,
 ;;         Nicolas Petton <nicolas@petton.fr>
-;; Version: 2.0.0
+;; Version: 3.0.0
 ;; Package-Requires: ((emacs "25"))
 ;; Url: https://github.com/DamienCassou/auth-password-store
 ;; Created: 07 Jun 2015
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #11: 0010-Fix-prefix-messages-of-auth-source-pass-debug-messag.patch --]
[-- Type: text/x-patch, Size: 960 bytes --]

From d26168ea8ba7007dbfb203daebbabfb46e2fbfc5 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Fri, 23 Mar 2018 09:16:25 +0100
Subject: [PATCH 10/14] Fix prefix messages of auth-source-pass debug messages

* lisp/auth-source-pass.el (auth-source-pass--do-debug): Fix message
prefix.
---
 lisp/auth-source-pass.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index c8722a5579..42c0344756 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -150,7 +150,7 @@ auth-source-pass--parse-data
 (defun auth-source-pass--do-debug (&rest msg)
   "Call `auth-source-do-debug` with MSG and a prefix."
   (apply #'auth-source-do-debug
-         (cons (concat "auth-source-password-store: " (car msg))
+         (cons (concat "auth-source-pass: " (car msg))
                (cdr msg))))
 
 (defun auth-source-pass--select-one-entry (entries user)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #12: 0011-lisp-auth-source-pass.el-Update-version-to-4.0.0.patch --]
[-- Type: text/x-patch, Size: 756 bytes --]

From eedf0078f204ebb43659777dcb57596f708453f1 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Fri, 23 Mar 2018 09:18:54 +0100
Subject: [PATCH 11/14] * lisp/auth-source-pass.el: Update version to 4.0.0

---
 lisp/auth-source-pass.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 42c0344756..1193d67954 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -4,7 +4,7 @@
 
 ;; Author: Damien Cassou <damien@cassou.me>,
 ;;         Nicolas Petton <nicolas@petton.fr>
-;; Version: 3.0.0
+;; Version: 4.0.0
 ;; Package-Requires: ((emacs "25"))
 ;; Url: https://github.com/DamienCassou/auth-password-store
 ;; Created: 07 Jun 2015
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #13: 0012-Make-sure-auth-source-pass-is-compatible-with-Emacs-.patch --]
[-- Type: text/x-patch, Size: 1141 bytes --]

From 178f50ff72a52521d9ff2f2b7ca75b335c907090 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Mon, 26 Mar 2018 06:28:17 +0200
Subject: [PATCH 12/14] Make sure auth-source-pass is compatible with Emacs 25

* lisp/auth-source-pass.el: Use `advice-add' for Emacs 25 users as
`auth-source-backend-parser-functions' does not exist there.
---
 lisp/auth-source-pass.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 1193d67954..d5c6139814 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -92,7 +92,9 @@ auth-source-pass-backend-parse
   (when (eq entry 'password-store)
     (auth-source-backend-parse-parameters entry auth-source-pass-backend)))
 
-(add-hook 'auth-source-backend-parser-functions #'auth-source-pass-backend-parse)
+(if (boundp 'auth-source-backend-parser-functions)
+    (add-hook 'auth-source-backend-parser-functions #'auth-source-pass-backend-parse)
+  (advice-add 'auth-source-backend-parse :before-until #'auth-source-pass-backend-parse))
 
 \f
 (defun auth-source-pass-get (key entry)
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #14: 0013-Test-checking-that-auth-source-pass-backend-is-corre.patch --]
[-- Type: text/x-patch, Size: 1265 bytes --]

From 7f3da2e0ab258aabeb952a5aa71199855ea3691d Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Mon, 26 Mar 2018 08:56:16 +0200
Subject: [PATCH 13/14] Test checking that auth-source-pass backend is
 correctly installed

* test/lisp/auth-source-pass-tests.el
(auth-source-pass-can-start-from-auth-source-search): Add test.
---
 test/lisp/auth-source-pass-tests.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el
index 431e4e411d..b30419f44b 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -244,6 +244,13 @@ auth-source-pass--with-store-find-foo
     (should (auth-source-pass--entry-valid-p "foo"))
     (should-not (auth-source-pass--entry-valid-p "bar"))))
 
+(ert-deftest auth-source-pass-can-start-from-auth-source-search ()
+  (auth-source-pass--with-store '(("gitlab.com" ("user" . "someone")))
+    (auth-source-pass-enable)
+    (let ((result (car (auth-source-search :host "gitlab.com"))))
+      (should (equal (plist-get result :user) "someone"))
+      (should (equal (plist-get result :host) "gitlab.com")))))
+
 (provide 'auth-source-pass-tests)
 
 ;;; auth-source-pass-tests.el ends here
-- 
2.17.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #15: 0014-lisp-auth-source-pass.el-Update-version-to-4.0.1.patch --]
[-- Type: text/x-patch, Size: 756 bytes --]

From c3f44365dad279521f42232a60f26f3694c6fceb Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Mon, 26 Mar 2018 09:04:36 +0200
Subject: [PATCH 14/14] * lisp/auth-source-pass.el: Update version to 4.0.1

---
 lisp/auth-source-pass.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index d5c6139814..cebe8c2666 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -4,7 +4,7 @@
 
 ;; Author: Damien Cassou <damien@cassou.me>,
 ;;         Nicolas Petton <nicolas@petton.fr>
-;; Version: 4.0.0
+;; Version: 4.0.1
 ;; Package-Requires: ((emacs "25"))
 ;; Url: https://github.com/DamienCassou/auth-password-store
 ;; Created: 07 Jun 2015
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#31639: 26.1; [PATCH] Update auth-source-pass
  2018-05-29 12:31 bug#31639: 26.1; [PATCH] Update auth-source-pass Damien Cassou
@ 2018-05-29 13:52 ` Nicolas Petton
  2018-06-05 13:55 ` Nicolas Petton
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Petton @ 2018-05-29 13:52 UTC (permalink / raw)
  To: Damien Cassou, 31639

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

Damien Cassou <damien@cassou.me> writes:

> This series of patches update auth-source-pass to its latest version.

Thanks.  Since you're maintaining that file, I'll just wait a few days
and install the patches in master.

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#31639: 26.1; [PATCH] Update auth-source-pass
  2018-05-29 12:31 bug#31639: 26.1; [PATCH] Update auth-source-pass Damien Cassou
  2018-05-29 13:52 ` Nicolas Petton
@ 2018-06-05 13:55 ` Nicolas Petton
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Petton @ 2018-06-05 13:55 UTC (permalink / raw)
  To: Damien Cassou, 31639

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

Damien Cassou <damien@cassou.me> writes:

close 31639
thanks

> This series of patches update auth-source-pass to its latest version.

I installed your patches in master.

Thanks,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-05 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29 12:31 bug#31639: 26.1; [PATCH] Update auth-source-pass Damien Cassou
2018-05-29 13:52 ` Nicolas Petton
2018-06-05 13:55 ` Nicolas Petton

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.