Commit 21130cdf authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'qa-fix-url-mask' into 'master'

Mask url in logs in QA framework

See merge request gitlab-org/gitlab!35837
parents bb4747fc 5974808f
......@@ -83,13 +83,13 @@ module QA
end
def api_get_from(get_path)
url = Runtime::API::Request.new(api_client, get_path).url
response = get(url)
request = Runtime::API::Request.new(api_client, get_path)
response = get(request.url)
if response.code == HTTP_STATUS_SERVER_ERROR
raise InternalServerError, "Failed to GET #{url} - (#{response.code}): `#{response}`."
raise InternalServerError, "Failed to GET #{request.mask_url} - (#{response.code}): `#{response}`."
elsif response.code != HTTP_STATUS_OK
raise ResourceNotFoundError, "Resource at #{url} could not be found (#{response.code}): `#{response}`."
raise ResourceNotFoundError, "Resource at #{request.mask_url} could not be found (#{response.code}): `#{response}`."
end
response
......@@ -108,11 +108,11 @@ module QA
end
def api_delete
url = Runtime::API::Request.new(api_client, api_delete_path).url
response = delete(url)
request = Runtime::API::Request.new(api_client, api_delete_path)
response = delete(request.url)
unless [HTTP_STATUS_NO_CONTENT, HTTP_STATUS_ACCEPTED].include? response.code
raise ResourceNotDeletedError, "Resource at #{url} could not be deleted (#{response.code}): `#{response}`."
raise ResourceNotDeletedError, "Resource at #{request.mask_url} could not be deleted (#{response.code}): `#{response}`."
end
response
......
......@@ -22,6 +22,12 @@ describe QA::Runtime::API::Request do
end
end
describe '#mask_url' do
it 'returns the full API request url with the token masked' do
expect(request.mask_url).to eq 'http://example.com/api/v4/users?private_token=[****]'
end
end
describe '#request_path' do
it 'prepends the api path' do
expect(request.request_path('/users')).to eq '/api/v4/users'
......
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