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 @@
= 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_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
module Admin
autoload :Menu, 'qa/page/admin/menu'
autoload :NewSession, 'qa/page/admin/new_session'
module Settings
autoload :Repository, 'qa/page/admin/settings/repository'
......
......@@ -10,7 +10,7 @@ module QA
def fabricate!
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)
EE::Page::Admin::Geo::Nodes::Show.perform(&:new_node!)
......
......@@ -6,7 +6,7 @@ module QA
class License < QA::Resource::Base
def fabricate!(license)
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)
EE::Page::Admin::License.perform do |page| # rubocop:disable QA/AmbiguousPageObjectName
......
......@@ -16,7 +16,7 @@ module QA
end
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::EE::Page::Admin::Settings::Integration.perform do |integration|
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
has_no_css?(element_selector_css(name, kwargs), wait: wait, text: text)
end
def has_text?(text)
page.has_text? text
def has_text?(text, wait: Capybara.default_max_wait_time)
page.has_text?(text, wait: wait)
end
def has_no_text?(text)
......
......@@ -60,8 +60,15 @@ module QA
end
end
def click_admin_area
within_top_menu { click_element :admin_area_link }
def go_to_admin_area
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
def signed_in?
......@@ -125,6 +132,10 @@ module QA
end
end
end
def click_admin_area
within_top_menu { click_element :admin_area_link }
end
end
end
end
......
......@@ -8,7 +8,7 @@ module QA
raise ArgumentError unless traits.include?(:enabled)
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::Settings::Repository.perform do |setting|
......
......@@ -32,7 +32,7 @@ module QA
Runtime::Browser.visit(@address, Page::Main::Login)
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::Settings::Network.perform do |setting|
......
......@@ -6,7 +6,7 @@ module QA
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
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::Settings::MetricsAndProfiling.perform do |setting|
......
......@@ -267,7 +267,7 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in)
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::Overview::Users::Index.perform do |index|
index.search_user(name)
......
......@@ -7,7 +7,7 @@ module QA
it 'logs audit events for UI operations' do
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)
EE::Page::Admin::Monitoring::AuditLog.perform do |audit_log_page|
expected_events.each do |expected_event|
......@@ -96,7 +96,7 @@ module QA
before do
sign_in
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::Overview::Users::Index.perform do |index|
index.search_user(user.username)
......
......@@ -71,7 +71,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
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)
EE::Page::Admin::Settings::Templates.perform do |templates|
......
......@@ -7,7 +7,7 @@ module QA
describe 'Custom email', :requires_admin do
before do
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)
end
......
......@@ -133,7 +133,7 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
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::Settings::Network.perform do |network|
......
......@@ -111,10 +111,10 @@ module QA
found
end
def has_text?(text)
def has_text?(text, **kwargs)
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
end
......
......@@ -117,7 +117,7 @@ describe QA::Support::Page::Logging do
allow(page).to receive(:has_text?).and_return(true)
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
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