Commit 1ff7ee6c authored by Andrejs Cunskis's avatar Andrejs Cunskis Committed by Mike Greiling

Update set up new password handling in e2e tests

parent d1c676e2
...@@ -16,16 +16,16 @@ ...@@ -16,16 +16,16 @@
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :current_password, _('Current password') = f.label :current_password, _('Current password')
.col-sm-10 .col-sm-10
= f.password_field :current_password, required: true, class: 'form-control gl-form-input' = f.password_field :current_password, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'current_password_field' }
.form-group.row .form-group.row
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :password, _('New password') = f.label :password, _('New password')
.col-sm-10 .col-sm-10
= f.password_field :password, required: true, class: 'form-control gl-form-input' = f.password_field :password, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'new_password_field' }
.form-group.row .form-group.row
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :password_confirmation, _('Password confirmation') = f.label :password_confirmation, _('Password confirmation')
.col-sm-10 .col-sm-10
= f.password_field :password_confirmation, required: true, class: 'form-control gl-form-input' = f.password_field :password_confirmation, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'confirm_password_field' }
.form-actions .form-actions
= f.submit _('Set new password'), class: 'gl-button btn btn-confirm' = f.submit _('Set new password'), class: 'gl-button btn btn-confirm', data: { qa_selector: 'set_new_password_button' }
...@@ -50,15 +50,17 @@ module QA ...@@ -50,15 +50,17 @@ 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
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 if Runtime::User.ldap_user? && user && user.username != Runtime::User.ldap_username end
if Runtime::User.ldap_user? if Runtime::User.ldap_user?
sign_in_using_ldap_credentials(user: user || Runtime::User) sign_in_using_ldap_credentials(user: user || Runtime::User)
else else
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
end end
end end
...@@ -69,8 +71,6 @@ module QA ...@@ -69,8 +71,6 @@ 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,8 +81,6 @@ module QA ...@@ -81,8 +81,6 @@ 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
...@@ -169,11 +167,11 @@ module QA ...@@ -169,11 +167,11 @@ module QA
end end
def set_initial_password_if_present def set_initial_password_if_present
return unless has_content?('Change your password') return unless has_content?('Set up new password')
fill_element :password_field, Runtime::User.password Profile::Password.perform do |new_password_page|
fill_element :password_confirmation_field, Runtime::User.password new_password_page.set_new_password(Runtime::User.password, Runtime::User.password)
click_element :change_password_button end
end end
end end
end end
......
...@@ -11,12 +11,26 @@ module QA ...@@ -11,12 +11,26 @@ module QA
element :save_password_button element :save_password_button
end end
view 'app/views/profiles/passwords/new.html.haml' do
element :current_password_field
element :new_password_field
element :confirm_password_field
element :set_new_password_button
end
def update_password(new_password, current_password) def update_password(new_password, current_password)
find_element(:current_password_field).set current_password find_element(:current_password_field).set current_password
find_element(:new_password_field).set new_password find_element(:new_password_field).set new_password
find_element(:confirm_password_field).set new_password find_element(:confirm_password_field).set new_password
click_element(:save_password_button) click_element(:save_password_button)
end end
def set_new_password(new_password, current_password)
fill_element :current_password_field, current_password
fill_element :new_password_field, new_password
fill_element :confirm_password_field, new_password
click_element :set_new_password_button
end
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