summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-05-28 13:15:53 +0000
committerGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-05-28 13:15:53 +0000
commit701914e1d9f6e5f56533c277fccdfc110d047a77 (patch)
tree6e9445064bc7a46ba4a37696f03872f3946f9c1b /spec
parenta6f2df2c8a70e154e655011572f59720dc80960c (diff)
parent4ace8900e9112115c1fb9d562d4f6c7392e34225 (diff)
downloadgitlab-ce-701914e1d9f6e5f56533c277fccdfc110d047a77.tar.gz
Merge branch 'security-jej/prevent-web-sign-in-bypass-11-10' into '11-10-stable'
Prevent password sign in restriction bypass See merge request gitlab/gitlabhq!3120
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/sessions_controller_spec.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index ea7242c1aa8..661c6d79597 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -56,7 +56,26 @@ describe SessionsController do
it 'authenticates user correctly' do
post(:create, params: { user: user_params })
- expect(subject.current_user). to eq user
+ 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
@@ -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
#