test/test_base.rb in otp-0.0.10 vs test/test_base.rb in otp-0.0.11
- old
+ new
@@ -22,12 +22,12 @@
otp.secret = ""
assert_equal("", otp.secret)
assert_equal("", otp.raw_secret)
- otp.secret = "MZXW6YTBOI======"
- assert_equal("MZXW6YTBOI======", otp.secret)
+ otp.secret = "MZXW6YTBOI"
+ assert_equal("MZXW6YTBOI", otp.secret)
assert_equal("foobar", otp.raw_secret)
otp.secret = "MZXW6YTBOI"
assert_equal("MZXW6YTBOI", otp.secret)
assert_equal("foobar", otp.raw_secret)
@@ -43,11 +43,22 @@
otp.raw_secret = ""
assert_equal("", otp.secret)
assert_equal("", otp.raw_secret)
otp.raw_secret = "foobarbaz"
- assert_equal("MZXW6YTBOJRGC6Q=", otp.secret)
+ assert_equal("MZXW6YTBOJRGC6Q", otp.secret)
assert_equal("foobarbaz", otp.raw_secret)
+ end
+
+ def test_verify
+ otp = OTP::Base.new
+ e = assert_raise(ArgumentError){ otp.verify("0", last:-1) }
+ assert_match(/last must be greater than or equal to 0/, e.message)
+ e = assert_raise(ArgumentError){ otp.verify("0", post:-1) }
+ assert_match(/post must be greater than or equal to 0/, e.message)
+ assert_equal(false, otp.verify(nil))
+ assert_equal(false, otp.verify(""))
+ assert_raise(NotImplementedError){ otp.verify("0") }
end
def test_moving_factor
base = OTP::Base.new
hotp = OTP::HOTP.new