diff options
Diffstat (limited to 'spec/features/users/login_spec.rb')
-rw-r--r-- | spec/features/users/login_spec.rb | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb index 853c381fe6b..0761c1871d3 100644 --- a/spec/features/users/login_spec.rb +++ b/spec/features/users/login_spec.rb @@ -26,7 +26,6 @@ RSpec.describe 'Login' do user.reload expect(user.reset_password_token).not_to be_nil - find('a[href="#login-pane"]').click gitlab_sign_in(user) expect(current_path).to eq root_path @@ -593,42 +592,95 @@ RSpec.describe 'Login' do describe 'UI tabs and panes' do context 'when no defaults are changed' do - it 'correctly renders tabs and panes' do - ensure_tab_pane_correctness + it 'does not render any tabs' do + visit new_user_session_path + + ensure_no_tabs + end + + it 'renders link to sign up path' do + visit new_user_session_path + + expect(page.body).to have_link('Register now', href: new_user_registration_path) end end context 'when signup is disabled' do before do stub_application_setting(signup_enabled: false) + + visit new_user_session_path end - it 'correctly renders tabs and panes' do - ensure_tab_pane_correctness + it 'does not render any tabs' do + ensure_no_tabs + end + + it 'does not render link to sign up path' do + visit new_user_session_path + + expect(page.body).not_to have_link('Register now', href: new_user_registration_path) end end context 'when ldap is enabled' do + include LdapHelpers + + let(:provider) { 'ldapmain' } + let(:ldap_server_config) do + { + 'label' => 'Main LDAP', + 'provider_name' => provider, + 'attributes' => {}, + 'encryption' => 'plain', + 'uid' => 'uid', + 'base' => 'dc=example,dc=com' + } + end + before do + stub_ldap_setting(enabled: true) + allow(::Gitlab::Auth::Ldap::Config).to receive_messages(enabled: true, servers: [ldap_server_config]) + allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [provider.to_sym]) + + Ldap::OmniauthCallbacksController.define_providers! + Rails.application.reload_routes! + + allow_next_instance_of(ActionDispatch::Routing::RoutesProxy) do |instance| + allow(instance).to receive(:"user_#{provider}_omniauth_callback_path") + .and_return("/users/auth/#{provider}/callback") + end + visit new_user_session_path - allow(page).to receive(:form_based_providers).and_return([:ldapmain]) - allow(page).to receive(:ldap_enabled).and_return(true) end it 'correctly renders tabs and panes' do - ensure_tab_pane_correctness(false) + ensure_tab_pane_correctness(['Main LDAP', 'Standard']) + end + + it 'renders link to sign up path' do + expect(page.body).to have_link('Register now', href: new_user_registration_path) end end context 'when crowd is enabled' do before do + allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [:crowd]) + stub_application_setting(crowd_enabled: true) + + Ldap::OmniauthCallbacksController.define_providers! + Rails.application.reload_routes! + + allow_next_instance_of(ActionDispatch::Routing::RoutesProxy) do |instance| + allow(instance).to receive(:user_crowd_omniauth_authorize_path) + .and_return("/users/auth/crowd/callback") + end + visit new_user_session_path - allow(page).to receive(:form_based_providers).and_return([:crowd]) - allow(page).to receive(:crowd_enabled?).and_return(true) end it 'correctly renders tabs and panes' do - ensure_tab_pane_correctness(false) + ensure_tab_pane_correctness(%w(Crowd Standard)) end end end |