From a210c43e0aca0311cc1d3d381763b25979ec72dc Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 11 Mar 2020 15:09:37 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- qa/qa/resource/ssh_key.rb | 31 ++++++++++++++++++++++ .../3_create/repository/add_ssh_key_spec.rb | 2 +- .../repository/protocol_v2_push_ssh_spec.rb | 18 ++++--------- .../3_create/repository/use_ssh_key_spec.rb | 2 +- 4 files changed, 38 insertions(+), 15 deletions(-) (limited to 'qa') diff --git a/qa/qa/resource/ssh_key.rb b/qa/qa/resource/ssh_key.rb index 22bdea424ca..3e130aef9e4 100644 --- a/qa/qa/resource/ssh_key.rb +++ b/qa/qa/resource/ssh_key.rb @@ -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 diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb index c3379d41ff2..25866e12185 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb @@ -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 diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb index a9e9380cac4..e845c3ca8ea 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb @@ -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 diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb index ab60ee33c1e..1a3c6d03098 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb @@ -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 -- cgit v1.2.3