test/test_totp.rb in otp-0.0.8 vs test/test_totp.rb in otp-0.0.9

- old
+ new

@@ -1,7 +1,6 @@ -require "test/unit" -require "otp" +require_relative "helper" class TestTOTP < Test::Unit::TestCase def assert_totp(totp, time, pass) totp.time = time assert_equal(pass, totp.password) @@ -68,7 +67,14 @@ assert(totp.verify("71170909", last:2, post:2)) assert(totp.verify("50451956", last:2, post:2)) # current assert(totp.verify("36432053", last:2, post:2)) assert(totp.verify("78660635", last:2, post:2)) assert(!totp.verify("97845627", last:2, post:2)) + end + + def test_error + seed = "12345678901234567890" + totp = OTP::TOTP.new(OTP::Base32.encode(seed), "SHA1", 8) + assert_raise(ArgumentError){ assert(totp.verify("50451956", last:-2)) } + assert_raise(ArgumentError){ assert(totp.verify("50451956", post:-2)) } end end