diff options
| author | Eli Zaretskii | 2015-12-17 20:31:25 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-12-17 20:31:25 +0200 |
| commit | 938495317a02b06a6c512832d0c6d9530fcd7f2b (patch) | |
| tree | 2dad910f573e1021b12d94ad485a45d6f96aca3d /test | |
| parent | 85e93e626ce6d9e169cb5a5ab827092a9b48f85e (diff) | |
| download | emacs-938495317a02b06a6c512832d0c6d9530fcd7f2b.tar.gz emacs-938495317a02b06a6c512832d0c6d9530fcd7f2b.zip | |
Fix parsing netrc entries with ports
* lisp/gnus/auth-source.el (auth-source-ensure-strings): Don't
make a list out of 't'. (Bug#22188)
* test/automated/auth-source-tests.el
(auth-source-test-netrc-parse-entry): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/auth-source-tests.el | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/automated/auth-source-tests.el b/test/automated/auth-source-tests.el index 0b49b9013f7..dd70d546d5c 100644 --- a/test/automated/auth-source-tests.el +++ b/test/automated/auth-source-tests.el | |||
| @@ -174,5 +174,50 @@ | |||
| 174 | (:search-function . auth-source-secrets-search) | 174 | (:search-function . auth-source-secrets-search) |
| 175 | (:create-function . auth-source-secrets-create))))) | 175 | (:create-function . auth-source-secrets-create))))) |
| 176 | 176 | ||
| 177 | (defun auth-source--test-netrc-parse-entry (entry host user port) | ||
| 178 | "Parse a netrc entry from buffer." | ||
| 179 | (auth-source-forget-all-cached) | ||
| 180 | (setq port (auth-source-ensure-strings port)) | ||
| 181 | (with-temp-buffer | ||
| 182 | (insert entry) | ||
| 183 | (goto-char (point-min)) | ||
| 184 | (let* ((check (lambda(alist) | ||
| 185 | (and alist | ||
| 186 | (auth-source-search-collection | ||
| 187 | host | ||
| 188 | (or | ||
| 189 | (auth-source--aget alist "machine") | ||
| 190 | (auth-source--aget alist "host") | ||
| 191 | t)) | ||
| 192 | (auth-source-search-collection | ||
| 193 | user | ||
| 194 | (or | ||
| 195 | (auth-source--aget alist "login") | ||
| 196 | (auth-source--aget alist "account") | ||
| 197 | (auth-source--aget alist "user") | ||
| 198 | t)) | ||
| 199 | (auth-source-search-collection | ||
| 200 | port | ||
| 201 | (or | ||
| 202 | (auth-source--aget alist "port") | ||
| 203 | (auth-source--aget alist "protocol") | ||
| 204 | t))))) | ||
| 205 | (entries (auth-source-netrc-parse-entries check 1))) | ||
| 206 | entries))) | ||
| 207 | |||
| 208 | (ert-deftest auth-source-test-netrc-parse-entry () | ||
| 209 | (should (equal (auth-source--test-netrc-parse-entry | ||
| 210 | "machine mymachine1 login user1 password pass1\n" t t t) | ||
| 211 | '((("password" . "pass1") | ||
| 212 | ("login" . "user1") | ||
| 213 | ("machine" . "mymachine1"))))) | ||
| 214 | (should (equal (auth-source--test-netrc-parse-entry | ||
| 215 | "machine mymachine1 login user1 password pass1 port 100\n" | ||
| 216 | t t t) | ||
| 217 | '((("port" . "100") | ||
| 218 | ("password" . "pass1") | ||
| 219 | ("login" . "user1") | ||
| 220 | ("machine" . "mymachine1")))))) | ||
| 221 | |||
| 177 | (provide 'auth-source-tests) | 222 | (provide 'auth-source-tests) |
| 178 | ;;; auth-source-tests.el ends here | 223 | ;;; auth-source-tests.el ends here |