Sha256: ee3bab926dd567329df25987004e8bea4f3f3faa8f8cae8c70308355ecd09d4e
Contents?: true
Size: 1.4 KB
Versions: 6
Compression:
Stored size: 1.4 KB
Contents
require "test/unit" require "otp" class TestURI < Test::Unit::TestCase def test_totp secret = OTP::Base32.encode("12345678901234567890") totp = OTP::TOTP.new totp.secret = secret totp.algorithm = "SHA256" totp.digits = 8 totp.period = 60 totp.issuer = "My Company" totp.accountname = "account@example.com" uri = totp.to_uri otp = OTP::URI.parse(uri) assert_equal(OTP::TOTP, otp.class) assert_equal(secret, otp.secret) assert_equal("SHA256", otp.algorithm) assert_equal(8, otp.digits) assert_equal(60, otp.period) assert_equal("account@example.com", otp.accountname) assert_equal("My Company", otp.issuer) totp.time = otp.time = Time.now assert_equal(otp.password, totp.password) end def test_hotp secret = OTP::Base32.encode("12345678901234567890") hotp = OTP::HOTP.new hotp.secret = secret hotp.algorithm = "SHA256" hotp.digits = 8 hotp.count = 1234 hotp.issuer = "My Company" hotp.accountname = "account@example.com" uri = hotp.to_uri otp = OTP::URI.parse(uri) assert_equal(OTP::HOTP, otp.class) assert_equal(secret, otp.secret) assert_equal("SHA256", otp.algorithm) 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 end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
otp-0.0.8 | test/test_uri.rb |
otp-0.0.7 | test/test_uri.rb |
otp-0.0.6 | test/test_uri.rb |
otp-0.0.5 | test/test_uri.rb |
otp-0.0.4 | test/test_uri.rb |
otp-0.0.3 | test/test_uri.rb |