From 3ba564ca9f2c5d894a9ef7ef6b827d95e21d2104 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Sat, 12 Feb 2022 19:15:05 -0800 Subject: Handle otpauth:// URIs with port numbers --- test/code.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/code.t') diff --git a/test/code.t b/test/code.t index 19b4754..1752d77 100755 --- a/test/code.t +++ b/test/code.t @@ -65,4 +65,24 @@ EOF [[ $("$PASS" show passfile) == "$expected" ]] ' +test_expect_success 'Generates TOTP code for URI with port number' ' + uri="otpauth://totp/Example:alice@domain.com: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:alice@google.com:443?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example" + inc="otpauth://hotp/Example:alice@google.com: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 -- cgit v1.2.3