Commit aeb7ca22 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'acunskis-revert-initial-password-remove' into 'master'

E2E: Revert removal of initial password setup in tests, update implementation of handling expired password

See merge request gitlab-org/gitlab!60469
parents 2d8961cc 69761e0e
......@@ -50,6 +50,8 @@ module QA
return if Page::Main::Menu.perform(&:signed_in?)
using_wait_time 0 do
set_initial_password_if_present
if Runtime::User.ldap_user? && user && user.username != Runtime::User.ldap_username
raise 'If an LDAP user is provided, it must be used for sign-in', QA::Resource::User::InvalidUserError
end
......@@ -60,7 +62,7 @@ module QA
sign_in_using_gitlab_credentials(user: user || Runtime::User, skip_page_validation: skip_page_validation)
end
set_initial_password_if_present
set_up_new_password_if_required(user: user, skip_page_validation: skip_page_validation)
end
end
......@@ -71,6 +73,7 @@ module QA
end
using_wait_time 0 do
set_initial_password_if_present
sign_in_using_gitlab_credentials(user: admin)
end
......@@ -81,6 +84,8 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in)
using_wait_time 0 do
set_initial_password_if_present
switch_to_ldap_tab
fill_element :username_field, user.ldap_username
......@@ -166,12 +171,26 @@ module QA
Page::Main::Menu.validate_elements_present! unless skip_page_validation
end
def set_initial_password_if_present
# Handle request for password change
# Happens on clean GDK installations when seeded root admin password is expired
#
def set_up_new_password_if_required(user:, skip_page_validation:)
return unless has_content?('Set up new password')
Profile::Password.perform do |new_password_page|
new_password_page.set_new_password(Runtime::User.password, Runtime::User.password)
password = user&.password || Runtime::User.password
new_password_page.set_new_password(password, password)
end
sign_in_using_credentials(user: user, skip_page_validation: skip_page_validation)
end
def set_initial_password_if_present
return unless has_content?('Change your password')
fill_element :password_field, Runtime::User.password
fill_element :password_confirmation_field, Runtime::User.password
click_element :change_password_button
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