[PATCH consfigurator v3 8/8] add tests for pass data source.
Sean Whitton
spwhitton at spwhitton.name
Sun Mar 20 17:55:31 GMT 2022
Hello,
On Sun 13 Mar 2022 at 11:40am -03, David Bremner wrote:
> diff --git a/tests/runner.lisp b/tests/runner.lisp
> index 6615683..7be865e 100644
> --- a/tests/runner.lisp
> +++ b/tests/runner.lisp
> @@ -65,6 +65,32 @@ registered and populated."
> (try-register-data-source :pgp :location *test-pgp-file*)
> , at body))
>
> +(defparameter *test-pass-dir* nil
> + "pass(1) store for use in test suite.")
> +
> +(defun pass (args &key input)
> + (run-program `("env" ,#?"GNUPGHOME=${*data-source-gnupghome*}"
> + ,#?"PASSWORD_STORE_DIR=${*test-pass-dir*}" "pass"
> + , at args)
> + :input (if input (make-string-input-stream input) nil)
> + :output :string :error-output :output))
> +
> +(defmacro with-test-pass-source (test-home &rest body)
> + "Run BODY with pass(1) data source in TEST-HOME populated and registed."
> + `(let ((*test-pass-dir* (strcat (namestring ,test-home) "/password-store")))
> + (pass (list "init" *test-gnupg-fingerprint*))
> + (pass '("insert" "-m" "server.example.org/account") :input "hunter2")
> + (pass '("insert" "-m" "_foo/bar/baz") :input "OK")
> + (pass '("insert" "-m" "foo/bar/baz") :input "illegal")
> + (pass '("insert" "-m" "valid/file") :input "shadowed")
> + (pass '("insert" "-m" "_valid/file") :input "visible")
> + (pass '("insert" "-m" "toplevel") :input "sekrit")
> + (pass '("insert" "-m" "server.example.org/etc/foo.conf")
> + :input "[section]
> +key=value")
> + (try-register-data-source :pass :location *test-pass-dir*)
> + , at body))
> +
Same comments as for patch #5, but additionally: I wonder if we should
catch MISSING-DATA-SOURCE from within TRY-REGISTER-DATA-SOURCE and turn
it into a generic error, since it's not really a missing data source?
This would also block the SKIP-DATA-SOURCE restart within
TRY-REGISTER-DATA-SOURCE, which wouldn't make sense in this case.
Something like
(handler-case (try-register-data-source ...)
(missing-data-source () (error "Test setup failure ...")))
?
--
Sean Whitton
More information about the sgo-software-discuss
mailing list