test/test_uri.rb in otp-0.0.10 vs test/test_uri.rb in otp-0.0.11
- old
+ new
@@ -15,10 +15,15 @@
uri = "otpauth://totp/My%20Company:%20%20account@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
otp = OTP::URI.parse(uri)
assert_equal("account@example.com", otp.accountname)
assert_equal("My Company", otp.issuer)
+ uri = "otpauth://totp/My%20Company%3A%20%20account@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
+ otp = OTP::URI.parse(uri)
+ assert_equal("account@example.com", otp.accountname)
+ assert_equal("My Company", otp.issuer)
+
uri = "otpauth://totp/My%20Company:%20%20account@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Foo"
otp = OTP::URI.parse(uri)
assert_equal("account@example.com", otp.accountname)
assert_equal("My Company", otp.issuer)
end
@@ -109,9 +114,19 @@
assert_equal(8, otp.digits)
assert_equal(1234, otp.count)
assert_equal("account@example.com", otp.accountname)
assert_equal("My Company", otp.issuer)
assert_equal(otp.password, hotp.password)
+ end
+
+ def test_format_invalid
+ totp = OTP::TOTP.new
+ e = assert_raise(RuntimeError){ totp.to_uri }
+ assert_match(/secret must be set/, e.message)
+
+ totp.new_secret
+ e = assert_raise(RuntimeError){ totp.to_uri }
+ assert_match(/accountname must be set/, e.message)
end
def test_parse_invalid
e = assert_raise(RuntimeError){ OTP::URI.parse("http://www.netlab.jp") }
assert_match(/URI scheme not match/, e.message)