[PATCH consfigurator v3 5/8] initial tests for consfigurator.data.pgp

Sean Whitton spwhitton at spwhitton.name
Sun Mar 20 17:37:48 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 0a9867b..6615683 100644
> --- a/tests/runner.lisp
> +++ b/tests/runner.lisp
> @@ -53,6 +53,18 @@ mainly useful when there is a single primary key."
>  *DATA-SOURCE-GNUPGHOME* set appropriately."
>    `(with-test-gnupg-home-func ,base-dir (lambda () (progn , at body))))
>
> +(defparameter *test-pgp-file* nil)
> +
> +(defmacro with-test-pgp-source (base-dir &rest body)
> +  "Run BODY with *TEST-PGP-FILE* defined and a corresponding pgp data source
> +registered and populated."
> +  `(let ((*test-pgp-file* (strcat (namestring ,base-dir) "/pgp-secrets.gpg")))

Could move the comma outside the strcat to make it clear that it's going
to be a constant value, so no variable capture issues to defuse.

Also, this is minor, but if you're going to use NAMESTRING not
UNIX-NAMESTRING then it probably makes sense to use MERGE-PATHNAMES too,
rather than hardcoding a forward slash.

> +     (data.pgp:set-data *test-pgp-file* "_secrets" "test" "this is a sekrit")
> +     (data.pgp:set-data *test-pgp-file* "host.example.com" "/etc/foo.conf"
> +                        "secret file content")
> +     (try-register-data-source :pgp :location *test-pgp-file*)
> +     , at body))

Could we define these two over in tests/data/pgp.lisp?  It would make
the tests over there more readable and it doesn't seem general enough to
be in runner.lisp.  You'll need to move runner.lisp down the list in
consfigurator.asd, but it doesn't look like that'll be a problem.

-- 
Sean Whitton



More information about the sgo-software-discuss mailing list