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