Commit 69761e0e authored by Andrejs Cunskis's avatar Andrejs Cunskis Committed by Sanad Liaquat

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

E2E: Revert removal of initial password setup in tests, update implementation of handling expired password
parent 5ff51c71
...@@ -50,6 +50,8 @@ module QA ...@@ -50,6 +50,8 @@ module QA
return if Page::Main::Menu.perform(&:signed_in?) return if Page::Main::Menu.perform(&:signed_in?)
using_wait_time 0 do using_wait_time 0 do
set_initial_password_if_present
if Runtime::User.ldap_user? && user && user.username != Runtime::User.ldap_username 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 raise 'If an LDAP user is provided, it must be used for sign-in', QA::Resource::User::InvalidUserError
end end
...@@ -60,7 +62,7 @@ module QA ...@@ -60,7 +62,7 @@ module QA
sign_in_using_gitlab_credentials(user: user || Runtime::User, skip_page_validation: skip_page_validation) sign_in_using_gitlab_credentials(user: user || Runtime::User, skip_page_validation: skip_page_validation)
end end
set_initial_password_if_present set_up_new_password_if_required(user: user, skip_page_validation: skip_page_validation)
end end
end end
...@@ -71,6 +73,7 @@ module QA ...@@ -71,6 +73,7 @@ module QA
end end
using_wait_time 0 do using_wait_time 0 do
set_initial_password_if_present
sign_in_using_gitlab_credentials(user: admin) sign_in_using_gitlab_credentials(user: admin)
end end
...@@ -81,6 +84,8 @@ module QA ...@@ -81,6 +84,8 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in) Page::Main::Menu.perform(&:sign_out_if_signed_in)
using_wait_time 0 do using_wait_time 0 do
set_initial_password_if_present
switch_to_ldap_tab switch_to_ldap_tab
fill_element :username_field, user.ldap_username fill_element :username_field, user.ldap_username
...@@ -166,12 +171,26 @@ module QA ...@@ -166,12 +171,26 @@ module QA
Page::Main::Menu.validate_elements_present! unless skip_page_validation Page::Main::Menu.validate_elements_present! unless skip_page_validation
end 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') return unless has_content?('Set up new password')
Profile::Password.perform do |new_password_page| 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 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 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