Here is the patch attached.
On 02/06/2017 11:07 AM, HacKan wrote: > Tests fails on latest password-store.sh because they're outdated. Also, > config vars weren't unset so local user config affected tests. > > I'm working on a few patches for pass, so I forked the project. Here's > the patch for tests: > https://github.com/HacKanCuBa/passh/commit/2e6767ea07c3b5a3f3c49eecf645efbb7ff588e0 > > Cheers! > -- HacKan || Iván GPG: 0x35710D312FDE468B
>From 2e6767ea07c3b5a3f3c49eecf645efbb7ff588e0 Mon Sep 17 00:00:00 2001 From: HacKan <[email protected]> Date: Mon, 6 Feb 2017 10:33:41 -0300 Subject: [PATCH] Fixed tests. Added script to run them all. Rebranded passh passes all tests. t0001: now compatible with passh. t0010: tests were broken (pwgen is no longer used, added fake tr). added a new test for random passwd generation. setup: unset all config vars before running, otherwise user config affects tests. --- tests/run-all-tests | 19 +++++++++++++++++++ tests/setup.sh | 17 +++++++++++++++++ tests/t0001-sanity-checks.sh | 2 +- tests/t0010-generate-tests.sh | 10 +++++++++- tests/tr | 2 ++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 tests/run-all-tests mode change 100755 => 100644 tests/t0001-sanity-checks.sh create mode 100755 tests/tr diff --git a/tests/run-all-tests b/tests/run-all-tests new file mode 100755 index 0000000..2bf9c6e --- /dev/null +++ b/tests/run-all-tests @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +echo -e "Running all enabled tests...\n" + +cd "$(dirname "$0")" + +for t in ls t*.sh; do + [[ ! -f "$t" ]] && continue + + if [[ -x "$t" ]]; then + echo "Running: $t" + ./$t + echo -e "Done\n" + else + echo -e "Not running (disabled): ${t}\n" + fi +done + +echo "All enabled tests executed, have a nice day" diff --git a/tests/setup.sh b/tests/setup.sh index 779f14a..ddf311a 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -7,6 +7,22 @@ # $TEST_HOME This folder +# Unset config vars +unset PASSWORD_STORE_DIR +unset PASSWORD_STORE_KEY +unset PASSWORD_STORE_GIT +unset PASSWORD_STORE_GPG_OPTS +unset PASSWORD_STORE_X_SELECTION +unset PASSWORD_STORE_CLIP_TIME +unset PASSWORD_STORE_UMASK +unset PASSWORD_STORE_GENERATED_LENGTH +unset PASSWORD_STORE_CHARACTER_SET +unset PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS +unset PASSWORD_STORE_ENABLE_EXTENSIONS +unset PASSWORD_STORE_EXTENSIONS_DIR +unset PASSWORD_STORE_SIGNING_KEY +unset EDITOR + # We must be called from tests/ !! TEST_HOME="$(pwd)" @@ -46,3 +62,4 @@ KEY2="D774A374" # pass test key 2 KEY3="EB7D54A8" # pass test key 3 KEY4="E4691410" # pass test key 4 KEY5="39E5020C" # pass test key 5 + diff --git a/tests/t0001-sanity-checks.sh b/tests/t0001-sanity-checks.sh old mode 100755 new mode 100644 index 92cb785..182e1a1 --- a/tests/t0001-sanity-checks.sh +++ b/tests/t0001-sanity-checks.sh @@ -5,7 +5,7 @@ cd "$(dirname "$0")" . ./setup.sh test_expect_success 'Make sure we can run pass' ' - "$PASS" --help | grep "pass: the standard unix password manager" + "$PASS" --help | grep "the standard unix password manager" ' test_expect_success 'Make sure we can initialize our test store' ' diff --git a/tests/t0010-generate-tests.sh b/tests/t0010-generate-tests.sh index cadb76f..17c74b9 100755 --- a/tests/t0010-generate-tests.sh +++ b/tests/t0010-generate-tests.sh @@ -12,8 +12,16 @@ test_expect_success 'Test "generate" command' ' test_expect_success 'Test replacement of first line' ' "$PASS" insert -m cred2 <<<"$(printf "this is a big\\npassword\\nwith\\nmany\\nlines\\nin it bla bla")" && - PATH="$TEST_HOME:$PATH" FAKE_PWGEN_PASSWORD="This is a fake password" "$PASS" generate -i cred2 88 && + PATH="$TEST_HOME:$PATH" FAKE_PWGEN_PASSWORD="This is a fake password" "$PASS" generate -i cred2 23 && [[ $("$PASS" show cred2) == "$(printf "This is a fake password\\npassword\\nwith\\nmany\\nlines\\nin it bla bla")" ]] ' +test_expect_success 'Test replacement of first line with random' ' + PASSWD="this is a big\\npassword\\nwith\\nmany\\nlines\\nin it bla bla" && + "$PASS" insert -m cred3 <<<"$(printf "$PASSWD")" && + GENERATED="$("$PASS" generate -n -i cred3 20 | cut -f7 -d\ | tr -d "[:space:]" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" && + REMAIN="$(echo -e $PASSWD | tail -n $(printf "$PASSWD" | wc -l))" && + [[ $("$PASS" show cred3) == "$(printf "${GENERATED}\\n${REMAIN}")" ]] +' + test_done diff --git a/tests/tr b/tests/tr new file mode 100755 index 0000000..c83eec9 --- /dev/null +++ b/tests/tr @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo "${FAKE_PWGEN_PASSWORD:-Hello World}" -- 2.11.0
53dce40763ce8d70447fc9336f0bf4bbf28d00ea49eecf511b50aac6cf86f90d94307d6abca5c1f10f06145069e7709bcdf47eaf62d58c9b5dba5f720abfedd0 0001-Fixed-tests.-Added-script-to-run-them-all.-Rebranded.patch
SHA512SUMS.sig
Description: PGP signature
_______________________________________________ Password-Store mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/password-store
