diff options
author | Tad Fisher <tad@simple.com> | 2017-03-19 16:49:01 -0700 |
---|---|---|
committer | Tad Fisher <tad@simple.com> | 2017-03-19 16:49:01 -0700 |
commit | d29b61248c87ab29283eb4ccbd037869f0b4df28 (patch) | |
tree | 16ae74a74b8d3bd850b39847ea820dcbeb4b0f24 /test | |
parent | 3aeea0b8ab9c7bbbfdf403fe5e0908a1160ef08b (diff) | |
download | pass-otp-d29b61248c87ab29283eb4ccbd037869f0b4df28.tar.gz pass-otp-d29b61248c87ab29283eb4ccbd037869f0b4df28.zip |
cmd_otp_uri: Show first line starting with otpauth:// in passfile
Diffstat (limited to 'test')
-rwxr-xr-x | test/uri.t | 24 | ||||
-rwxr-xr-x | test/validate.t | 27 |
2 files changed, 37 insertions, 14 deletions
@@ -4,24 +4,20 @@ 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 'Shows key URI in single-line passfile' ' + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example" -test_expect_success 'Fails for bogus URL' ' - test_must_fail "$PASS" otp validate https://www.google.com/ + test_pass_init && + "$PASS" otp insert "$uri" passfile && + [[ $("$PASS" otp uri passfile) == "$uri" ]] ' -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 'Shows key URI in multi-line passfile' ' + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example" -test_expect_success 'Fails for missing counter' ' - test_must_fail "$PASS" otp validate otpauth://hotp?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ + test_pass_init && + "$PASS" insert -m passfile < <(echo -e "password\nfoo\n$uri\nbar") && + [[ $("$PASS" otp uri passfile) == "$uri" ]] ' test_done diff --git a/test/validate.t b/test/validate.t new file mode 100755 index 0000000..9fbe66c --- /dev/null +++ b/test/validate.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 |