Commit 5ab23438 authored by Mark Lapierre's avatar Mark Lapierre

Add rake task to set password and an access token

This sets the default password from Runtime::User.default_password
if it's not set already, and it creates a personal access token.

This is useful when testing on a fresh GitLab instance (e.g., an
omnibus-gitlab docker image)
parent d9cacdc2
......@@ -2,6 +2,7 @@ require_relative 'qa/tools/revoke_all_personal_access_tokens'
require_relative 'qa/tools/delete_subgroups'
require_relative 'qa/tools/generate_perf_testdata'
require_relative 'qa/tools/delete_test_ssh_keys'
require_relative 'qa/tools/initialize_gitlab_auth'
desc "Revokes all personal access tokens"
task :revoke_personal_access_tokens do
......@@ -13,6 +14,11 @@ task :delete_subgroups do
QA::Tools::DeleteSubgroups.new.run
end
desc "Initialize GitLab with an access token"
task :initialize_gitlab_auth, [:address] do |t, args|
QA::Tools::InitializeGitLabAuth.new(args).run
end
desc "Generate Performance Testdata"
task :generate_perf_testdata, :type do |t, args|
args.with_defaults(type: :all)
......
# 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!.access_token}"
end
end
end
end
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