aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTad Fisher <tad@simple.com>2017-03-18 15:37:07 -0700
committerTad Fisher <tad@simple.com>2017-03-18 15:44:12 -0700
commit01a95a45932f9a54c2c2fc3423824bdbac3918d8 (patch)
tree828ff13a10d9864c4568c2ebe4d3589818926c0b /test
parentdb2baf62a27d5a657d0477d928f21a739981dc46 (diff)
downloadpass-otp-01a95a45932f9a54c2c2fc3423824bdbac3918d8.tar.gz
pass-otp-01a95a45932f9a54c2c2fc3423824bdbac3918d8.zip
Parse key URIs
Diffstat (limited to 'test')
-rwxr-xr-xtest/uri.t27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/uri.t b/test/uri.t
new file mode 100755
index 0000000..9fbe66c
--- /dev/null
+++ b/test/uri.t
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+export test_description='Tests pass otp URI parsing'
+
+. ./setup.sh
+
+test_expect_success 'Parses a basic TOTP URI' '
+ "$PASS" otp validate "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
+'
+
+test_expect_success 'Parses a complex TOTP URI' '
+ "$PASS" otp validate otpauth://totp/ACME%20Co:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30
+'
+
+test_expect_success 'Fails for bogus URL' '
+ test_must_fail "$PASS" otp validate https://www.google.com/
+'
+
+test_expect_success 'Fails for missing secret' '
+ test_must_fail "$PASS" otp validate otpauth://totp/ACME%20Co:john.doe@email.com?issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30
+'
+
+test_expect_success 'Fails for missing counter' '
+ test_must_fail "$PASS" otp validate otpauth://hotp?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ
+'
+
+test_done