Commit 7732db22 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'qa-allow-gitlab-qa-pat-env-var' into 'master'

Allow personal access token env var from gitlab-qa

See merge request gitlab-org/gitlab-ce!24048
parents d762302e 35c55576
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
def personal_access_token def personal_access_token
@personal_access_token ||= begin @personal_access_token ||= begin
# you can set the environment variable PERSONAL_ACCESS_TOKEN # you can set the environment variable GITLAB_QA_ACCESS_TOKEN
# to use a specific access token rather than create one from the UI # to use a specific access token rather than create one from the UI
Runtime::Env.personal_access_token ||= create_personal_access_token Runtime::Env.personal_access_token ||= create_personal_access_token
end end
......
...@@ -53,7 +53,7 @@ module QA ...@@ -53,7 +53,7 @@ module QA
# specifies token that can be used for the api # specifies token that can be used for the api
def personal_access_token def personal_access_token
@personal_access_token ||= ENV['PERSONAL_ACCESS_TOKEN'] @personal_access_token ||= ENV['GITLAB_QA_ACCESS_TOKEN']
end end
def remote_grid def remote_grid
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require_relative '../../qa' require_relative '../../qa'
# This script deletes all subgroups of a group specified by ENV['GROUP_NAME_OR_PATH'] # This script deletes all subgroups of a group specified by ENV['GROUP_NAME_OR_PATH']
# Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS # Required environment variables: GITLAB_QA_ACCESS_TOKEN and GITLAB_ADDRESS
# Optional environment variable: GROUP_NAME_OR_PATH (defaults to 'gitlab-qa-sandbox-group') # Optional environment variable: GROUP_NAME_OR_PATH (defaults to 'gitlab-qa-sandbox-group')
# Run `rake delete_subgroups` # Run `rake delete_subgroups`
...@@ -14,9 +14,9 @@ module QA ...@@ -14,9 +14,9 @@ module QA
def initialize def initialize
raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS'] raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS']
raise ArgumentError, "Please provide PERSONAL_ACCESS_TOKEN" unless ENV['PERSONAL_ACCESS_TOKEN'] raise ArgumentError, "Please provide GITLAB_QA_ACCESS_TOKEN" unless ENV['GITLAB_QA_ACCESS_TOKEN']
@api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN']) @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['GITLAB_QA_ACCESS_TOKEN'])
end end
def run def run
......
...@@ -5,7 +5,7 @@ require 'faker' ...@@ -5,7 +5,7 @@ require 'faker'
require 'yaml' require 'yaml'
require_relative '../../qa' require_relative '../../qa'
# This script generates testdata for Performance Testing. # This script generates testdata for Performance Testing.
# Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS # Required environment variables: GITLAB_QA_ACCESS_TOKEN and GITLAB_ADDRESS
# This job creates a urls.txt which contains a hash of all the URLs needed for Performance Testing # This job creates a urls.txt which contains a hash of all the URLs needed for Performance Testing
# Run `rake generate_perf_testdata` # Run `rake generate_perf_testdata`
...@@ -16,9 +16,9 @@ module QA ...@@ -16,9 +16,9 @@ module QA
def initialize def initialize
raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS'] raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS']
raise ArgumentError, "Please provide PERSONAL_ACCESS_TOKEN" unless ENV['PERSONAL_ACCESS_TOKEN'] raise ArgumentError, "Please provide GITLAB_QA_ACCESS_TOKEN" unless ENV['GITLAB_QA_ACCESS_TOKEN']
@api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN']) @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['GITLAB_QA_ACCESS_TOKEN'])
@group_name = "gitlab-qa-perf-sandbox-#{SecureRandom.hex(8)}" @group_name = "gitlab-qa-perf-sandbox-#{SecureRandom.hex(8)}"
@project_name = "my-test-project-#{SecureRandom.hex(8)}" @project_name = "my-test-project-#{SecureRandom.hex(8)}"
@visibility = "public" @visibility = "public"
......
...@@ -90,13 +90,13 @@ describe QA::Runtime::Env do ...@@ -90,13 +90,13 @@ describe QA::Runtime::Env do
described_class.instance_variable_set(:@personal_access_token, nil) described_class.instance_variable_set(:@personal_access_token, nil)
end end
context 'when PERSONAL_ACCESS_TOKEN is set' do context 'when GITLAB_QA_ACCESS_TOKEN is set' do
before do before do
stub_env('PERSONAL_ACCESS_TOKEN', 'a_token') stub_env('GITLAB_QA_ACCESS_TOKEN', 'a_token_too')
end end
it 'returns specified token from env' do it 'returns specified token from env' do
expect(described_class.personal_access_token).to eq 'a_token' expect(described_class.personal_access_token).to eq 'a_token_too'
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