Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared examples two_factor_authenticatable failed when set otp_allowed_drift to 5 #197

Open
jsice opened this issue Aug 19, 2021 · 0 comments
Labels

Comments

@jsice
Copy link

jsice commented Aug 19, 2021

some tests might fail if the otp_allowed_drift is too low

it 'does not validate an OTP above the allowed drift' do
  otp = ROTP::TOTP.new(otp_secret).at(Time.now + subject.class.otp_allowed_drift * 2)
  expect(subject.validate_and_consume_otp!(otp)).to be false
end

it 'does not validate an OTP below the allowed drift' do
  otp = ROTP::TOTP.new(otp_secret).at(Time.now - subject.class.otp_allowed_drift * 2)
  expect(subject.validate_and_consume_otp!(otp)).to be false
end

An OTP is valid for INTERVAL + otp_allowed_drift * 2 seconds but these test cases didn't include the interval so if otp_allowed_drift is less than the interval, the tests may possibly fail

@bsedat bsedat added the bug label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants