Commit 80bbb770 authored by Mark Lapierre's avatar Mark Lapierre Committed by Sanad Liaquat

Update E2E test to add SSH key via the API

parent 2a3770cd
...@@ -7,6 +7,8 @@ module QA ...@@ -7,6 +7,8 @@ module QA
attr_accessor :title attr_accessor :title
attribute :id
def_delegators :key, :private_key, :public_key, :md5_fingerprint def_delegators :key, :private_key, :public_key, :md5_fingerprint
def key def key
...@@ -21,6 +23,35 @@ module QA ...@@ -21,6 +23,35 @@ module QA
profile_page.add_key(public_key, title) profile_page.add_key(public_key, title)
end end
end end
def fabricate_via_api!
api_post
end
def api_delete
QA::Runtime::Logger.debug("Deleting SSH key with title '#{title}' and fingerprint '#{md5_fingerprint}'")
super
end
def api_get_path
"/user/keys/#{id}"
end
def api_post_path
'/user/keys'
end
def api_post_body
{
title: title,
key: public_key
}
end
def api_delete_path
"/user/keys/#{id}"
end
end end
end end
end end
...@@ -8,7 +8,7 @@ module QA ...@@ -8,7 +8,7 @@ module QA
it 'user adds and then removes an SSH key', :smoke do it 'user adds and then removes an SSH key', :smoke do
Flow::Login.sign_in Flow::Login.sign_in
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_browser_ui! do |resource|
resource.title = key_title resource.title = key_title
end end
......
...@@ -11,29 +11,24 @@ module QA ...@@ -11,29 +11,24 @@ module QA
let(:key_title) { "key for ssh tests #{Time.now.to_f}" } let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
let(:ssh_key) do let(:ssh_key) do
Resource::SSHKey.fabricate! do |resource| Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
end end
around do |example| around do |example|
# Create an SSH key to be used with Git # Create an SSH key to be used with Git, then remove it after the test
Flow::Login.sign_in Flow::Login.sign_in
ssh_key ssh_key
example.run example.run
# Remove the SSH key ssh_key.remove_via_api!
Flow::Login.sign_in
Page::Main::Menu.perform(&:click_settings_link) Page::Main::Menu.perform(&:sign_out_if_signed_in)
Page::Profile::Menu.perform(&:click_ssh_keys)
Page::Profile::SSHKeys.perform do |ssh_keys|
ssh_keys.remove_key(key_title)
end
end end
it 'user pushes to the repository' do it 'user pushes to the repository' do
# Create a project to push to
project = Resource::Project.fabricate_via_api! do |project| project = Resource::Project.fabricate_via_api! do |project|
project.name = 'git-protocol-project' project.name = 'git-protocol-project'
end end
...@@ -68,11 +63,8 @@ module QA ...@@ -68,11 +63,8 @@ module QA
project.visit! project.visit!
project.wait_for_push_new_branch project.wait_for_push_new_branch
# Check that the push worked
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
# And check that the correct Git protocol was used
expect(git_protocol_reported).to eq(git_protocol) expect(git_protocol_reported).to eq(git_protocol)
end end
end end
......
...@@ -11,7 +11,7 @@ module QA ...@@ -11,7 +11,7 @@ module QA
it 'user adds an ssh key and pushes code to the repository' do it 'user adds an ssh key and pushes code to the repository' do
Flow::Login.sign_in Flow::Login.sign_in
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
......
...@@ -46,7 +46,7 @@ module QA ...@@ -46,7 +46,7 @@ module QA
context 'Add SSH key' do context 'Add SSH key' do
before do before do
sign_in sign_in
Resource::SSHKey.fabricate! do |resource| Resource::SSHKey.fabricate_via_browser_ui! do |resource|
resource.title = "key for instance audit event logs test #{Time.now.to_f}" resource.title = "key for instance audit event logs test #{Time.now.to_f}"
end end
end end
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
...@@ -83,7 +83,7 @@ module QA ...@@ -83,7 +83,7 @@ module QA
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
......
...@@ -15,7 +15,7 @@ module QA ...@@ -15,7 +15,7 @@ module QA
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
...@@ -105,7 +105,7 @@ module QA ...@@ -105,7 +105,7 @@ module QA
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
......
...@@ -15,7 +15,7 @@ module QA ...@@ -15,7 +15,7 @@ module QA
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
end end
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
before do before do
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
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title resource.title = key_title
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