Skip to content
Snippets Groups Projects
Verified Commit f23d0827 authored by Jay McCure's avatar Jay McCure Committed by GitLab
Browse files

E2E test: remove airborne from non ee api tests

parent a824f481
No related branches found
No related tags found
2 merge requests!164749Enable parallel in test-on-omnibus,!163425E2E test: remove airborne from non ee api tests
# frozen_string_literal: true
require 'airborne'
module QA
RSpec.describe 'Plan' do
include Support::API
......@@ -39,7 +37,8 @@ def push_commit(commit_message, new_branch = true)
end
def issue_closed?
response = get Runtime::API::Request.new(api_client, "/projects/#{issue.project.id}/issues/#{issue_id}").url
response = Support::API.get(Runtime::API::Request.new(api_client,
"/projects/#{issue.project.id}/issues/#{issue_id}").url)
parse_body(response)[:state] == 'closed'
end
end
......
# frozen_string_literal: true
require 'airborne'
module QA
RSpec.describe 'Create' do
describe 'API basics', product_group: :source_code do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
include Support::API
describe 'API basics', product_group: :source_code do
let(:api_client) { Runtime::API::Client.new(:gitlab) }
let(:project_name) { "api-basics-#{SecureRandom.hex(8)}" }
let(:sanitized_project_path) { CGI.escape("#{Runtime::User.username}/#{project_name}") }
let(:file_name) { 'bã®' }
......@@ -16,34 +13,37 @@ module QA
let(:file_path) { CGI.escape("føo/#{file_name}/føo/#{file_name}") }
it 'user creates a project with a file and deletes them afterwards', :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347745' do
create_project_request = Runtime::API::Request.new(@api_client, '/projects')
post create_project_request.url, path: project_name, name: project_name
create_project_request = Runtime::API::Request.new(api_client, '/projects')
response = Support::API.post(create_project_request.url, path: project_name, name: project_name)
response_body = parse_body(response)
aggregate_failures do
expect_status(201)
expect(json_body).to match(
expect(response.code).to eq(Support::API::HTTP_STATUS_CREATED)
expect(response_body).to match(
a_hash_including(name: project_name, path: project_name)
)
end
default_branch = json_body[:default_branch].to_s.empty? ? Runtime::Env.default_branch : json_body[:default_branch]
default_branch = response_body[:default_branch].to_s.empty? ? Runtime::Env.default_branch : response_body[:default_branch]
create_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}")
post create_file_request.url, branch: default_branch, content: 'Hello world', commit_message: 'Add README.md'
create_file_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}")
response = Support::API.post(create_file_request.url, branch: default_branch, content: 'Hello world', commit_message: 'Add README.md')
response_body = parse_body(response)
aggregate_failures do
expect_status(201)
expect(json_body).to match(
expect(response.code).to eq(Support::API::HTTP_STATUS_CREATED)
expect(response_body).to match(
a_hash_including(branch: default_branch, file_path: CGI.unescape(file_path))
)
end
get_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}", ref: default_branch)
get get_file_request.url
get_file_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}", ref: default_branch)
response = Support::API.get(get_file_request.url)
response_body = parse_body(response)
aggregate_failures do
expect_status(200)
expect(json_body).to match(
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
expect(response_body).to match(
a_hash_including(
ref: default_branch,
file_path: CGI.unescape(file_path), file_name: file_name,
......@@ -52,25 +52,27 @@ module QA
)
end
delete_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}", branch: default_branch, commit_message: 'Remove README.md')
delete delete_file_request.url
delete_file_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/files/#{file_path}", branch: default_branch, commit_message: 'Remove README.md')
response = Support::API.delete(delete_file_request.url)
expect_status(204)
expect(response.code).to eq(Support::API::HTTP_STATUS_NO_CONTENT)
get_tree_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/tree")
get get_tree_request.url
get_tree_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/tree")
response = Support::API.get(get_tree_request.url)
response_body = parse_body(response)
aggregate_failures do
expect_status(200)
expect(json_body).to eq([])
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
expect(response_body).to eq([])
end
delete_project_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}")
delete delete_project_request.url
delete_project_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}")
response = Support::API.delete(delete_project_request.url)
response_body = parse_body(response)
aggregate_failures do
expect_status(202)
expect(json_body).to match(
expect(response.code).to eq(Support::API::HTTP_STATUS_ACCEPTED)
expect(response_body).to match(
a_hash_including(message: '202 Accepted')
)
end
......@@ -93,25 +95,26 @@ module QA
it 'sets no-cache headers as expected', :blocking,
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347746' do
create_project_request = Runtime::API::Request.new(@api_client, '/projects')
post create_project_request.url, path: project_name, name: project_name
create_project_request = Runtime::API::Request.new(api_client, '/projects')
response = Support::API.post(create_project_request.url, path: project_name, name: project_name)
response_body = parse_body(response)
default_branch = json_body[:default_branch].to_s.empty? ? Runtime::Env.default_branch : json_body[:default_branch]
default_branch = response_body[:default_branch].to_s.empty? ? Runtime::Env.default_branch : response_body[:default_branch]
create_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/test.svg")
post create_file_request.url, branch: default_branch, content: svg_file, commit_message: 'Add test.svg'
create_file_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/files/test.svg")
response = Support::API.post(create_file_request.url, branch: default_branch, content: svg_file, commit_message: 'Add test.svg')
get_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/test.svg/raw", ref: default_branch)
get_file_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}/repository/files/test.svg/raw", ref: default_branch)
3.times do
response = get get_file_request.url
response = Support::API.get(get_file_request.url)
# Subsequent responses aren't cached, so headers should match from
# request to request, especially a 200 response rather than a 304
# (indicating a cached response.) Further, :content_disposition
# should include `attachment` for all responses.
aggregate_failures do
expect_status(200)
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
expect(response.headers[:cache_control]).to include("no-store")
expect(response.headers[:cache_control]).to include("no-cache")
expect(response.headers[:expires]).to eq("Fri, 01 Jan 1990 00:00:00 GMT")
......@@ -121,12 +124,13 @@ module QA
end
end
delete_project_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}")
delete delete_project_request.url
delete_project_request = Runtime::API::Request.new(api_client, "/projects/#{sanitized_project_path}")
response = Support::API.delete(delete_project_request.url)
response_body = parse_body(response)
aggregate_failures do
expect_status(202)
expect(json_body).to match(
expect(response.code).to eq(Support::API::HTTP_STATUS_ACCEPTED)
expect(response_body).to match(
a_hash_including(message: '202 Accepted')
)
end
......
# frozen_string_literal: true
require 'airborne'
require 'digest'
module QA
......@@ -59,7 +58,7 @@ def create_project(user, api_client, project_name)
def download_project_archive_via_api(api_client, project, type = 'tar.gz')
get_project_archive_zip = Runtime::API::Request.new(api_client, project.api_get_archive_path(type))
project_archive_download = Support::API.get(get_project_archive_zip.url, raw_response: true)
expect(project_archive_download.code).to eq(200)
expect(project_archive_download.code).to eq(Support::API::HTTP_STATUS_OK)
project_archive_download.file
end
......
# frozen_string_literal: true
require 'airborne'
module QA
RSpec.describe 'Package', only: { subdomain: %i[staging staging-canary pre] },
product_group: :container_registry do
......
# frozen_string_literal: true
require 'airborne'
module QA
RSpec.describe 'Data Stores' do
include Support::API
describe 'Users API', :smoke, product_group: :tenant_scale do
let(:api_client) { Runtime::API::Client.new(:gitlab) }
let(:request) { Runtime::API::Request.new(api_client, '/users') }
it 'GET /users', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347882' do
get request.url
request = Runtime::API::Request.new(api_client, '/users')
response = Support::API.get(request.url)
expect_status(200)
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
end
it 'GET /users/:username with a valid username',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347886' do
get request.url, { params: { username: Runtime::User.username } }
request = Runtime::API::Request.new(api_client, '/users', username: Runtime::User.username)
response = Support::API.get(request.url)
response_body = parse_body(response)
expect_status(200)
expect(json_body).to contain_exactly(
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
expect(response_body).to contain_exactly(
a_hash_including(username: Runtime::User.username)
)
end
it 'GET /users/:username with an invalid username',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347883' do
get request.url, { params: { username: SecureRandom.hex(10) } }
request = Runtime::API::Request.new(api_client, '/users', username: SecureRandom.hex(10))
response = Support::API.get(request.url)
response_body = parse_body(response)
expect_status(200)
expect(json_body).to eq([])
expect(response.code).to eq(Support::API::HTTP_STATUS_OK)
expect(response_body).to eq([])
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment