summaryrefslogtreecommitdiff
path: root/qa/qa/tools/initialize_gitlab_auth.rb
blob: 18e90f0d739f2bb63a9ca68a5b4b479af693a881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module QA
  module Tools
    # Task to set default password from Runtime::Env.default_password if not set already
    # Also creates a personal access token
    # @example
    #   $ bundle exec rake  'initialize_gitlab_auth[http://gitlab.test]'
    class InitializeGitLabAuth
      attr_reader :address

      def initialize(address:)
        @address = address
      end

      def run
        Runtime::Scenario.define(:gitlab_address, address)

        QA::Runtime::Logger.info("Signing in and creating the default password for the root user if it's not set already...")
        QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login)
        Flow::Login.sign_in

        puts "Creating an API scoped access token for the root user..."
        puts "Token: #{Resource::PersonalAccessToken.fabricate!.token}"
      end
    end
  end
end