| ... | @@ -22,8 +22,8 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -22,8 +22,8 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
with_omniauth_full_host { example.run }
|
|
with_omniauth_full_host { example.run }
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def login_with_provider(provider, enter_two_factor: false)
|
|
def login_with_provider(provider, enter_two_factor: false, additional_info: {})
|
|
|
login_via(provider.to_s, user, uid, remember_me: remember_me)
|
|
login_via(provider.to_s, user, uid, remember_me: remember_me, additional_info: additional_info)
|
|
|
enter_code(user.current_otp) if enter_two_factor
|
|
enter_code(user.current_otp) if enter_two_factor
|
|
|
end
|
|
end
|
|
|
|
|
|
| ... | @@ -33,6 +33,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -33,6 +33,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
let(:remember_me) { false }
|
|
let(:remember_me) { false }
|
|
|
let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider.to_s) }
|
|
let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider.to_s) }
|
|
|
let(:two_factor_user) { create(:omniauth_user, :two_factor, extern_uid: uid, provider: provider.to_s) }
|
|
let(:two_factor_user) { create(:omniauth_user, :two_factor, extern_uid: uid, provider: provider.to_s) }
|
|
|
|
provider == :salesforce ? let(:additional_info) { { extra: { email_verified: true } } } : let(:additional_info) { {} }
|
|
|
|
|
|
|
|
before do
|
|
before do
|
|
|
stub_omniauth_config(provider)
|
|
stub_omniauth_config(provider)
|
| ... | @@ -41,7 +42,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -41,7 +42,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
|
|
|
|
|
context 'when two-factor authentication is disabled' do
|
|
context 'when two-factor authentication is disabled' do
|
|
|
it 'logs the user in' do
|
|
it 'logs the user in' do
|
|
|
login_with_provider(provider)
|
|
login_with_provider(provider, additional_info: additional_info)
|
|
|
|
|
|
|
|
expect(current_path).to eq root_path
|
|
expect(current_path).to eq root_path
|
|
|
end
|
|
end
|
| ... | @@ -51,20 +52,20 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -51,20 +52,20 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
let(:user) { two_factor_user }
|
|
let(:user) { two_factor_user }
|
|
|
|
|
|
|
|
it 'logs the user in' do
|
|
it 'logs the user in' do
|
|
|
login_with_provider(provider, enter_two_factor: true)
|
|
login_with_provider(provider, additional_info: additional_info, enter_two_factor: true)
|
|
|
|
|
|
|
|
expect(current_path).to eq root_path
|
|
expect(current_path).to eq root_path
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'when bypass-two-factor is enabled' do
|
|
it 'when bypass-two-factor is enabled' do
|
|
|
allow(Gitlab.config.omniauth).to receive_messages(allow_bypass_two_factor: true)
|
|
allow(Gitlab.config.omniauth).to receive_messages(allow_bypass_two_factor: true)
|
|
|
login_via(provider.to_s, user, uid, remember_me: false)
|
|
login_via(provider.to_s, user, uid, remember_me: false, additional_info: additional_info)
|
|
|
expect(current_path).to eq root_path
|
|
expect(current_path).to eq root_path
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'when bypass-two-factor is disabled' do
|
|
it 'when bypass-two-factor is disabled' do
|
|
|
allow(Gitlab.config.omniauth).to receive_messages(allow_bypass_two_factor: false)
|
|
allow(Gitlab.config.omniauth).to receive_messages(allow_bypass_two_factor: false)
|
|
|
login_with_provider(provider, enter_two_factor: true)
|
|
login_with_provider(provider, enter_two_factor: true, additional_info: additional_info)
|
|
|
expect(current_path).to eq root_path
|
|
expect(current_path).to eq root_path
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
| ... | @@ -74,7 +75,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -74,7 +75,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
|
|
|
|
|
context 'when two-factor authentication is disabled' do
|
|
context 'when two-factor authentication is disabled' do
|
|
|
it 'remembers the user after a browser restart' do
|
|
it 'remembers the user after a browser restart' do
|
|
|
login_with_provider(provider)
|
|
login_with_provider(provider, additional_info: additional_info)
|
|
|
|
|
|
|
|
clear_browser_session
|
|
clear_browser_session
|
|
|
|
|
|
| ... | @@ -87,7 +88,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -87,7 +88,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
let(:user) { two_factor_user }
|
|
let(:user) { two_factor_user }
|
|
|
|
|
|
|
|
it 'remembers the user after a browser restart' do
|
|
it 'remembers the user after a browser restart' do
|
|
|
login_with_provider(provider, enter_two_factor: true)
|
|
login_with_provider(provider, enter_two_factor: true, additional_info: additional_info)
|
|
|
|
|
|
|
|
clear_browser_session
|
|
clear_browser_session
|
|
|
|
|
|
| ... | @@ -100,7 +101,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -100,7 +101,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
context 'when "remember me" is not checked' do
|
|
context 'when "remember me" is not checked' do
|
|
|
context 'when two-factor authentication is disabled' do
|
|
context 'when two-factor authentication is disabled' do
|
|
|
it 'does not remember the user after a browser restart' do
|
|
it 'does not remember the user after a browser restart' do
|
|
|
login_with_provider(provider)
|
|
login_with_provider(provider, additional_info: additional_info)
|
|
|
|
|
|
|
|
clear_browser_session
|
|
clear_browser_session
|
|
|
|
|
|
| ... | @@ -113,7 +114,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
... | @@ -113,7 +114,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do |
|
|
let(:user) { two_factor_user }
|
|
let(:user) { two_factor_user }
|
|
|
|
|
|
|
|
it 'does not remember the user after a browser restart' do
|
|
it 'does not remember the user after a browser restart' do
|
|
|
login_with_provider(provider, enter_two_factor: true)
|
|
login_with_provider(provider, enter_two_factor: true, additional_info: additional_info)
|
|
|
|
|
|
|
|
clear_browser_session
|
|
clear_browser_session
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |