summaryrefslogtreecommitdiff
path: root/qa/qa/tools/initialize_gitlab_auth.rb
blob: 3ead8fc9bd480161787de562a26bc171d6efeef0 (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
29
30
# frozen_string_literal: true

require_relative '../../qa'

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)

        puts "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