summaryrefslogtreecommitdiff
path: root/spec/views/admin/sessions/new.html.haml_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /spec/views/admin/sessions/new.html.haml_spec.rb
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
downloadgitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/views/admin/sessions/new.html.haml_spec.rb')
-rw-r--r--spec/views/admin/sessions/new.html.haml_spec.rb59
1 files changed, 55 insertions, 4 deletions
diff --git a/spec/views/admin/sessions/new.html.haml_spec.rb b/spec/views/admin/sessions/new.html.haml_spec.rb
index 05601e5471e..b52ad0f9505 100644
--- a/spec/views/admin/sessions/new.html.haml_spec.rb
+++ b/spec/views/admin/sessions/new.html.haml_spec.rb
@@ -6,20 +6,26 @@ describe 'admin/sessions/new.html.haml' do
let(:user) { create(:admin) }
before do
+ disable_all_signin_methods
+
allow(view).to receive(:current_user).and_return(user)
- allow(view).to receive(:omniauth_enabled?).and_return(false)
end
context 'internal admin user' do
+ before do
+ allow(view).to receive(:allow_admin_mode_password_authentication_for_web?).and_return(true)
+ end
+
it 'shows enter password form' do
render
+ expect(rendered).to have_selector('[data-qa-selector="sign_in_tab"]')
expect(rendered).to have_css('#login-pane.active')
- expect(rendered).to have_selector('input[name="user[password]"]')
+ expect(rendered).to have_selector('[data-qa-selector="password_field"]')
end
it 'warns authentication not possible if password not set' do
- allow(user).to receive(:require_password_creation_for_web?).and_return(true)
+ allow(view).to receive(:allow_admin_mode_password_authentication_for_web?).and_return(false)
render
@@ -39,8 +45,53 @@ describe 'admin/sessions/new.html.haml' do
expect(rendered).to have_css('.omniauth-container')
expect(rendered).to have_content _('Sign in with')
-
expect(rendered).not_to have_content _('No authentication methods configured.')
end
end
+
+ context 'ldap authentication' do
+ let(:user) { create(:omniauth_user, :admin, extern_uid: 'my-uid', provider: 'ldapmain') }
+ let(:server) { { provider_name: 'ldapmain', label: 'LDAP' }.with_indifferent_access }
+
+ before do
+ enable_ldap
+ end
+
+ it 'is shown when enabled' do
+ render
+
+ expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]')
+ expect(rendered).to have_css('.login-box#ldapmain')
+ expect(rendered).to have_field('LDAP Username')
+ expect(rendered).not_to have_content('No authentication methods configured')
+ end
+
+ it 'is not shown when LDAP sign in is disabled' do
+ disable_ldap_sign_in
+
+ render
+
+ expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]')
+ expect(rendered).not_to have_field('LDAP Username')
+ expect(rendered).to have_content('No authentication methods configured')
+ end
+
+ def enable_ldap
+ allow(view).to receive(:ldap_servers).and_return([server])
+ allow(view).to receive(:form_based_providers).and_return([:ldapmain])
+ allow(view).to receive(:omniauth_callback_path).with(:user, 'ldapmain').and_return('/ldapmain')
+ allow(view).to receive(:ldap_sign_in_enabled?).and_return(true)
+ end
+
+ def disable_ldap_sign_in
+ allow(view).to receive(:ldap_sign_in_enabled?).and_return(false)
+ allow(view).to receive(:ldap_servers).and_return([])
+ end
+ end
+
+ def disable_all_signin_methods
+ allow(view).to receive(:password_authentication_enabled_for_web?).and_return(false)
+ allow(view).to receive(:omniauth_enabled?).and_return(false)
+ allow(view).to receive(:ldap_sign_in_enabled?).and_return(false)
+ end
end