diff options
author | F. Jason Park <jp@neverwas.me> | 2022-12-02 23:11:24 -0800 |
---|---|---|
committer | F. Jason Park <jp@neverwas.me> | 2022-12-14 06:40:55 -0800 |
commit | 0155fc67be393239e5a2956d5dfaf6a0f74b517e (patch) | |
tree | c36c226ef68dad55b76648ab97724a0f20de84fa /test/lisp/erc/erc-scenarios-services-misc.el | |
parent | 9ac80e8a6e4969cfe88d5233dc4152bbfa46c848 (diff) | |
download | emacs-0155fc67be393239e5a2956d5dfaf6a0f74b517e.tar.gz emacs-0155fc67be393239e5a2956d5dfaf6a0f74b517e.tar.bz2 emacs-0155fc67be393239e5a2956d5dfaf6a0f74b517e.zip |
Respect a nil erc-session-password when reconnecting
* lisp/erc/erc.el (erc-open): Simplify `old-vars' expression.
(erc--compute-server-password): Only compute a server password when
first connecting. For compatibility, this respects third-party code
that expects session passwords in target buffers when initially
non-nil.
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-auth-source-reconnect): Add new test.
* test/lisp/erc/resources/services/auth-source/recon.eld: Add new test
data file. (Bug#59858.)
Diffstat (limited to 'test/lisp/erc/erc-scenarios-services-misc.el')
-rw-r--r-- | test/lisp/erc/erc-scenarios-services-misc.el | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-scenarios-services-misc.el b/test/lisp/erc/erc-scenarios-services-misc.el index 680750d2d71..44e04e51509 100644 --- a/test/lisp/erc/erc-scenarios-services-misc.el +++ b/test/lisp/erc/erc-scenarios-services-misc.el @@ -84,4 +84,63 @@ (should-not (memq 'services erc-modules)))) +;; A user with `services' enabled connects, quits, and reconnects. An +;; entry in their netrc matches the network ID, which isn't known when +;; `erc-auth-source-server-function' runs -- initially *or* on +;; reconnect. It's only seen by `erc-auth-source-services-function'. + +(ert-deftest erc-scenarios-services-auth-source-reconnect () + :tags '(:expensive-test) + (erc-scenarios-common-with-cleanup + ((erc-scenarios-common-dialog "services/auth-source") + (erc-server-flood-penalty 0.1) + (dumb-server (erc-d-run "localhost" t 'recon 'recon)) + (port (process-contact dumb-server :service)) + (netrc-file (make-temp-file + "auth-source-test" nil nil + "machine FooNet login tester password changeme\n")) + (auth-sources (list netrc-file)) + (auth-source-do-cache nil) + (erc-modules (cons 'services erc-modules)) + (erc-use-auth-source-for-nickserv-password t) ; do consult + (erc-prompt-for-nickserv-password nil) ; don't prompt + (erc-nickserv-alist + (cons '(FooNet + "NickServ!NickServ@services.int" + "This nickname is registered. Please choose" + "NickServ" "IDENTIFY" nil nil "You are now identified for ") + erc-nickserv-alist)) + (expect (erc-d-t-make-expecter)) + (erc-scenarios-common-extra-teardown (lambda () + (delete-file netrc-file)))) + + (ert-info ("Server password omitted from initial connection") + (with-current-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :user "tester" + :full-name "tester") + (should (string= (buffer-name) (format "127.0.0.1:%d" port))) + (ert-info ("Services module authenticates") + (funcall expect 10 "This nickname is registered.") + (funcall expect 3 "You are now identified")) + (erc-cmd-JOIN "#chan") + (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) + (funcall expect 10 "the gallants desire it")) + (erc-cmd-QUIT "") + (funcall expect 3 "finished"))) + + (ert-info ("Server password withheld on reconnect") + (with-current-buffer "#chan" + (erc-cmd-RECONNECT)) + (with-current-buffer "FooNet" + (funcall expect 10 "This nickname is registered.") + (funcall expect 3 "You are now identified") + (with-current-buffer "#chan" ; autojoined + (funcall expect 10 "the gallants desire it")) + (erc-cmd-QUIT "") + (funcall expect 3 "finished"))) + + (erc-services-mode -1))) + ;;; erc-scenarios-services-misc.el ends here |