Commit fa53b1e7 authored by Dan Davison's avatar Dan Davison

Merge branch 'ml-delete-ssh-keys-created-by-tests' into 'master'

Delete SSH keys created by tests

Closes gitlab-org/quality/team-tasks#665

See merge request gitlab-org/gitlab!43504
parents c6f69a0a ad19a475
......@@ -76,6 +76,15 @@ module QA
parse_body(response)[:title].include?(title)
end
end
private
def api_get
with_paginated_response_body(Runtime::API::Request.new(api_client, '/user/keys', per_page: '100').url) do |page|
key = page.find { |key| key[:title] == title }
break process_api_response(key) if key
end
end
end
end
end
......@@ -36,6 +36,10 @@ module QA
Flow::Login.sign_in
end
after do
ssh_key.remove_via_api!
end
it 'clones, pushes, and pulls a snippet over HTTP, edits via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/826' do
Resource::Repository::Push.fabricate! do |push|
push.repository_http_uri = repository_uri_http
......
......@@ -36,6 +36,10 @@ module QA
Flow::Login.sign_in
end
after do
ssh_key.remove_via_api!
end
it 'clones, pushes, and pulls a project snippet over HTTP, edits via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/833' do
Resource::Repository::Push.fabricate! do |push|
push.repository_http_uri = repository_uri_http
......
......@@ -83,6 +83,10 @@ module QA
end
end
after do
key.remove_via_api!
end
it 'denies access', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/860' do
expect { push_a_project_with_ssh_key(key) }.to raise_error(QA::Git::Repository::RepositoryCommandError, /fatal: Could not read from remote repository/)
end
......@@ -126,6 +130,10 @@ module QA
end
end
after do
key.remove_via_api!
end
it 'allows access', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/863' do
expect { push_a_project_with_ssh_key(key) }.not_to raise_error
end
......
......@@ -45,13 +45,19 @@ module QA
end
context 'Add SSH key', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/738' do
key = nil
before do
sign_in
Resource::SSHKey.fabricate_via_browser_ui! do |resource|
key = Resource::SSHKey.fabricate_via_browser_ui! do |resource|
resource.title = "key for audit event test #{Time.now.to_f}"
end
end
after do
key&.reload!&.remove_via_api!
end
it_behaves_like 'audit event', ["Added SSH key"]
end
......
......@@ -5,12 +5,17 @@ module QA
describe 'GitLab SSH push' do
let(:file_name) { 'README.md' }
key = nil
after do
key&.remove_via_api!
end
context 'regular git commit' do
it "is replicated to the secondary", testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/686' do
key_title = "Geo SSH #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from primary.'
project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user
......@@ -73,7 +78,6 @@ module QA
key_title = "Geo SSH LFS #{Time.now.to_f}"
file_content = 'The rendered file could not be displayed because it is stored in LFS.'
project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user
......
......@@ -6,12 +6,17 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
key = nil
after do
key&.remove_via_api!
end
context 'regular git commit' do
it 'is proxied to the primary and ultimately replicated to the secondary', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/698' do
file_name = 'README.md'
key_title = "Geo SSH to 2nd #{Time.now.to_f}"
project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user
......@@ -95,7 +100,6 @@ module QA
file_name_primary = 'README.md'
file_name_secondary = 'README_MORE.md'
project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user
......
......@@ -3,12 +3,17 @@
module QA
RSpec.describe 'Geo', :orchestrated, :geo do
describe 'GitLab wiki SSH push' do
key = nil
after do
key&.remove_via_api!
end
context 'wiki commit' do
it 'is replicated to the secondary', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/688' do
wiki_content = 'This tests replication of wikis via SSH'
push_content = 'This is from the Geo wiki push via SSH!'
project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key
......
......@@ -34,6 +34,10 @@ module QA
end
end
after do
key.remove_via_api!
end
it 'proxies wiki commit to primary node and ultmately replicates to secondary node', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/694' do
QA::Runtime::Logger.debug('*****Visiting the secondary geo node*****')
......
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