diff options
| author | Michael Albinus | 2025-09-15 11:43:52 +0200 |
|---|---|---|
| committer | Michael Albinus | 2025-09-15 11:43:52 +0200 |
| commit | 72c19d0f395e8883c65689c86e79905a34d36586 (patch) | |
| tree | bb277e51742b2f473246287fc1048784df5ffa75 /test | |
| parent | 897d32285fc17b8afd889b1f733aed7149b50a5c (diff) | |
| download | emacs-72c19d0f395e8883c65689c86e79905a34d36586.tar.gz emacs-72c19d0f395e8883c65689c86e79905a34d36586.zip | |
Improve check for netrc tokens
* doc/misc/auth.texi (Help for users): Mention also "#" inside tokens.
* lisp/auth-source.el (auth-source-netrc-create): Better check for
token format.
* test/lisp/auth-source-tests.el (auth-source-backend-parse-json):
New test.
(auth-source-test-netrc-create-secret): Extend test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/auth-source-tests.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index b4bc0f5a7f6..d6845b0af37 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -119,6 +119,16 @@ | |||
| 119 | (create-function | 119 | (create-function |
| 120 | . auth-source-netrc-create)))) | 120 | . auth-source-netrc-create)))) |
| 121 | 121 | ||
| 122 | (ert-deftest auth-source-backend-parse-json () | ||
| 123 | (auth-source-validate-backend '(:source "foo.json") | ||
| 124 | '((source . "foo.json") | ||
| 125 | (type . json) | ||
| 126 | (search-function . auth-source-json-search) | ||
| 127 | (create-function | ||
| 128 | ;; To be implemented: | ||
| 129 | ;; . auth-source-json-create)))) | ||
| 130 | . ignore)))) | ||
| 131 | |||
| 122 | (ert-deftest auth-source-backend-parse-secrets () | 132 | (ert-deftest auth-source-backend-parse-secrets () |
| 123 | (provide 'secrets) ; simulates the presence of the `secrets' package | 133 | (provide 'secrets) ; simulates the presence of the `secrets' package |
| 124 | (let ((secrets-enabled t)) | 134 | (let ((secrets-enabled t)) |
| @@ -383,7 +393,8 @@ | |||
| 383 | (auth-source-save-behavior t) | 393 | (auth-source-save-behavior t) |
| 384 | (auth-source-ignore-non-existing-file t) | 394 | (auth-source-ignore-non-existing-file t) |
| 385 | host auth-info auth-passwd) | 395 | host auth-info auth-passwd) |
| 386 | (dolist (passwd '("foo" "" nil)) | 396 | (dolist (passwd `("foo" "bar baz" "bar'baz" "bar\"baz" |
| 397 | "foo'bar\"baz" "" nil)) | ||
| 387 | ;; Redefine `read-*' in order to avoid interactive input. | 398 | ;; Redefine `read-*' in order to avoid interactive input. |
| 388 | (cl-letf (((symbol-function 'read-passwd) (lambda (_) passwd)) | 399 | (cl-letf (((symbol-function 'read-passwd) (lambda (_) passwd)) |
| 389 | ((symbol-function 'read-string) | 400 | ((symbol-function 'read-string) |
| @@ -409,7 +420,9 @@ | |||
| 409 | auth-passwd (auth-info-password auth-info)) | 420 | auth-passwd (auth-info-password auth-info)) |
| 410 | (with-temp-buffer | 421 | (with-temp-buffer |
| 411 | (insert-file-contents netrc-file) | 422 | (insert-file-contents netrc-file) |
| 412 | (if (zerop (length passwd)) | 423 | (if (or (zerop (length passwd)) |
| 424 | (and (string-match-p "\"" passwd) | ||
| 425 | (string-match-p "'" passwd))) | ||
| 413 | (progn | 426 | (progn |
| 414 | (should-not (plist-get auth-info :user)) | 427 | (should-not (plist-get auth-info :user)) |
| 415 | (should-not (plist-get auth-info :host)) | 428 | (should-not (plist-get auth-info :host)) |