summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-02-29 13:56:40 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-02-29 13:56:40 -0500
commit3334c3fc7026497fc9da258824795c0ce23a8ffd (patch)
tree319a10073764e84cd0fc7855c7ff26b872a41776 /spec
parent333ad73e765d87fa1ccbd4a361f7f172c790f897 (diff)
downloadgitlab-ce-3334c3fc7026497fc9da258824795c0ce23a8ffd.tar.gz
Reset `otp_grace_period_started_at` after disabling 2FA
Prior, if the user enabled 2FA, then disabled it and came back some time after the grace period expired, they would be forced to enable 2FA immediately.
Diffstat (limited to 'spec')
-rw-r--r--spec/factories.rb1
-rw-r--r--spec/models/user_spec.rb2
2 files changed, 3 insertions, 0 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index 264e3ed2c8d..cd57661c1cd 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -32,6 +32,7 @@ FactoryGirl.define do
before(:create) do |user|
user.two_factor_enabled = true
user.otp_secret = User.generate_otp_secret(32)
+ user.otp_grace_period_started_at = Time.now
user.generate_otp_backup_codes!
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 88821dd0dad..7ad7aab2eec 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -268,6 +268,7 @@ describe User, models: true do
expect(user).to be_two_factor_enabled
expect(user.encrypted_otp_secret).not_to be_nil
expect(user.otp_backup_codes).not_to be_nil
+ expect(user.otp_grace_period_started_at).not_to be_nil
user.disable_two_factor!
@@ -276,6 +277,7 @@ describe User, models: true do
expect(user.encrypted_otp_secret_iv).to be_nil
expect(user.encrypted_otp_secret_salt).to be_nil
expect(user.otp_backup_codes).to be_nil
+ expect(user.otp_grace_period_started_at).to be_nil
end
end