tools/password-store: fix emacs 26 compatibility
This commit is contained in:
parent
41751aca44
commit
3bc0b18184
2 changed files with 30 additions and 18 deletions
|
@ -10,14 +10,19 @@
|
||||||
(t
|
(t
|
||||||
(pass))))
|
(pass))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defalias '+pass--get-entry
|
||||||
|
(if (featurep 'auth-store-pass)
|
||||||
|
#'auth-source-pass-parse-entry
|
||||||
|
#'auth-pass-parse-entry))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +pass-get-field (entry fields)
|
(defun +pass-get-field (entry fields)
|
||||||
(unless noninteractive
|
(if-let* ((data (if (listp entry) entry (+pass--get-entry entry))))
|
||||||
(if-let* ((data (if (listp entry) entry (auth-pass-parse-entry entry))))
|
(cl-loop for key in (doom-enlist fields)
|
||||||
(cl-loop for key in (doom-enlist fields)
|
when (assoc key data)
|
||||||
when (assoc key data)
|
return (cdr it))
|
||||||
return (cdr it))
|
(error "Couldn't find entry: %s" entry)))
|
||||||
(error "Couldn't find entry: %s" entry))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +pass-get-user (entry)
|
(defun +pass-get-user (entry)
|
||||||
|
@ -35,7 +40,7 @@
|
||||||
(error "Username not found.")))
|
(error "Username not found.")))
|
||||||
|
|
||||||
(defun +pass-ivy-action--get-field (item)
|
(defun +pass-ivy-action--get-field (item)
|
||||||
(let* ((data (auth-pass-parse-entry item))
|
(let* ((data (+pass--get-entry item))
|
||||||
(field (if data (completing-read "Field: " (mapcar #'car data) nil t))))
|
(field (if data (completing-read "Field: " (mapcar #'car data) nil t))))
|
||||||
(if data
|
(if data
|
||||||
(progn
|
(progn
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; tools/password-store/test/autoload-pass.el
|
;;; tools/password-store/test/autoload-pass.el
|
||||||
|
|
||||||
|
(load! ../autoload)
|
||||||
|
|
||||||
(defmacro -with-passwords! (buffer-args &rest body)
|
(defmacro -with-passwords! (buffer-args &rest body)
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
`(cl-letf
|
`(cl-letf
|
||||||
(((symbol-function 'auth-pass-parse-entry)
|
(((symbol-function '+pass--get-entry)
|
||||||
(lambda (entry)
|
(lambda (entry)
|
||||||
(when (equal entry "fake/source")
|
(when (equal entry "fake/source")
|
||||||
'((secret . "defuse-account-gad")
|
'((secret . "defuse-account-gad")
|
||||||
|
@ -17,17 +19,22 @@
|
||||||
;;
|
;;
|
||||||
(def-test! get-field
|
(def-test! get-field
|
||||||
(-with-passwords!
|
(-with-passwords!
|
||||||
(should (equal (+pass-get-field "fake/source" "login")
|
(should (equal (+pass-get-field "fake/source" "login")
|
||||||
"HL2532-GANDI"))
|
"HL2532-GANDI"))
|
||||||
(should (equal (+pass-get-field "fake/source" "email")
|
(should (equal (+pass-get-field "fake/source" "email")
|
||||||
"henrik@lissner.net"))
|
"henrik@lissner.net"))
|
||||||
(should (equal (+pass-get-field "fake/source" '("alt-login" "email"))
|
(should (equal (+pass-get-field "fake/source" '("alt-login" "email"))
|
||||||
"hlissner"))
|
"hlissner"))
|
||||||
(should (equal (+pass-get-field "fake/source" '("username" "email"))
|
(should (equal (+pass-get-field "fake/source" '("username" "email"))
|
||||||
"henrik@lissner.net"))
|
"henrik@lissner.net"))))
|
||||||
(should-not (+pass-get-field "fake/source" '("x" "y" "z")))
|
|
||||||
|
|
||||||
(should-error (+pass-get-field "nonexistent/source" "login"))))
|
(def-test! missing-fields-return-nil
|
||||||
|
(-with-passwords!
|
||||||
|
(should-not (+pass-get-field "fake/source" '("x" "y" "z")))))
|
||||||
|
|
||||||
|
(def-test! missing-entries-throw-error
|
||||||
|
(-with-passwords!
|
||||||
|
(should-error (+pass-get-field "nonexistent/source" "login"))))
|
||||||
|
|
||||||
(def-test! get-login
|
(def-test! get-login
|
||||||
(-with-passwords!
|
(-with-passwords!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue