Commit ad19a475 authored by Mark Lapierre's avatar Mark Lapierre Committed by Dan Davison

Delete SSH keys created by tests

parent 1eeec3fe
...@@ -76,6 +76,15 @@ module QA ...@@ -76,6 +76,15 @@ module QA
parse_body(response)[:title].include?(title) parse_body(response)[:title].include?(title)
end end
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 end
end end
...@@ -36,6 +36,10 @@ module QA ...@@ -36,6 +36,10 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end 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 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| Resource::Repository::Push.fabricate! do |push|
push.repository_http_uri = repository_uri_http push.repository_http_uri = repository_uri_http
......
...@@ -36,6 +36,10 @@ module QA ...@@ -36,6 +36,10 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end 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 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| Resource::Repository::Push.fabricate! do |push|
push.repository_http_uri = repository_uri_http push.repository_http_uri = repository_uri_http
......
...@@ -83,6 +83,10 @@ module QA ...@@ -83,6 +83,10 @@ module QA
end end
end end
after do
key.remove_via_api!
end
it 'denies access', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/860' do 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/) expect { push_a_project_with_ssh_key(key) }.to raise_error(QA::Git::Repository::RepositoryCommandError, /fatal: Could not read from remote repository/)
end end
...@@ -126,6 +130,10 @@ module QA ...@@ -126,6 +130,10 @@ module QA
end end
end end
after do
key.remove_via_api!
end
it 'allows access', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/863' do 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 expect { push_a_project_with_ssh_key(key) }.not_to raise_error
end end
......
...@@ -45,13 +45,19 @@ module QA ...@@ -45,13 +45,19 @@ module QA
end end
context 'Add SSH key', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/738' do context 'Add SSH key', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/738' do
key = nil
before do before do
sign_in 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}" resource.title = "key for audit event test #{Time.now.to_f}"
end end
end end
after do
key&.reload!&.remove_via_api!
end
it_behaves_like 'audit event', ["Added SSH key"] it_behaves_like 'audit event', ["Added SSH key"]
end end
......
...@@ -5,12 +5,17 @@ module QA ...@@ -5,12 +5,17 @@ module QA
describe 'GitLab SSH push' do describe 'GitLab SSH push' do
let(:file_name) { 'README.md' } let(:file_name) { 'README.md' }
key = nil
after do
key&.remove_via_api!
end
context 'regular git commit' do context 'regular git commit' do
it "is replicated to the secondary", testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/686' 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}" key_title = "Geo SSH #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from primary.' file_content = 'This is a Geo project! Commit from primary.'
project = nil project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user # Create a new SSH key for the user
...@@ -73,7 +78,6 @@ module QA ...@@ -73,7 +78,6 @@ module QA
key_title = "Geo SSH LFS #{Time.now.to_f}" key_title = "Geo SSH LFS #{Time.now.to_f}"
file_content = 'The rendered file could not be displayed because it is stored in LFS.' file_content = 'The rendered file could not be displayed because it is stored in LFS.'
project = nil project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user # Create a new SSH key for the user
......
...@@ -6,12 +6,17 @@ module QA ...@@ -6,12 +6,17 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' } let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' } 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 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 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' file_name = 'README.md'
key_title = "Geo SSH to 2nd #{Time.now.to_f}" key_title = "Geo SSH to 2nd #{Time.now.to_f}"
project = nil project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user # Create a new SSH key for the user
...@@ -95,7 +100,6 @@ module QA ...@@ -95,7 +100,6 @@ module QA
file_name_primary = 'README.md' file_name_primary = 'README.md'
file_name_secondary = 'README_MORE.md' file_name_secondary = 'README_MORE.md'
project = nil project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key for the user # Create a new SSH key for the user
......
...@@ -3,12 +3,17 @@ ...@@ -3,12 +3,17 @@
module QA module QA
RSpec.describe 'Geo', :orchestrated, :geo do RSpec.describe 'Geo', :orchestrated, :geo do
describe 'GitLab wiki SSH push' do describe 'GitLab wiki SSH push' do
key = nil
after do
key&.remove_via_api!
end
context 'wiki commit' do context 'wiki commit' do
it 'is replicated to the secondary', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/688' 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' wiki_content = 'This tests replication of wikis via SSH'
push_content = 'This is from the Geo wiki push via SSH!' push_content = 'This is from the Geo wiki push via SSH!'
project = nil project = nil
key = nil
QA::Flow::Login.while_signed_in(address: :geo_primary) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Create a new SSH key # Create a new SSH key
......
...@@ -34,6 +34,10 @@ module QA ...@@ -34,6 +34,10 @@ module QA
end end
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 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*****') 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