diff options
author | F. Jason Park <jp@neverwas.me> | 2022-11-23 21:31:19 -0800 |
---|---|---|
committer | Amin Bandali <bandali@gnu.org> | 2022-11-28 23:56:04 -0500 |
commit | 35e2b8a26be06ac1e563801eeb2193c57fd1189d (patch) | |
tree | fa180ea6e783e816f54700b1153f50c0cb506fbd /test/lisp/erc/erc-sasl-tests.el | |
parent | 7336520fe774f7f7f5209c884e04911514bae796 (diff) | |
download | emacs-35e2b8a26be06ac1e563801eeb2193c57fd1189d.tar.gz emacs-35e2b8a26be06ac1e563801eeb2193c57fd1189d.tar.bz2 emacs-35e2b8a26be06ac1e563801eeb2193c57fd1189d.zip |
Add erc-sasl-auth-source-function to cached options
* lisp/erc/erc-sasl.el (erc-sasl--read-password): Consult cached
options instead of `erc-sasl-auth-source-function'.
(erc-sasl--init): Add `erc-sasl-auth-source-function' to
`erc-sasl--options'.
* test/lisp/erc/erc-sasl-tests.el (erc-sasl--read-password--basic,
erc-sasl--read-password--auth-source): Look for original value of
`erc-sasl-auth-source-function' in `erc-sasl--options' under the
`authfn' key.
Diffstat (limited to 'test/lisp/erc/erc-sasl-tests.el')
-rw-r--r-- | test/lisp/erc/erc-sasl-tests.el | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/lisp/erc/erc-sasl-tests.el b/test/lisp/erc/erc-sasl-tests.el index 64593ca270c..3e6828ff644 100644 --- a/test/lisp/erc/erc-sasl-tests.el +++ b/test/lisp/erc/erc-sasl-tests.el @@ -42,17 +42,17 @@ (erc-sasl--options '((password . :password)))) (should (string= (erc-sasl--read-password nil) "foo")))) - (ert-info ("Fallback to prompt skip auth-source") - (should-not erc-sasl-auth-source-function) - (let ((erc-session-password "bar") - (erc-networks--id (erc-networks--id-create nil))) + (ert-info ("Prompt when no authfn and :password resolves to nil") + (let ((erc-session-password nil) + (erc-sasl--options + '((password . :password) (user . :user) (authfn)))) (should (string= (ert-simulate-keys "bar\r" (erc-sasl--read-password "?")) "bar")))) - (ert-info ("Prompt when auth-source fails and `erc-sasl-password' null") - (let ((erc-sasl--options '((password))) - (erc-sasl-auth-source-function #'ignore)) + (ert-info ("Prompt when auth-source fails and `erc-session-password' null") + (should-not erc-session-password) + (let ((erc-sasl--options '((password) (authfn . ignore)))) (should (string= (ert-simulate-keys "baz\r" (erc-sasl--read-password "pwd:")) "baz"))))) @@ -71,36 +71,37 @@ (erc-session-port 6697) (erc-networks--id (erc-networks--id-create nil)) calls - (erc-sasl-auth-source-function - (lambda (&rest r) - (push r calls) - (apply #'erc--auth-source-search r))) + (fn (lambda (&rest r) + (push r calls) + (apply #'erc-auth-source-search r))) erc-server-announced-name ; too early auth-source-do-cache) (ert-info ("Symbol as password specifies machine") - (let ((erc-sasl--options '((user . "bob") (password . FSF.chat))) + (let ((erc-sasl--options + `((user . "bob") (password . FSF.chat) (authfn . ,fn))) (erc-networks--id (make-erc-networks--id))) (should (string= (erc-sasl--read-password nil) "sesame")) (should (equal (pop calls) '(:user "bob" :host "FSF.chat"))))) (ert-info ("ID for :host and `erc-session-username' for :user") ; *1 (let ((erc-session-username "bob") - (erc-sasl--options '((user . :user) (password))) + (erc-sasl--options `((user . :user) (password) (authfn . ,fn))) (erc-networks--id (erc-networks--id-create 'GNU/chat))) (should (string= (erc-sasl--read-password nil) "spam")) (should (equal (pop calls) '(:user "bob" :host "GNU/chat"))))) (ert-info ("ID for :host and current nick for :user") ; *1 (let ((erc-server-current-nick "bob") - (erc-sasl--options '((user . :nick) (password))) + (erc-sasl--options `((user . :nick) (password) (authfn . ,fn))) (erc-networks--id (erc-networks--id-create 'GNU/chat))) (should (string= (erc-sasl--read-password nil) "spam")) (should (equal (pop calls) '(:user "bob" :host "GNU/chat"))))) (ert-info ("Symbol as password, entry lacks user field") (let ((erc-server-current-nick "fake") - (erc-sasl--options '((user . :nick) (password . MyHost))) + (erc-sasl--options + `((user . :nick) (password . MyHost) (authfn . ,fn))) (erc-networks--id (erc-networks--id-create 'GNU/chat))) (should (string= (erc-sasl--read-password nil) "123")) (should (equal (pop calls) '(:user "fake" :host "MyHost")))))))) |