Commit 633c7125 authored by Mark Lapierre's avatar Mark Lapierre

Allow registration when LDAP is enabled

Update the login page object and related code so that a user can be
registered when LDAP is enabled
parent 732538c4
......@@ -10,4 +10,4 @@
= link_to 'Standard', '#login-pane', class: 'nav-link qa-standard-tab', 'data-toggle' => 'tab'
- if allow_signup?
%li.nav-item
= link_to 'Register', '#register-pane', class: 'nav-link', 'data-toggle' => 'tab'
= link_to 'Register', '#register-pane', class: 'nav-link qa-register-tab', 'data-toggle' => 'tab'
......@@ -37,7 +37,10 @@ module QA
product(:password) { |factory| factory.password }
def fabricate!
# Don't try to log-out if we're not logged-in
if Page::Menu::Main.act { has_personal_area?(wait: 0) }
Page::Menu::Main.perform { |main| main.sign_out }
end
if credentials_given?
Page::Main::Login.perform do |login|
......
......@@ -76,6 +76,10 @@ module QA
find_element(name).set(content)
end
def has_element?(name)
has_css?(element_selector_css(name))
end
def within_element(name)
page.within(element_selector_css(name)) do
yield
......
......@@ -23,6 +23,7 @@ module QA
view 'app/views/devise/shared/_tabs_ldap.html.haml' do
element :ldap_tab
element :standard_tab
element :register_tab
end
view 'app/views/devise/shared/_tabs_normal.html.haml' do
......@@ -35,7 +36,7 @@ module QA
# we need to wait for the instance to start. That said, in some cases
# we are already logged-in so we check both cases here.
wait(max: 500) do
page.has_css?('.login-page') ||
has_css?('.login-page') ||
Page::Menu::Main.act { has_personal_area?(wait: 0) }
end
end
......@@ -78,12 +79,28 @@ module QA
'/users/sign_in'
end
def has_sign_in_tab?
has_element?(:sign_in_tab)
end
def has_ldap_tab?
has_element?(:ldap_tab)
end
def has_standard_tab?
has_element?(:standard_tab)
end
def sign_in_tab?
page.has_button?('Sign in')
has_css?(".active", text: 'Sign in')
end
def ldap_tab?
page.has_link?('LDAP')
has_css?(".active", text: 'LDAP')
end
def standard_tab?
has_css?(".active", text: 'Standard')
end
def switch_to_sign_in_tab
......@@ -113,8 +130,8 @@ module QA
end
def sign_in_using_gitlab_credentials(user)
switch_to_sign_in_tab unless sign_in_tab?
switch_to_standard_tab if ldap_tab?
switch_to_sign_in_tab if has_sign_in_tab?
switch_to_standard_tab if has_standard_tab?
fill_element :login_field, user.username
fill_element :password_field, user.password
......@@ -122,7 +139,7 @@ module QA
end
def set_initial_password_if_present
return unless page.has_content?('Change your password')
return unless has_content?('Change your password')
fill_element :password_field, Runtime::User.password
fill_element :password_confirmation, Runtime::User.password
......
# frozen_string_literal: true
module QA
shared_examples 'registration and login' do
it 'user registers and logs in' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Factory::Resource::User.fabricate!
# TODO, since `Signed in successfully` message was removed
# this is the only way to tell if user is signed in correctly.
#
Page::Menu::Main.perform do |menu|
expect(menu).to have_personal_area
end
end
end
context :manage do
describe 'standard' do
it_behaves_like 'registration and login'
end
end
context :manage, :orchestrated, :ldap do
describe 'while LDAP is enabled' do
it_behaves_like 'registration and login'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment