Commit 25df3e13 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'qa-shl-fix-admin-reauth-required' into 'master'

Re-authenticate as admin if required

Closes #36107

See merge request gitlab-org/gitlab!20285
parents d88ec344 8a42ab0e
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
= password_field_tag :password, nil, class: 'form-control', required: true, title: _('This field is required.'), data: { qa_selector: 'password_field' } = password_field_tag :password, nil, class: 'form-control', required: true, title: _('This field is required.'), data: { qa_selector: 'password_field' }
.submit-container.move-submit-down .submit-container.move-submit-down
= submit_tag _('Enter Admin Mode'), class: 'btn btn-success', data: { qa_selector: 'sign_in_button' } = submit_tag _('Enter Admin Mode'), class: 'btn btn-success', data: { qa_selector: 'enter_admin_mode_button' }
...@@ -331,6 +331,7 @@ module QA ...@@ -331,6 +331,7 @@ module QA
module Admin module Admin
autoload :Menu, 'qa/page/admin/menu' autoload :Menu, 'qa/page/admin/menu'
autoload :NewSession, 'qa/page/admin/new_session'
module Settings module Settings
autoload :Repository, 'qa/page/admin/settings/repository' autoload :Repository, 'qa/page/admin/settings/repository'
......
...@@ -10,7 +10,7 @@ module QA ...@@ -10,7 +10,7 @@ module QA
def fabricate! def fabricate!
QA::Page::Main::Login.perform(&:sign_in_using_credentials) QA::Page::Main::Login.perform(&:sign_in_using_credentials)
QA::Page::Main::Menu.perform(&:click_admin_area) QA::Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:click_geo_menu_link) QA::Page::Admin::Menu.perform(&:click_geo_menu_link)
EE::Page::Admin::Geo::Nodes::Show.perform(&:new_node!) EE::Page::Admin::Geo::Nodes::Show.perform(&:new_node!)
......
...@@ -6,7 +6,7 @@ module QA ...@@ -6,7 +6,7 @@ module QA
class License < QA::Resource::Base class License < QA::Resource::Base
def fabricate!(license) def fabricate!(license)
QA::Page::Main::Login.perform(&:sign_in_using_admin_credentials) QA::Page::Main::Login.perform(&:sign_in_using_admin_credentials)
QA::Page::Main::Menu.perform(&:click_admin_area) QA::Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:click_license_menu_link) QA::Page::Admin::Menu.perform(&:click_license_menu_link)
EE::Page::Admin::License.perform do |page| # rubocop:disable QA/AmbiguousPageObjectName EE::Page::Admin::License.perform do |page| # rubocop:disable QA/AmbiguousPageObjectName
......
...@@ -16,7 +16,7 @@ module QA ...@@ -16,7 +16,7 @@ module QA
end end
def fabricate! def fabricate!
QA::Page::Main::Menu.perform(&:click_admin_area) QA::Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_integration_settings) QA::Page::Admin::Menu.perform(&:go_to_integration_settings)
QA::EE::Page::Admin::Settings::Integration.perform do |integration| QA::EE::Page::Admin::Settings::Integration.perform do |integration|
integration.expand_elasticsearch do |es| integration.expand_elasticsearch do |es|
......
# frozen_string_literal: true
module QA
module Page
module Admin
class NewSession < Page::Base
view 'app/views/admin/sessions/_new_base.html.haml' do
element :enter_admin_mode_button
element :password_field
end
def set_password(password)
fill_element :password_field, password
end
def click_enter_admin_mode
click_element :enter_admin_mode_button
end
end
end
end
end
...@@ -133,8 +133,8 @@ module QA ...@@ -133,8 +133,8 @@ module QA
has_no_css?(element_selector_css(name, kwargs), wait: wait, text: text) has_no_css?(element_selector_css(name, kwargs), wait: wait, text: text)
end end
def has_text?(text) def has_text?(text, wait: Capybara.default_max_wait_time)
page.has_text? text page.has_text?(text, wait: wait)
end end
def has_no_text?(text) def has_no_text?(text)
......
...@@ -60,8 +60,15 @@ module QA ...@@ -60,8 +60,15 @@ module QA
end end
end end
def click_admin_area def go_to_admin_area
within_top_menu { click_element :admin_area_link } click_admin_area
if has_text?('Enter Admin Mode', wait: 1.0)
Admin::NewSession.perform do |new_session|
new_session.set_password(Runtime::User.admin_password)
new_session.click_enter_admin_mode
end
end
end end
def signed_in? def signed_in?
...@@ -125,6 +132,10 @@ module QA ...@@ -125,6 +132,10 @@ module QA
end end
end end
end end
def click_admin_area
within_top_menu { click_element :admin_area_link }
end
end end
end end
end end
......
...@@ -8,7 +8,7 @@ module QA ...@@ -8,7 +8,7 @@ module QA
raise ArgumentError unless traits.include?(:enabled) raise ArgumentError unless traits.include?(:enabled)
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_repository_settings) Page::Admin::Menu.perform(&:go_to_repository_settings)
Page::Admin::Settings::Repository.perform do |setting| Page::Admin::Settings::Repository.perform do |setting|
......
...@@ -32,7 +32,7 @@ module QA ...@@ -32,7 +32,7 @@ module QA
Runtime::Browser.visit(@address, Page::Main::Login) Runtime::Browser.visit(@address, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials) Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_network_settings) Page::Admin::Menu.perform(&:go_to_network_settings)
Page::Admin::Settings::Network.perform do |setting| Page::Admin::Settings::Network.perform do |setting|
......
...@@ -6,7 +6,7 @@ module QA ...@@ -6,7 +6,7 @@ module QA
before do before do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials) Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_metrics_and_profiling_settings) Page::Admin::Menu.perform(&:go_to_metrics_and_profiling_settings)
Page::Admin::Settings::MetricsAndProfiling.perform do |setting| Page::Admin::Settings::MetricsAndProfiling.perform do |setting|
......
...@@ -267,7 +267,7 @@ module QA ...@@ -267,7 +267,7 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in) Page::Main::Menu.perform(&:sign_out_if_signed_in)
Page::Main::Login.perform(&:sign_in_using_admin_credentials) Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_users_overview) Page::Admin::Menu.perform(&:go_to_users_overview)
Page::Admin::Overview::Users::Index.perform do |index| Page::Admin::Overview::Users::Index.perform do |index|
index.search_user(name) index.search_user(name)
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
it 'logs audit events for UI operations' do it 'logs audit events for UI operations' do
sign_in sign_in
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_monitoring_audit_logs) QA::Page::Admin::Menu.perform(&:go_to_monitoring_audit_logs)
EE::Page::Admin::Monitoring::AuditLog.perform do |audit_log_page| EE::Page::Admin::Monitoring::AuditLog.perform do |audit_log_page|
expected_events.each do |expected_event| expected_events.each do |expected_event|
...@@ -96,7 +96,7 @@ module QA ...@@ -96,7 +96,7 @@ module QA
before do before do
sign_in sign_in
user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_users_overview) Page::Admin::Menu.perform(&:go_to_users_overview)
Page::Admin::Overview::Users::Index.perform do |index| Page::Admin::Overview::Users::Index.perform do |index|
index.search_user(user.username) index.search_user(user.username)
......
...@@ -71,7 +71,7 @@ module QA ...@@ -71,7 +71,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials) Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_template_settings) Page::Admin::Menu.perform(&:go_to_template_settings)
EE::Page::Admin::Settings::Templates.perform do |templates| EE::Page::Admin::Settings::Templates.perform do |templates|
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
describe 'Custom email', :requires_admin do describe 'Custom email', :requires_admin do
before do before do
Flow::Login.sign_in_as_admin Flow::Login.sign_in_as_admin
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_preferences_settings) Page::Admin::Menu.perform(&:go_to_preferences_settings)
end end
......
...@@ -133,7 +133,7 @@ module QA ...@@ -133,7 +133,7 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in) Page::Main::Menu.perform(&:sign_out_if_signed_in)
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials) Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_network_settings) Page::Admin::Menu.perform(&:go_to_network_settings)
Page::Admin::Settings::Network.perform do |network| Page::Admin::Settings::Network.perform do |network|
......
...@@ -111,10 +111,10 @@ module QA ...@@ -111,10 +111,10 @@ module QA
found found
end end
def has_text?(text) def has_text?(text, **kwargs)
found = super found = super
log(%Q{has_text?('#{text}') returned #{found}}) log(%Q{has_text?('#{text}', wait: #{kwargs[:wait] || Capybara.default_max_wait_time}) returned #{found}})
found found
end end
......
...@@ -117,7 +117,7 @@ describe QA::Support::Page::Logging do ...@@ -117,7 +117,7 @@ describe QA::Support::Page::Logging do
allow(page).to receive(:has_text?).and_return(true) allow(page).to receive(:has_text?).and_return(true)
expect { subject.has_text? 'foo' } expect { subject.has_text? 'foo' }
.to output(/has_text\?\('foo'\) returned true/).to_stdout_from_any_process .to output(/has_text\?\('foo', wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned true/).to_stdout_from_any_process
end end
it 'logs has_no_text?' do it 'logs has_no_text?' do
......
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