diff options
author | Gabriel Mazetto <gabriel@gitlab.com> | 2015-12-24 02:04:41 -0200 |
---|---|---|
committer | Gabriel Mazetto <gabriel@gitlab.com> | 2015-12-24 19:01:30 -0200 |
commit | b61a5bc20cbfcd8a2c914f19e8786a989bf69198 (patch) | |
tree | 782acf1b8e437a2f6f88935ceeddf88b5d03c447 /spec/features | |
parent | 31fb2b7702345fbf597c2cb17466567776433a56 (diff) | |
download | gitlab-ce-b61a5bc20cbfcd8a2c914f19e8786a989bf69198.tar.gz |
specs for forced two-factor authentication and grace period
simplified code and fixed stuffs
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 |