| ... | ... | @@ -59,6 +59,25 @@ describe SessionsController do |
|
|
|
expect(subject.current_user).to eq user
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with password authentication disabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(password_authentication_enabled_for_web: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not sign in the user' do
|
|
|
|
post(:create, params: { user: user_params })
|
|
|
|
|
|
|
|
expect(@request.env['warden']).not_to be_authenticated
|
|
|
|
expect(subject.current_user).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns status 403' do
|
|
|
|
post(:create, params: { user: user_params })
|
|
|
|
|
|
|
|
expect(response.status).to eq 403
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates an audit log record' do
|
|
|
|
expect { post(:create, params: { user: user_params }) }.to change { SecurityEvent.count }.by(1)
|
|
|
|
expect(SecurityEvent.last.details[:with]).to eq('standard')
|
| ... | ... | @@ -151,6 +170,19 @@ describe SessionsController do |
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with password authentication disabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(password_authentication_enabled_for_web: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows 2FA stage of non-password login' do
|
|
|
|
authenticate_2fa(otp_attempt: user.current_otp)
|
|
|
|
|
|
|
|
expect(@request.env['warden']).to be_authenticated
|
|
|
|
expect(subject.current_user).to eq user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# See #14900 issue
|
|
|
|
#
|
| ... | ... | |
| ... | ... | |