diff options
author | Tad Fisher <tadfisher@gmail.com> | 2017-03-20 10:01:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-20 10:01:26 -0700 |
commit | 310322fdeee57330e92afdf0810ac5200163d08d (patch) | |
tree | 262111fc810123e3b0123b5e19a0219a54b8639d /test/validate.t | |
parent | db2baf62a27d5a657d0477d928f21a739981dc46 (diff) | |
parent | d9c681a8fbb70d40e14079e5f1a8b4aaee0b0d08 (diff) |
Merge pull request #17 from tadfisher/key-uri
Handle OTP key URIs
Diffstat (limited to 'test/validate.t')
-rwxr-xr-x | test/validate.t | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/validate.t b/test/validate.t new file mode 100755 index 0000000..6d05fdf --- /dev/null +++ b/test/validate.t @@ -0,0 +1,31 @@ +#!/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 'Parses a basic HOTP URI' ' + "$PASS" otp validate "otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example" +' + +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 |