aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTad Fisher <tadfisher@gmail.com>2018-06-28 15:51:29 -0700
committerTad Fisher <tadfisher@gmail.com>2018-06-28 15:51:29 -0700
commit7d7a9afc48562ac292e6847ebe834ed673e83ebd (patch)
tree94ceab018dfbe48cbf4f0de452e3766d94d32242 /test
parent9edb479405156f5712dd101661b86bd599904e8d (diff)
parent5fb4620b087a34c93b8f67874992dcc6409f7fcc (diff)
downloadpass-otp-7d7a9afc48562ac292e6847ebe834ed673e83ebd.tar.gz
pass-otp-7d7a9afc48562ac292e6847ebe834ed673e83ebd.zip
Merge branch 'develop' into master
Diffstat (limited to 'test')
-rw-r--r--test/Makefile12
-rwxr-xr-xtest/insert.t9
-rw-r--r--test/setup.sh33
3 files changed, 37 insertions, 17 deletions
diff --git a/test/Makefile b/test/Makefile
index 45882e7..16da562 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
@@ -49,14 +52,17 @@ 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)'
-.PHONY: all test prove $(T) pre-clean clean
+lint:
+ shellcheck -s bash setup.sh
+
+.PHONY: all debug test prove $(T) pre-clean clean lint
.PHONY: aggregate-results-and-cleanup aggregate-results
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
diff --git a/test/setup.sh b/test/setup.sh
index f407164..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
@@ -41,29 +42,33 @@ 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
-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[@]}"
}