diff options
| author | Michael Albinus | 2018-04-13 15:21:24 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-04-13 15:21:24 +0200 |
| commit | 1f31c1348c4ddec31664e78f8cf4b9514d2a32c6 (patch) | |
| tree | 1b9ab34b0ff5cb0b24ebe7f0355fd2d18aac517e /test | |
| parent | 9822a6a5708227897432f47d3f676c646b7bd4b2 (diff) | |
| download | emacs-1f31c1348c4ddec31664e78f8cf4b9514d2a32c6.tar.gz emacs-1f31c1348c4ddec31664e78f8cf4b9514d2a32c6.zip | |
Fix Bug#30246
* lisp/auth-source.el (auth-source-secrets-search): Do not
suppress creation.
(auth-source-secrets-create): Implement it. (Bug#30246)
* lisp/net/secrets.el (secrets-debug): Set default to nil.
* test/lisp/auth-source-tests.el (secrets): Require it.
(auth-source-test-secrets-create-secret): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/auth-source-tests.el | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index eb93f7488e4..2f5a9320b17 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -29,9 +29,7 @@ | |||
| 29 | (require 'ert) | 29 | (require 'ert) |
| 30 | (require 'cl-lib) | 30 | (require 'cl-lib) |
| 31 | (require 'auth-source) | 31 | (require 'auth-source) |
| 32 | 32 | (require 'secrets) | |
| 33 | (defvar secrets-enabled t | ||
| 34 | "Enable the secrets backend to test its features.") | ||
| 35 | 33 | ||
| 36 | (defun auth-source-ensure-ignored-backend (source) | 34 | (defun auth-source-ensure-ignored-backend (source) |
| 37 | (auth-source-validate-backend source '((:source . "") | 35 | (auth-source-validate-backend source '((:source . "") |
| @@ -289,5 +287,35 @@ | |||
| 289 | (should (equal found-as-string (concat testname ": " needed))))) | 287 | (should (equal found-as-string (concat testname ": " needed))))) |
| 290 | (delete-file netrc-file))) | 288 | (delete-file netrc-file))) |
| 291 | 289 | ||
| 290 | (ert-deftest auth-source-test-secrets-create-secret () | ||
| 291 | (skip-unless secrets-enabled) | ||
| 292 | ;; The "session" collection is temporary for the lifetime of the | ||
| 293 | ;; Emacs process. Therefore, we don't care to delete it. | ||
| 294 | (let ((auth-sources '((:source (:secrets "session")))) | ||
| 295 | (host (md5 (concat (prin1-to-string process-environment) | ||
| 296 | (current-time-string)))) | ||
| 297 | (passwd (md5 (concat (prin1-to-string process-environment) | ||
| 298 | (current-time-string) (current-time-string)))) | ||
| 299 | auth-info auth-passwd) | ||
| 300 | ;; Redefine `read-*' in order to avoid interactive input. | ||
| 301 | (cl-letf (((symbol-function 'read-passwd) (lambda (_) passwd)) | ||
| 302 | ((symbol-function 'read-string) | ||
| 303 | (lambda (_prompt _initial _history default) default))) | ||
| 304 | (setq auth-info | ||
| 305 | (car (auth-source-search | ||
| 306 | :max 1 :host host :require '(:user :secret) :create t)))) | ||
| 307 | (should (functionp (plist-get auth-info :save-function))) | ||
| 308 | (funcall (plist-get auth-info :save-function)) | ||
| 309 | |||
| 310 | ;; Check, that the item has been created indeed. | ||
| 311 | (auth-source-forget+ :host t) | ||
| 312 | (setq auth-info (car (auth-source-search :host host)) | ||
| 313 | auth-passwd (plist-get auth-info :secret) | ||
| 314 | auth-passwd (if (functionp auth-passwd) | ||
| 315 | (funcall auth-passwd) | ||
| 316 | auth-passwd)) | ||
| 317 | (should (string-equal (plist-get auth-info :user) (user-login-name))) | ||
| 318 | (should (string-equal auth-passwd passwd)))) | ||
| 319 | |||
| 292 | (provide 'auth-source-tests) | 320 | (provide 'auth-source-tests) |
| 293 | ;;; auth-source-tests.el ends here | 321 | ;;; auth-source-tests.el ends here |