aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTad Fisher <tadfisher@gmail.com>2018-03-04 11:26:13 -0800
committerGitHub <noreply@github.com>2018-03-04 11:26:13 -0800
commitf88e6a338cd976bfa4e14567c1f3024ddc58ab7d (patch)
tree4549da42122c877121c38b2956abf5fbd479c554 /test
parent0737f1f3e8ad8e31b7b5d7eb9b6a6a21eb3781e9 (diff)
parent948c2f04cbaf2f065b0c21b80de82f1f0c946e54 (diff)
downloadpass-otp-f88e6a338cd976bfa4e14567c1f3024ddc58ab7d.tar.gz
pass-otp-f88e6a338cd976bfa4e14567c1f3024ddc58ab7d.zip
Merge pull request #56 from tadfisher/develop
Merge branch 'develop' into master
Diffstat (limited to 'test')
-rw-r--r--test/Makefile1
-rwxr-xr-xtest/append.t11
-rwxr-xr-xtest/code.t10
-rwxr-xr-xtest/insert.t18
4 files changed, 38 insertions, 2 deletions
diff --git a/test/Makefile b/test/Makefile
index 39f1df2..45882e7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -47,6 +47,7 @@ clean-except-prove-cache:
clean: clean-except-prove-cache
$(RM) .prove
+ $(RM) gnupg/random_seed
aggregate-results-and-cleanup: $(T)
$(MAKE) aggregate-results
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/code.t b/test/code.t
index 02bd086..39310fb 100755
--- a/test/code.t
+++ b/test/code.t
@@ -4,6 +4,12 @@ export test_description='Tests pass otp code generation'
. ./setup.sh
+test_expect_success 'Fails for missing secret' '
+ test_pass_init &&
+ "$PASS" insert passfile <<< "12345"
+ test_expect_code 1 pass otp passfile
+'
+
test_expect_success 'Generates TOTP code' '
uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
@@ -31,14 +37,14 @@ test_expect_success 'HOTP counter increments and preserves multiline contents' '
read -r -d "" existing <<EOF
foo bar baz
zab rab oof
-$uri1
+$uri
baz bar foo
EOF
read -r -d "" expected <<EOF
foo bar baz
zab rab oof
-$uri2
+$inc
baz bar foo
EOF
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