diff options
| author | Filipp Gunbin | 2018-05-15 03:02:49 +0300 |
|---|---|---|
| committer | Filipp Gunbin | 2018-05-17 18:44:31 +0300 |
| commit | 60ff8101449eea3a5ca4961299501efd83d011bd (patch) | |
| tree | 9947d1ac9503a65842975bb560a78265c41bc9a9 /test | |
| parent | 01120ec3d2eecd11e23f008feed020def7ea0e88 (diff) | |
| download | emacs-60ff8101449eea3a5ca4961299501efd83d011bd.tar.gz emacs-60ff8101449eea3a5ca4961299501efd83d011bd.zip | |
Fix bugs in `auth-source-netrc-parse-one'.
* lisp/auth-source.el (auth-source-netrc-parse-one): Ensure that match
data is not overwritten in `auth-source-netrc-parse-next-interesting'.
Ensure that blanks are skipped before and after going over comments
and eols.
* test/lisp/auth-source-tests.el (auth-source-test-netrc-parse-one): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/auth-source-tests.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index 1f6737cb7c8..be516f2c40d 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -208,6 +208,25 @@ | |||
| 208 | ("login" . "user1") | 208 | ("login" . "user1") |
| 209 | ("machine" . "mymachine1")))))) | 209 | ("machine" . "mymachine1")))))) |
| 210 | 210 | ||
| 211 | (ert-deftest auth-source-test-netrc-parse-one () | ||
| 212 | (should (equal (auth-source--test-netrc-parse-one--all | ||
| 213 | "machine host1\n# comment\n") | ||
| 214 | '("machine" "host1"))) | ||
| 215 | (should (equal (auth-source--test-netrc-parse-one--all | ||
| 216 | "machine host1\n \n \nmachine host2\n") | ||
| 217 | '("machine" "host1" "machine" "host2")))) | ||
| 218 | |||
| 219 | (defun auth-source--test-netrc-parse-one--all (text) | ||
| 220 | "Parse TEXT with `auth-source-netrc-parse-one' until end,return list." | ||
| 221 | (with-temp-buffer | ||
| 222 | (insert text) | ||
| 223 | (goto-char (point-min)) | ||
| 224 | (let ((one (auth-source-netrc-parse-one)) all) | ||
| 225 | (while one | ||
| 226 | (push one all) | ||
| 227 | (setq one (auth-source-netrc-parse-one))) | ||
| 228 | (nreverse all)))) | ||
| 229 | |||
| 211 | (ert-deftest auth-source-test-format-prompt () | 230 | (ert-deftest auth-source-test-format-prompt () |
| 212 | (should (equal (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host"))) | 231 | (should (equal (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host"))) |
| 213 | "test user host %p"))) | 232 | "test user host %p"))) |