aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/append.t11
-rwxr-xr-xtest/insert.t18
2 files changed, 29 insertions, 0 deletions
diff --git a/test/append.t b/test/append.t
index bba3c60..7f6d0af 100755
--- a/test/append.t
+++ b/test/append.t
@@ -14,6 +14,17 @@ test_expect_success 'Reads non-terminal input' '
[[ $("$PASS" otp uri passfile) == "$uri" ]]
'
+test_expect_success 'Read secret non-terminal input' '
+ existing="foo bar baz"
+ secret=JBSWY3DPEHPK3PXP
+ uri="otpauth://totp/Example:alice%40google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
+
+ test_pass_init &&
+ "$PASS" insert -e passfile <<< "$existing" &&
+ "$PASS" otp append -s -i Example -a alice@google.com -e passfile <<< "$secret" &&
+ [[ $("$PASS" otp uri passfile) == "$uri" ]]
+'
+
test_expect_success 'Reads terminal input in noecho mode' '
existing="foo bar baz"
uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
diff --git a/test/insert.t b/test/insert.t
index e0d2441..1c8ddb2 100755
--- a/test/insert.t
+++ b/test/insert.t
@@ -112,4 +112,22 @@ test_expect_success 'Force overwrites key URI' '
[[ $("$PASS" show passfile) == "$uri2" ]]
'
+test_expect_success 'Insert passfile from secret with options(issuer, accountname)' '
+ 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 passfile <<< "$secret" &&
+ echo [[ $("$PASS" show passfile) == "$uri" ]]
+'
+
+test_expect_success 'Insert from secret without passfile' '
+ 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