Sha256: 35137a4b97344a1c9d209292df1debc33373d5af1855e3c5f65cfe09b5fb30f4

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

require "test/unit"
require "otp"

class TestHTOP < Test::Unit::TestCase
  def assert_hotp(hotp, count, pass)
    hotp.count = count
    assert_equal(pass, hotp.password)
    assert(hotp.verify(pass))
    assert(!hotp.verify(pass.chop))
  end

  def test_hotp
    seed = "12345678901234567890"
    hotp = OTP::HOTP.new(OTP::Base32.encode(seed), "SHA1", 6)
    assert_hotp(hotp, 0, "755224")
    assert_hotp(hotp, 1, "287082")
    assert_hotp(hotp, 2, "359152")
    assert_hotp(hotp, 3, "969429")
    assert_hotp(hotp, 4, "338314")
    assert_hotp(hotp, 5, "254676")
    assert_hotp(hotp, 6, "287922")
    assert_hotp(hotp, 7, "162583")
    assert_hotp(hotp, 8, "399871")
    assert_hotp(hotp, 9, "520489")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
otp-0.0.4 test/test_hotp.rb
otp-0.0.3 test/test_hotp.rb