-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle otpauth:// URIs with port numbers
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,24 @@ EOF | |
[[ $("$PASS" show passfile) == "$expected" ]] | ||
' | ||
|
||
test_expect_success 'Generates TOTP code for URI with port number' ' | ||
uri="otpauth://totp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&issuer=Example" | ||
test_pass_init && | ||
"$PASS" otp insert passfile <<< "$uri" && | ||
code=$("$PASS" otp passfile) && | ||
[[ ${#code} -eq 6 ]] | ||
' | ||
|
||
test_expect_success 'Generates HOTP code for URI with port number' ' | ||
uri="otpauth://hotp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example" | ||
inc="otpauth://hotp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&counter=11&issuer=Example" | ||
test_pass_init && | ||
"$PASS" otp insert passfile <<< "$uri" && | ||
code=$("$PASS" otp passfile) && | ||
[[ ${#code} -eq 6 ]] && | ||
[[ $("$PASS" otp uri passfile) == "$inc" ]] | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,4 +157,12 @@ test_expect_success 'Allow multiple levels in path prefix' ' | |
echo [[ $("$PASS" show totp/pass-test/Example/[email protected]) == "$uri" ]] | ||
' | ||
|
||
test_expect_success 'Insert TOTP URI with port number' ' | ||
uri="otpauth://totp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&issuer=Example" | ||
test_pass_init && | ||
"$PASS" otp insert passfile <<< "$uri" && | ||
[[ $("$PASS" show passfile) == "$uri" ]] | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ export test_description='Tests pass otp URI parsing' | |
. ./setup.sh | ||
|
||
test_expect_success 'Parses a basic TOTP URI' ' | ||
"$PASS" otp validate "otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example" | ||
"$PASS" otp validate "otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example" | ||
echo $otp_type | ||
' | ||
|
||
test_expect_success 'Parses a complex TOTP URI' ' | ||
|
@@ -28,4 +29,16 @@ test_expect_success 'Fails for missing counter' ' | |
test_must_fail "$PASS" otp validate otpauth://hotp?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ | ||
' | ||
|
||
test_expect_success 'Parses TOTP URI with port number' ' | ||
"$PASS" otp validate "otpauth://totp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&issuer=Example" | ||
' | ||
|
||
test_expect_success 'Parses a complex TOTP URI with port number' ' | ||
"$PASS" otp validate otpauth://totp/ACME%20Co:[email protected]:443?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30 | ||
' | ||
|
||
test_expect_success 'Parses a HOTP URI with port umber' ' | ||
"$PASS" otp validate "otpauth://hotp/Example:[email protected]:443?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example" | ||
' | ||
|
||
test_done |