From 694d10db8fb714d1dc69ec50c0298833a7922088 Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 00:24:43 -0500 Subject: Add `make debug` target to log errors for failed tests to console. --- test/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 45882e7..deb6033 100644 --- a/test/Makefile +++ b/test/Makefile @@ -29,6 +29,9 @@ T = $(sort $(wildcard *.t)) all: $(DEFAULT_TEST_TARGET) +debug: pre-clean + TEST_OPTS="-v" $(MAKE) aggregate-results-and-cleanup + test: pre-clean $(MAKE) aggregate-results-and-cleanup -- cgit v1.2.3 From 20232a9ecd5f4909f0965b3abc1f80a70671076e Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 10:38:41 -0500 Subject: Check that testing prerequisites are installed --- test/setup.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/setup.sh b/test/setup.sh index f407164..2ec49d3 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -41,17 +41,21 @@ export GIT_WORK_TREE="$PASSWORD_STORE_DIR" git config --global user.email "Pass-Automated-Testing-Suite@zx2c4.com" git config --global user.name "Pass Automated Testing Suite" -PASS=`which pass` -if [[ ! -e $PASS ]]; then - echo "Could not find pass command" - exit 1 -fi +PASS=$(which pass) +[[ -e $PASS ]] || error "Could not find pass command" + +EXPECT=$(which expect) +[[ -e $EXPECT ]] || error "Could not find expect command" + +OAUTHTOOL=$(which oathtool) +[[ -e $OAUTHTOOL ]] || error "Could not find oathtool command" + +GPG=$(which gpg2) || GPG=$(which gpg) +[[ -e $GPG ]] || error "Could not find gpg command" # Note: the assumption is the test key is unencrypted. export GNUPGHOME="$TEST_HOME/gnupg/" chmod 700 "$GNUPGHOME" -GPG="gpg" -which gpg2 &>/dev/null && GPG="gpg2" # We don't want any currently running agent to conflict. unset GPG_AGENT_INFO -- cgit v1.2.3 From 8c37628a5d50e1a01fd7c97ba0aa80a39c972638 Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 11:09:52 -0500 Subject: Enable `make lint` for test/setup.sh --- Makefile | 1 + test/Makefile | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/Makefile b/Makefile index a9c1c55..402dc39 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ uninstall: lint: shellcheck -s bash $(PROG).bash + $(MAKE) -C test lint test: $(MAKE) -C test diff --git a/test/Makefile b/test/Makefile index deb6033..027feca 100644 --- a/test/Makefile +++ b/test/Makefile @@ -61,5 +61,8 @@ aggregate-results: echo "$$f"; \ done | '$(SHELL_PATH_SQ)' '$(AGGREGATE_SCRIPT)' -.PHONY: all test prove $(T) pre-clean clean +lint: + shellcheck -s bash setup.sh + +.PHONY: all test prove $(T) pre-clean clean lint .PHONY: aggregate-results-and-cleanup aggregate-results -- cgit v1.2.3 From f44934582124502b6609ddf145f183c8f18d3238 Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 12:24:35 -0500 Subject: Modified setup.sh to pass lint --- test/setup.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/setup.sh b/test/setup.sh index 2ec49d3..5fd7173 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -27,8 +27,9 @@ unset EDITOR # We must be called from test/ TEST_HOME="$(pwd)" -EXT_HOME="$(dirname $TEST_HOME)" +EXT_HOME="$(dirname "$TEST_HOME")" +# shellcheck disable=SC1091 . ./sharness.sh export PASSWORD_STORE_ENABLE_EXTENSIONS=true @@ -60,14 +61,14 @@ chmod 700 "$GNUPGHOME" # We don't want any currently running agent to conflict. unset GPG_AGENT_INFO -KEY1="CF90C77B" # pass test key 1 -KEY2="D774A374" # pass test key 2 -KEY3="EB7D54A8" # pass test key 3 -KEY4="E4691410" # pass test key 4 -KEY5="39E5020C" # pass test key 5 +KEY[1]="CF90C77B" # pass test key 1 +KEY[2]="D774A374" # pass test key 2 +KEY[3]="EB7D54A8" # pass test key 3 +KEY[4]="E4691410" # pass test key 4 +KEY[5]="39E5020C" # pass test key 5 # Test helpers test_pass_init() { rm -rf "$PASSWORD_STORE_DIR" - "$PASS" init "$KEY1" + "$PASS" init "${KEY[@]}" } -- cgit v1.2.3 From 6f5f35fd167177e3e18639593d540207c74992c1 Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 14:33:29 -0500 Subject: Fixed aggregate-results target to run indently of aggregate-results-and-clean --- test/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 027feca..5cc4e57 100644 --- a/test/Makefile +++ b/test/Makefile @@ -52,11 +52,11 @@ clean: clean-except-prove-cache $(RM) .prove $(RM) gnupg/random_seed -aggregate-results-and-cleanup: $(T) +aggregate-results-and-cleanup: $(MAKE) aggregate-results $(MAKE) clean -aggregate-results: +aggregate-results: $(T) for f in test-results/*.counts; do \ echo "$$f"; \ done | '$(SHELL_PATH_SQ)' '$(AGGREGATE_SCRIPT)' -- cgit v1.2.3 From 778400313da4533a5fb9e5940df79249ebcbe140 Mon Sep 17 00:00:00 2001 From: Lucid One Date: Wed, 7 Mar 2018 14:37:27 -0500 Subject: Marked debug target as .PHONY --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 5cc4e57..16da562 100644 --- a/test/Makefile +++ b/test/Makefile @@ -64,5 +64,5 @@ aggregate-results: $(T) lint: shellcheck -s bash setup.sh -.PHONY: all test prove $(T) pre-clean clean lint +.PHONY: all debug test prove $(T) pre-clean clean lint .PHONY: aggregate-results-and-cleanup aggregate-results -- cgit v1.2.3 From cb461eb752766c34cec422110239fbae4e1765fd Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Thu, 28 Jun 2018 15:27:34 -0700 Subject: Tolerate base64 padding in secret --- otp.bash | 2 +- test/insert.t | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/otp.bash b/otp.bash index 2668d9a..55dbcb3 100755 --- a/otp.bash +++ b/otp.bash @@ -63,7 +63,7 @@ otp_parse_uri() { local params local IFS=\&; read -r -a params < <(echo "$p") ; unset IFS - pattern='^(.+)=(.+)$' + pattern='^([^=]+)=(.+)$' for param in "${params[@]}"; do if [[ "$param" =~ $pattern ]]; then case ${BASH_REMATCH[1]} in diff --git a/test/insert.t b/test/insert.t index 1c8ddb2..a8c6458 100755 --- a/test/insert.t +++ b/test/insert.t @@ -130,4 +130,13 @@ test_expect_success 'Insert from secret without passfile' ' echo [[ $("$PASS" show Example/alice@google.com) == "$uri" ]] ' +test_expect_success 'Tolerates padding in secret' ' + secret="JBSWY3DPEHPK3PXP==" + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example" + + test_pass_init && + "$PASS" otp insert -s -i Example -a alice@google.com <<< "$secret" && + echo [[ $("$PASS" show Example/alice@google.com) == "$uri" ]] +' + test_done -- cgit v1.2.3