:tools password-store -> :tools pass

A simpler name and matches the prefix of its module.
This commit is contained in:
Henrik Lissner 2019-05-19 00:03:15 -04:00
parent 0674e4b4b0
commit c3cb7c5000
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
9 changed files with 13 additions and 12 deletions

View file

@ -0,0 +1,41 @@
;; -*- no-byte-compile: t; -*-
;;; tools/pass/test/test-pass.el
(describe "tools/pass"
(before-all
(load! "../autoload"))
(before-each
(spy-on 'auth-source-pass-parse-entry :and-call-fake
(lambda (entry)
(when (equal entry "fake/source")
'((secret . "defuse-account-gad")
("login" . "HL2532")
("alt-login" . "hlissner")
("email" . "henrik@lissner.net")
("url" . "https://some-place.net/login"))))))
(describe "get field"
(it "returns specific fields"
(expect (+pass-get-field "fake/source" "email")
:to-equal "henrik@lissner.net"))
(it "returns first existing of a list of fields"
(expect (+pass-get-field "fake/source" '("alt-login" "email"))
:to-equal "hlissner")
(expect (+pass-get-field "fake/source" '("username" "email"))
:to-equal "henrik@lissner.net"))
(it "returns nil for missing fields"
(expect (+pass-get-field "fake/source" '("x" "y" "z"))
:to-be nil))
(it "throws error on missing entries"
(expect (+pass-get-field "nonexistent/source" "login")
:to-throw)))
(describe "get user/secret"
(it "returns the user"
(let ((+pass-user-fields '("login" "user" "username" "email")))
(expect (+pass-get-user "fake/source")
:to-equal "HL2532")))
(it "returns the secret"
(expect (+pass-get-secret "fake/source")
:to-equal "defuse-account-gad"))))