diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-12-25 15:16:33 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-12-25 15:16:33 +0300 |
commit | 7dedd997b910f65ee3c494d906fbc2392962c114 (patch) | |
tree | 4ff6c88677c75cd366d58c9bd1f2d11f0739bfd5 /spec/features | |
parent | ef8b1dbf21a90f719c2e8b8c052e16f6107193c6 (diff) | |
parent | ed777c7bcc990e5e3ff9f8e0d28a1e23af44d8f1 (diff) |
Merge branch 'master' into milestone-ref
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/login_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index 922c76285d1..2451e56fe7c 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -98,4 +98,56 @@ feature 'Login', feature: true do expect(page).to have_content('Invalid login or password.') end end + + describe 'with required two-factor authentication enabled' do + let(:user) { create(:user) } + before(:each) { stub_application_setting(require_two_factor_authentication: true) } + + context 'with grace period defined' do + before(:each) do + stub_application_setting(two_factor_grace_period: 48) + login_with(user) + end + + context 'within the grace period' do + it 'redirects to two-factor configuration page' do + expect(current_path).to eq new_profile_two_factor_auth_path + expect(page).to have_content('You must configure Two-Factor Authentication in your account until') + end + + it 'two-factor configuration is skippable' do + expect(current_path).to eq new_profile_two_factor_auth_path + + click_link 'Configure it later' + expect(current_path).to eq root_path + end + end + + context 'after the grace period' do + let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) } + + it 'redirects to two-factor configuration page' do + expect(current_path).to eq new_profile_two_factor_auth_path + expect(page).to have_content('You must configure Two-Factor Authentication in your account.') + end + + it 'two-factor configuration is not skippable' do + expect(current_path).to eq new_profile_two_factor_auth_path + expect(page).not_to have_link('Configure it later') + end + end + end + + context 'without grace pariod defined' do + before(:each) do + stub_application_setting(two_factor_grace_period: 0) + login_with(user) + end + + it 'redirects to two-factor configuration page' do + expect(current_path).to eq new_profile_two_factor_auth_path + expect(page).to have_content('You must configure Two-Factor Authentication in your account.') + end + end + end end |