aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Kletzander <mkletzan@redhat.com>2019-03-22 12:33:29 +0100
committerTad Fisher <129148+tadfisher@users.noreply.github.com>2020-09-12 12:49:24 -0700
commit99419824e12ccfa082967248df356e15f456e8cd (patch)
tree495bac8387cb43ecdc1828aff502ea2f46432663 /test
parent3b11688682435847b49ef6310eb11eab32acd8b9 (diff)
Add support for quiet output of otp code command
When using this option the output of `pass otp -q ...` is predictable and can be further used without parsing even when the password store is a repository as well. This is useful, for example, when using rofi-pass. The patch is written in a way that other commands can optionally use the quiet option for otp_insert as well.
Diffstat (limited to 'test')
-rwxr-xr-xtest/code.t11
-rw-r--r--test/setup.sh5
2 files changed, 16 insertions, 0 deletions
diff --git a/test/code.t b/test/code.t
index 39310fb..19b4754 100755
--- a/test/code.t
+++ b/test/code.t
@@ -30,6 +30,17 @@ test_expect_success 'Generates HOTP code and increments counter' '
[[ $("$PASS" otp uri passfile) == "$inc" ]]
'
+test_expect_success 'Generates HOTP code quietly' '
+ uri="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example"
+ inc="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=11&issuer=Example"
+
+ test_pass_git_init &&
+ "$PASS" otp insert passfile <<< "$uri" &&
+ code=$("$PASS" otp -q passfile) &&
+ [[ ${#code} -eq 6 ]] &&
+ [[ $("$PASS" otp uri passfile) == "$inc" ]]
+'
+
test_expect_success 'HOTP counter increments and preserves multiline contents' '
uri="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example"
inc="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=11&issuer=Example"
diff --git a/test/setup.sh b/test/setup.sh
index 5fd7173..4029530 100644
--- a/test/setup.sh
+++ b/test/setup.sh
@@ -72,3 +72,8 @@ test_pass_init() {
rm -rf "$PASSWORD_STORE_DIR"
"$PASS" init "${KEY[@]}"
}
+
+test_pass_git_init() {
+ rm -rf "$PASSWORD_STORE_DIR"
+ "$PASS" init "${KEY[@]}" && "$PASS" git init
+}