aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/auth-source.el14
-rw-r--r--test/lisp/auth-source-tests.el28
2 files changed, 26 insertions, 16 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 369cf4dca2e..cf93cb05fba 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1946,18 +1946,20 @@ entries for git.gnus.org:
1946 (returned-keys (delete-dups (append 1946 (returned-keys (delete-dups (append
1947 '(:host :login :port :secret) 1947 '(:host :login :port :secret)
1948 search-keys))) 1948 search-keys)))
1949 ;; Extract host and port from spec 1949 ;; Extract host, port and user from spec
1950 (hosts (plist-get spec :host)) 1950 (hosts (plist-get spec :host))
1951 (hosts (if (and hosts (listp hosts)) hosts `(,hosts))) 1951 (hosts (if (consp hosts) hosts `(,hosts)))
1952 (ports (plist-get spec :port)) 1952 (ports (plist-get spec :port))
1953 (ports (if (and ports (listp ports)) ports `(,ports))) 1953 (ports (if (consp ports) ports `(,ports)))
1954 (users (plist-get spec :user)) 1954 (users (plist-get spec :user))
1955 (users (if (and users (listp users)) users `(,users))) 1955 (users (if (consp users) users `(,users)))
1956 ;; Loop through all combinations of host/port and pass each of these to 1956 ;; Loop through all combinations of host/port and pass each of these to
1957 ;; auth-source-macos-keychain-search-items 1957 ;; auth-source-macos-keychain-search-items. Convert numeric port to
1958 ;; string (bug#68376).
1958 (items (catch 'match 1959 (items (catch 'match
1959 (dolist (host hosts) 1960 (dolist (host hosts)
1960 (dolist (port ports) 1961 (dolist (port ports)
1962 (when (numberp port) (setq port (number-to-string port)))
1961 (dolist (user users) 1963 (dolist (user users)
1962 (let ((items (apply 1964 (let ((items (apply
1963 #'auth-source-macos-keychain-search-items 1965 #'auth-source-macos-keychain-search-items
@@ -2019,7 +2021,7 @@ entries for git.gnus.org:
2019 (when port 2021 (when port
2020 (if keychain-generic 2022 (if keychain-generic
2021 (setq args (append args (list "-s" port))) 2023 (setq args (append args (list "-s" port)))
2022 (setq args (append args (if (string-match "[0-9]+" port) 2024 (setq args (append args (if (string-match-p "\\`[[:digit:]]+\\'" port)
2023 (list "-P" port) 2025 (list "-P" port)
2024 (list "-r" (substring 2026 (list "-r" (substring
2025 (format "%-4s" port) 2027 (format "%-4s" port)
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index 5452501b861..2ff76977174 100644
--- a/test/lisp/auth-source-tests.el
+++ b/test/lisp/auth-source-tests.el
@@ -442,18 +442,26 @@ machine c1 port c2 user c3 password c4\n"
442 (cl-letf (((symbol-function 'call-process) 442 (cl-letf (((symbol-function 'call-process)
443 (lambda (_program _infile _destination _display 443 (lambda (_program _infile _destination _display
444 &rest args) 444 &rest args)
445 ;; Arguments must be all strings 445 ;; Arguments must be all strings.
446 (should (cl-every #'stringp args)) 446 (should (cl-every #'stringp args))
447 ;; Argument number should be even 447 ;; Argument number should be even.
448 (should (cl-evenp (length args))) 448 (should (cl-evenp (length args)))
449 (should (cond ((string= (car args) "find-internet-password") 449 (should
450 (let ((protocol (cl-member "-r" args :test #'string=))) 450 (cond
451 (if protocol 451 ((string= (car args) "find-internet-password")
452 (= 4 (length (cadr protocol))) 452 (let ((protocol-r (cl-member "-r" args :test #'string=))
453 t))) 453 (protocol-P (cl-member "-P" args :test #'string=)))
454 ((string= (car args) "find-generic-password") 454 (cond (protocol-r
455 t)))))) 455 (= 4 (length (cadr protocol-r))))
456 (auth-source-search :user '("a" "b") :host '("example.org") :port '("irc" "ftp" "https"))))) 456 (protocol-P
457 (string-match-p
458 "\\`[[:digit:]]+\\'" (cadr protocol-P)))
459 (t))))
460 ((string= (car args) "find-generic-password")
461 t))))))
462 (auth-source-search
463 :user '("a" "b") :host '("example.org")
464 :port '("irc" "ftp" "https" 123)))))
457 465
458(provide 'auth-source-tests) 466(provide 'auth-source-tests)
459;;; auth-source-tests.el ends here 467;;; auth-source-tests.el ends here