[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/magit 1312f89003 24/31: magit-process:password-prompt-rege
From: |
Jonas Bernoulli |
Subject: |
[nongnu] elpa/magit 1312f89003 24/31: magit-process:password-prompt-regexps: New test |
Date: |
Sun, 26 Jan 2025 13:08:56 -0500 (EST) |
branch: elpa/magit
commit 1312f890032220b996218d66b3af9de5bc549a92
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-process:password-prompt-regexps: New test
---
lisp/magit-process.el | 1 +
test/magit-tests.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 848ab2a7b4..6df6ad68eb 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -157,6 +157,7 @@ itself from the hook, to avoid further futile attempts."
:type 'regexp)
(defcustom magit-process-password-prompt-regexps
+ ;; See also history in test `magit-process:password-prompt-regexps'.
'("^\\(Enter \\)?[Pp]assphrase\\( for \\(RSA \\)?key '.*'\\)?: ?$"
;; Match-group 99 is used to identify the "user@host" part.
"^\\(Enter \\|([^) ]+) \\)?\
diff --git a/test/magit-tests.el b/test/magit-tests.el
index 0313375e6b..4df82d010f 100644
--- a/test/magit-tests.el
+++ b/test/magit-tests.el
@@ -252,6 +252,8 @@
(should (equal (magit-list-remote-branch-names "origin" t)
(list "master")))))
+;;; Prompts
+
(ert-deftest magit-process:match-prompt-nil-when-no-match ()
(should (null (magit-process-match-prompt '("^foo: ?$") "bar: "))))
@@ -272,6 +274,48 @@
(should (equal prompt "foo 'bar': "))
(should (equal (match-string 99 "foo 'bar':") "bar"))))
+(ert-deftest magit-process:password-prompt-regexps ()
+ (cl-flet ((m (prompt)
+ (and (magit-process-match-prompt
+ magit-process-password-prompt-regexps prompt)
+ (or (match-string 99 prompt) t))))
+ ;; History of `magit-process-password-prompt-regexps':
+ ;; a36a801cc2 Initial noisy version.
+ ;; 2a3bbc3c53 First cleanup.
+ ;; "^\\(Enter \\)?[Pp]assphrase\\( for key '.*'\\)?: ?$"
+ ;; "^\\(Enter \\)?[Pp]assword\\( for '.*'\\)?: ?$"
+ ;; "^.*'s password: ?$"
+ ;; "^Yubikey for .*: ?$")
+ (should (eq (m "Passphrase: ") t))
+ (should (eq (m "Enter passphrase: ") t))
+ (should (eq (m "Enter passphrase for key '/home/me/.ssh/id_rsa': ") t))
+ (should (eq (m "Password: ") t))
+ (should (equal (m "Password for 'https://example.com': ") "example.com"))
+ (should (eq (m "Yubikey for foobar: ") t))
+ ;; 272f2069a3 Support for "RSA " in passphrase prompt.
+ ;; $ strings $(which ssh) | grep -i passphrase
+ ;; Nowadays this only gives:
+ ;; Enter passphrase for key '%.100s':
+ ;; So this is only necessary for historic versions.
+ (should (eq (m "Enter passphrase for RSA key '/home/me/.ssh/id_rsa': ") t))
+ ;; #2736 Support pcsc-lite (version 1.8.14 on NixOS).
+ (should (eq (m "Enter PIN for 'PIV_II (PIV Card Holder pin)':") t))
+ ;; #3651 Don't include "https://" in host match.
+ (should (equal (m "Password for 'https://me@magit.vc':") "me@magit.vc"))
+ ;; #4025 Don't require quotes around host match.
+ (should (equal (m "Password for ahihi@foo:") "ahihi@foo"))
+ ;; #4076 Support GnuPG for PGP and SSH keys.
+ (should (eq (m "│ Please enter the passphrase to unlock the OpenPGP secret
key: │") t))
+ (should (eq (m "│ Please enter the passphrase for the ssh key: │") t))
+ ;; #4318 Support git-credential-manager-core.
+ (should (eq (m "Token: ") t))
+ ;; #4992 Support openssh (version 9.1p1).
+ (should (equal (m "(user@host) Password for user@host: ") "user@host"))
+ ;; #5257 Support another prompt (by what?).
+ (should (equal (m "volumio@192.168.0.211's password: ")
"volumio@192.168.0.211"))
+ ;; #5288 Major rewrite, adding this test and history.
+ ))
+
(ert-deftest magit-process:password-prompt ()
(let ((magit-process-find-password-functions
(list (lambda (host) (and (string= host "www.host.com")
"mypasswd")))))
- [nongnu] elpa/magit c1f1da238e 10/31: magit-commit: Change descriptions of "spread" commands, (continued)
- [nongnu] elpa/magit c1f1da238e 10/31: magit-commit: Change descriptions of "spread" commands, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 778ad46f01 16/31: Improve documentation about commit commands, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 0e624c6c39 15/31: Rearrange definitions and documentation of commit commands, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 20eb323b47 08/31: magit-commit: Disable magit-commit-reshelve, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit e9614a336f 21/31: magit-commit-revise: Don't show diff in log-select, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit a43c1d8d7a 31/31: magit-process-password-prompt-regexps: Increase flexibility, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 7ac3896481 26/31: magit-process-password-prompt-regexps: Group regexps by type, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 889ec5bd89 23/31: magit-process:password-prompt: Cosmetics, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 4e4690968a 29/31: magit-process-password-prompt-regexps: Split out a host regexp, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit c28ddcf14e 27/31: magit-process-password-prompt-regexps: Move a newline, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 1312f89003 24/31: magit-process:password-prompt-regexps: New test,
Jonas Bernoulli <=
- [nongnu] elpa/magit bfc5ff4b6b 30/31: magit-process-password-prompt-regexps: Split out a non-host regexp, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 8b14384878 18/31: manual: Fix introduction to committing, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit fd4fb4c9d6 28/31: magit-process-password-prompt-regexps: Match double-quotes, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit bfadd41079 06/31: magit-commit-{absorb, autofixup}: Explicitly set transient behavior, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 75988adc0a 22/31: magit-process-match-prompt: Tweak docstring, Jonas Bernoulli, 2025/01/26
- [nongnu] elpa/magit 8f15054d09 19/31: manual: Fix pasto, Jonas Bernoulli, 2025/01/26