Sha256: 75dd728ab5b910c65c3ef44c7bd91c4f98e04115fd4154596d065b37d3b708ab
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require "test_helper" class OtpTest < MiniTest::Unit::TestCase def setup @user = User.new @user.email = 'roberto@heapsource.com' @user.run_callbacks :create @visitor = Visitor.new @visitor.email = 'roberto@heapsource.com' @visitor.run_callbacks :create end def test_authenticate_with_otp code = @user.otp_code assert @user.authenticate_otp(code) code = @visitor.otp_code assert @visitor.authenticate_otp(code) end def test_authenticate_with_otp_when_drift_is_allowed code = @user.otp_code(Time.now - 30) assert @user.authenticate_otp(code, drift: 60) code = @visitor.otp_code(Time.now - 30) assert @visitor.authenticate_otp(code, drift: 60) end def test_otp_code assert_match(/\d{5,6}/, @user.otp_code.to_s) assert_match(/\d{5,6}/, @visitor.otp_code.to_s) end def test_provisioning_uri_with_provided_account assert_match %r{otpauth://totp/roberto\?secret=\w{16}}, @user.provisioning_uri("roberto") assert_match %r{otpauth://totp/roberto\?secret=\w{16}}, @visitor.provisioning_uri("roberto") end def test_provisioning_uri_with_email_field assert_match %r{otpauth://totp/roberto@heapsource\.com\?secret=\w{16}}, @user.provisioning_uri assert_match %r{otpauth://totp/roberto@heapsource\.com\?secret=\w{16}}, @visitor.provisioning_uri end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_model_otp-0.1.0 | test/one_time_password_test.rb |
active_model_otp-0.0.2 | test/one_time_password_test.rb |