diff options
Diffstat (limited to 'qa/qa/runtime/api/client.rb')
-rw-r--r-- | qa/qa/runtime/api/client.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb index 02015e23ad8..0545b500e4c 100644 --- a/qa/qa/runtime/api/client.rb +++ b/qa/qa/runtime/api/client.rb @@ -6,33 +6,34 @@ module QA class Client attr_reader :address - def initialize(address = :gitlab, personal_access_token: nil) + def initialize(address = :gitlab, personal_access_token: nil, is_new_session: true) @address = address @personal_access_token = personal_access_token + @is_new_session = is_new_session end def personal_access_token - @personal_access_token ||= get_personal_access_token - end - - def get_personal_access_token - # you can set the environment variable PERSONAL_ACCESS_TOKEN - # to use a specific access token rather than create one from the UI - if Runtime::Env.personal_access_token - Runtime::Env.personal_access_token - else - create_personal_access_token + @personal_access_token ||= begin + # you can set the environment variable PERSONAL_ACCESS_TOKEN + # to use a specific access token rather than create one from the UI + Runtime::Env.personal_access_token ||= create_personal_access_token end end private def create_personal_access_token - Runtime::Browser.visit(@address, Page::Main::Login) do - Page::Main::Login.act { sign_in_using_credentials } - Factory::Resource::PersonalAccessToken.fabricate!.access_token + if @is_new_session + Runtime::Browser.visit(@address, Page::Main::Login) { do_create_personal_access_token } + else + do_create_personal_access_token end end + + def do_create_personal_access_token + Page::Main::Login.act { sign_in_using_credentials } + Factory::Resource::PersonalAccessToken.fabricate!.access_token + end end end end |