small pixel drawing of a pufferfish pa

add test script for testing pa functionality

- it's a shell script - run it using ./test
- it creates a dir `test-stuff` that contains the test artifacts
- the dir can be inspected between runs to help with debugging
Jes Olson j3s@c3f.net
Mon, 30 Sep 2024 22:19:45 -0400
commit

516d86560ae35e889ff2274cbe45d56fde0c5603

parent

ff521730586d5aadcfc6b507e8842f72ed377b3e

2 files changed, 49 insertions(+), 0 deletions(-)

jump to
A .gitignore

@@ -0,0 +1,1 @@

+test-stuff
A test

@@ -0,0 +1,48 @@

+#!/bin/sh +# +# test - a pa test script + +export pa="$(pwd)/pa" + +export PA_DIR=test-stuff/passwords + +# clean up previous run +# (the previous state is left around +# intentionally, in case the dev +# wants to poke around) +# that's why we don't clean up on exit +rm -rf test-stuff + +# pa welcomes you +$pa | grep -q "a simple password manager" || + printf "pa should print a welcome message\n" + +# generate pa dirs/identityfile/recipientfile +$pa list + +# pa auto-generated files are correct +test -s test-stuff/identities || + printf "an identities file should exist\n" +test -s test-stuff/recipients || + printf "a recipients file should exist\n" +test -d "$PA_DIR/.git" || + printf "git dir should exist\n" +# TODO: ensure git author/email are set correctly, etc + +# pa add +printf 'y\n' | $pa add test 2>&1 >/dev/null || + printf "pa add should be capable of adding a test password\n" +printf 'y\n' | $pa add nested/password 2>&1 | + grep -q "Saved 'nested/password' to the store." || + printf 'pa add should say it stored nested/passworod\n' +test -s test-stuff/passwords/nested/password.age || + printf 'pa add should create an encrypted password file\n' + +# pa list +$pa list | grep -q test || + printf "pa list should list the test password\n" + +# ensure git commits are working +cd test-stuff/passwords/ +git log | grep -q "add 'nested/password'" || + printf "git log should have line: add 'nested/password'\n"