Commit d8d066de authored by Ian Baum's avatar Ian Baum Committed by Andrejs Cunskis

Match address of host when checking whether to login

* Makes sure we are on the login page of the desired host before
  deciding whether we need to re-login. Currently only checks if we're
  on the login page. For Geo specs, we need to sign into different hosts

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73492
EE: true
parent f3e83a99
......@@ -6,8 +6,6 @@ module QA
module_function
def while_signed_in(as: nil, address: :gitlab, admin: false)
Page::Main::Menu.perform(&:sign_out_if_signed_in)
sign_in(as: as, address: address, admin: admin)
result = yield
......@@ -23,9 +21,10 @@ module QA
end
def sign_in(as: nil, address: :gitlab, skip_page_validation: false, admin: false)
Page::Main::Login.perform { |p| p.redirect_to_login_page(address) }
unless Page::Main::Login.perform(&:on_login_page?)
Page::Main::Menu.perform(&:sign_out) if Page::Main::Menu.perform(&:signed_in?)
Runtime::Browser.visit(address, Page::Main::Login)
end
Page::Main::Login.perform do |login|
......
......@@ -386,6 +386,10 @@ module QA
end
end
def current_host
URI(page.current_url).host
end
def self.path
raise NotImplementedError
end
......
......@@ -156,6 +156,11 @@ module QA
sign_in_using_credentials(user: user)
end
def redirect_to_login_page(address)
desired_host = URI(Runtime::Scenario.send("#{address}_address")).host
Runtime::Browser.visit(address, Page::Main::Login) if desired_host != current_host
end
private
def sign_in_using_gitlab_credentials(user:, skip_page_validation: false)
......
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