aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii2023-09-30 13:50:07 -0400
committerEli Zaretskii2023-09-30 13:50:07 -0400
commit46978fa1eff286ea15248ee358fe62608ca070c5 (patch)
treea9cce889b60229e11006585e276a018719e5fdad /test
parente6dd64aaba55b93340de1d7e0d6783da6de2af2f (diff)
parent4776d90c31b3d5bc4117ca7ecde95444adf402ac (diff)
downloademacs-46978fa1eff286ea15248ee358fe62608ca070c5.tar.gz
emacs-46978fa1eff286ea15248ee358fe62608ca070c5.zip
Merge from origin/emacs-29
4776d90c31b Add new Tramp test ca5b48fd76d Fix tmm-mid-prompt :type (Bug#66179) 7447d3df94e Fix tree-sitter indentation conflict with multiple languages bee18e52737 Fix bug#66093 in Tramp 7d5fee0feaa Support regeneration of ja-dic.el under '--with-small-ja-... Conflicts: make-dist
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-tests.el61
1 files changed, 60 insertions, 1 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 69d31a54644..e382d044275 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -7886,7 +7886,7 @@ process sentinels. They shall not disturb each other."
7886 (shell-command-to-string "read -s -p Password: pass")))) 7886 (shell-command-to-string "read -s -p Password: pass"))))
7887 7887
7888 (let ((pass "secret") 7888 (let ((pass "secret")
7889 (mock-entry (copy-sequence (assoc "mock" tramp-methods))) 7889 (mock-entry (copy-tree (assoc "mock" tramp-methods)))
7890 mocked-input tramp-methods) 7890 mocked-input tramp-methods)
7891 ;; We must mock `read-string', in order to avoid interactive 7891 ;; We must mock `read-string', in order to avoid interactive
7892 ;; arguments. 7892 ;; arguments.
@@ -7933,6 +7933,65 @@ process sentinels. They shall not disturb each other."
7933 (let ((auth-sources `(,netrc-file))) 7933 (let ((auth-sources `(,netrc-file)))
7934 (should (file-exists-p ert-remote-temporary-file-directory))))))))) 7934 (should (file-exists-p ert-remote-temporary-file-directory)))))))))
7935 7935
7936(ert-deftest tramp-test46-read-otp-password ()
7937 "Check Tramp one-time password handling."
7938 :tags '(:expensive-test)
7939 (skip-unless (tramp--test-mock-p))
7940 ;; Not all read commands understand argument "-s" or "-p".
7941 (skip-unless
7942 (string-empty-p
7943 (let ((shell-file-name "sh"))
7944 (shell-command-to-string "read -s -p Password: pass"))))
7945
7946 (let ((pass "secret")
7947 (mock-entry (copy-tree (assoc "mock" tramp-methods)))
7948 mocked-input tramp-methods)
7949 ;; We must mock `read-string', in order to avoid interactive
7950 ;; arguments.
7951 (cl-letf* (((symbol-function #'read-string)
7952 (lambda (&rest _args) (pop mocked-input))))
7953 (setcdr
7954 (assq 'tramp-login-args mock-entry)
7955 `((("-c")
7956 (,(tramp-shell-quote-argument
7957 (concat
7958 "read -s -p 'Verification code: ' pass; echo; "
7959 "(test \"pass$pass\" != \"pass" pass "\" && "
7960 "echo \"Login incorrect\" || sh -i)"))))))
7961 (setq tramp-methods `(,mock-entry))
7962
7963 ;; Reading password from stdin works.
7964 (tramp-cleanup-connection tramp-test-vec 'keep-debug)
7965 ;; We don't want to invalidate the password.
7966 (setq mocked-input `(,(copy-sequence pass)))
7967 (should (file-exists-p ert-remote-temporary-file-directory))
7968
7969 ;; Don't entering a password returns in error.
7970 (tramp-cleanup-connection tramp-test-vec 'keep-debug)
7971 (setq mocked-input nil)
7972 (should-error (file-exists-p ert-remote-temporary-file-directory))
7973
7974 ;; A wrong password doesn't work either.
7975 (tramp-cleanup-connection tramp-test-vec 'keep-debug)
7976 (setq mocked-input `(,(concat pass pass)))
7977 (should-error (file-exists-p ert-remote-temporary-file-directory))
7978
7979 ;; The password shouldn't be read from auth-source.
7980 ;; Macro `ert-with-temp-file' was introduced in Emacs 29.1.
7981 (with-no-warnings (when (symbol-plist 'ert-with-temp-file)
7982 (tramp-cleanup-connection tramp-test-vec 'keep-debug)
7983 (setq mocked-input nil)
7984 (auth-source-forget-all-cached)
7985 (ert-with-temp-file netrc-file
7986 :prefix "tramp-test" :suffix ""
7987 :text (format
7988 "machine %s port mock password %s"
7989 (file-remote-p ert-remote-temporary-file-directory 'host)
7990 pass)
7991 (let ((auth-sources `(,netrc-file)))
7992 (should-error
7993 (file-exists-p ert-remote-temporary-file-directory)))))))))
7994
7936;; This test is inspired by Bug#29163. 7995;; This test is inspired by Bug#29163.
7937(ert-deftest tramp-test48-auto-load () 7996(ert-deftest tramp-test48-auto-load ()
7938 "Check that Tramp autoloads properly." 7997 "Check that Tramp autoloads properly."