From 99419824e12ccfa082967248df356e15f456e8cd Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Fri, 22 Mar 2019 12:33:29 +0100 Subject: 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. --- test/code.t | 11 +++++++++++ test/setup.sh | 5 +++++ 2 files changed, 16 insertions(+) (limited to 'test') 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 +} -- cgit v1.2.3