diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-20 15:11:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-20 15:11:29 +0300 |
commit | 7b384a1f3d2608898318e67d11eea2914889ae81 (patch) | |
tree | af33e77d13b18a96156c69616cb09a3a4f7697c6 /qa | |
parent | d46287cc16ba244720c6d5c00491944336972988 (diff) |
Add latest changes from gitlab-org/gitlab@12-3-stable
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 3 | ||||
-rw-r--r-- | qa/qa/git/repository.rb | 11 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 12 | ||||
-rw-r--r-- | qa/qa/page/project/settings/mirroring_repositories.rb | 55 | ||||
-rw-r--r-- | qa/qa/page/project/settings/repository.rb | 6 | ||||
-rw-r--r-- | qa/qa/resource/issue.rb | 14 | ||||
-rw-r--r-- | qa/qa/resource/repository/push.rb | 44 | ||||
-rw-r--r-- | qa/qa/resource/tag.rb | 30 | ||||
-rw-r--r-- | qa/qa/resource/user_gpg.rb | 46 | ||||
-rw-r--r-- | qa/qa/runtime/gpg.rb | 37 | ||||
-rw-r--r-- | qa/qa/runtime/user.rb | 4 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb | 1 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb | 4 | ||||
-rw-r--r-- | qa/qa/support/page/logging.rb | 9 |
14 files changed, 35 insertions, 241 deletions
@@ -23,7 +23,6 @@ module QA autoload :Feature, 'qa/runtime/feature' autoload :Fixtures, 'qa/runtime/fixtures' autoload :Logger, 'qa/runtime/logger' - autoload :GPG, 'qa/runtime/gpg' module API autoload :Client, 'qa/runtime/api/client' @@ -68,9 +67,7 @@ module QA autoload :Fork, 'qa/resource/fork' autoload :SSHKey, 'qa/resource/ssh_key' autoload :Snippet, 'qa/resource/snippet' - autoload :Tag, 'qa/resource/tag' autoload :ProjectMember, 'qa/resource/project_member' - autoload :UserGPG, 'qa/resource/user_gpg' module Events autoload :Base, 'qa/resource/events/base' diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index 09052a5e33f..24b9fc67dd9 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -14,7 +14,7 @@ module QA include Scenario::Actable RepositoryCommandError = Class.new(StandardError) - attr_writer :use_lfs, :gpg_key_id + attr_writer :use_lfs attr_accessor :env_vars InvalidCredentialsError = Class.new(RuntimeError) @@ -25,7 +25,6 @@ module QA # .netrc can be utilised self.env_vars = [%Q{HOME="#{tmp_home_dir}"}] @use_lfs = false - @gpg_key_id = nil end def self.perform(*args) @@ -100,18 +99,10 @@ module QA git_lfs_track_result.to_s + git_add_result.to_s end - def delete_tag(tag_name) - run(%Q{git push origin --delete #{tag_name}}).to_s - end - def commit(message) run(%Q{git commit -m "#{message}"}).to_s end - def commit_with_gpg(message) - run(%Q{git config user.signingkey #{@gpg_key_id} && git config gpg.program $(which gpg) && git commit -S -m "#{message}"}).to_s - end - def push_changes(branch = 'master') run("git push #{uri} #{branch}").to_s end diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 104c9b19e2a..45496c6b245 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -15,10 +15,6 @@ module QA def_delegators :evaluator, :view, :views - def assert_no_element(name) - assert_no_selector(element_selector_css(name)) - end - def refresh page.refresh end @@ -94,8 +90,8 @@ module QA end # replace with (..., page = self.class) - def click_element(name, page = nil, text: nil) - find_element(name, text: nil).click + def click_element(name, page = nil) + find_element(name).click page.validate_elements_present! if page end @@ -106,9 +102,9 @@ module QA def select_element(name, value) element = find_element(name) - return if element.text == value + return if element.text.downcase.to_s == value.to_s - element.select value + element.select value.to_s.capitalize end def has_element?(name, text: nil, wait: Capybara.default_max_wait_time) diff --git a/qa/qa/page/project/settings/mirroring_repositories.rb b/qa/qa/page/project/settings/mirroring_repositories.rb index 4afe042d9fb..441235afca8 100644 --- a/qa/qa/page/project/settings/mirroring_repositories.rb +++ b/qa/qa/page/project/settings/mirroring_repositories.rb @@ -15,9 +15,7 @@ module QA element :mirror_repository_button element :mirror_repository_url_cell element :mirror_last_update_at_cell - element :mirror_error_badge element :mirrored_repository_row - element :copy_public_key_button end view 'app/views/projects/mirrors/_mirror_repos_form.html.haml' do @@ -26,17 +24,6 @@ module QA view 'app/views/shared/_remote_mirror_update_button.html.haml' do element :update_now_button - element :updating_button - end - - view 'app/views/projects/mirrors/_ssh_host_keys.html.haml' do - element :detect_host_keys - element :fingerprints_list - end - - view 'app/views/projects/mirrors/_authentication_method.html.haml' do - element :authentication_method - element :password end def repository_url=(value) @@ -48,40 +35,17 @@ module QA end def mirror_direction=(value) - raise ArgumentError, "Mirror direction must be 'Push' or 'Pull'" unless %w(Push Pull).include? value + raise ArgumentError, "Mirror direction must be :push or :pull" unless [:push, :pull].include? value select_element(:mirror_direction, value) - - # Changing the mirror direction causes the fields below to change, - # and that change is animated, so we need to wait for the animation - # to complete otherwise changes to those fields could fail - wait_for_animated_element :authentication_method end def authentication_method=(value) - raise ArgumentError, "Authentication method must be 'SSH public key', 'Password', or 'None'" unless %w(Password None SSH\ public\ key).include? value + raise ArgumentError, "Authentication method must be :password or :none" unless [:password, :none].include? value select_element(:authentication_method, value) end - def public_key(url) - row_index = find_repository_row_index url - - within_element_by_index(:mirrored_repository_row, row_index) do - find_element(:copy_public_key_button)['data-clipboard-text'] - end - end - - def detect_host_keys - click_element :detect_host_keys - - # The host key detection process is interrupted if we navigate away - # from the page before the fingerprint appears. - wait(max: 5) do - find_element(:fingerprints_list).has_text? /.*/ - end - end - def mirror_repository click_element :mirror_repository_button end @@ -90,9 +54,7 @@ module QA row_index = find_repository_row_index url within_element_by_index(:mirrored_repository_row, row_index) do - # When a repository is first mirrored, the update process might - # already be started, so the button is already "clicked" - click_element :update_now_button unless has_element? :updating_button + click_element :update_now_button end # Wait a few seconds for the sync to occur and then refresh the page @@ -110,19 +72,16 @@ module QA # Fail early if the page still shows that there has been no update within_element_by_index(:mirrored_repository_row, row_index) do find_element(:mirror_last_update_at_cell, wait: 0).assert_no_text('Never') - assert_no_element(:mirror_error_badge) end end private def find_repository_row_index(target_url) - wait(max: 5, reload: false) do - all_elements(:mirror_repository_url_cell).index do |url| - # The url might be a sanitized url but the target_url won't be so - # we compare just the paths instead of the full url - URI.parse(url.text).path == target_url.path - end + all_elements(:mirror_repository_url_cell).index do |url| + # The url might be a sanitized url but the target_url won't be so + # we compare just the paths instead of the full url + URI.parse(url.text).path == target_url.path end end end diff --git a/qa/qa/page/project/settings/repository.rb b/qa/qa/page/project/settings/repository.rb index 58ed37870b7..437a945aceb 100644 --- a/qa/qa/page/project/settings/repository.rb +++ b/qa/qa/page/project/settings/repository.rb @@ -16,7 +16,7 @@ module QA end view 'app/views/projects/mirrors/_mirror_repos.html.haml' do - element :mirroring_repositories_settings_section + element :mirroring_repositories_settings end def expand_deploy_keys(&block) @@ -38,7 +38,7 @@ module QA end def expand_mirroring_repositories(&block) - expand_section(:mirroring_repositories_settings_section) do + expand_section(:mirroring_repositories_settings) do MirroringRepositories.perform(&block) end end @@ -47,5 +47,3 @@ module QA end end end - -QA::Page::Project::Settings::Repository.prepend_if_ee('QA::EE::Page::Project::Settings::Repository') diff --git a/qa/qa/resource/issue.rb b/qa/qa/resource/issue.rb index 9d0a5e159e0..a894e5c2033 100644 --- a/qa/qa/resource/issue.rb +++ b/qa/qa/resource/issue.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'securerandom' - module QA module Resource class Issue < Base @@ -15,14 +13,11 @@ module QA end attribute :id - attribute :assignee_ids attribute :labels attribute :title def initialize - @assignee_ids = [] @labels = [] - @title = "Issue title #{SecureRandom.hex(8)}" end def fabricate! @@ -30,10 +25,10 @@ module QA Page::Project::Show.perform(&:go_to_new_issue) - Page::Project::Issue::New.perform do |new_page| - new_page.add_title(@title) - new_page.add_description(@description) - new_page.create_new_issue + Page::Project::Issue::New.perform do |page| # rubocop:disable QA/AmbiguousPageObjectName + page.add_title(@title) + page.add_description(@description) + page.create_new_issue end end @@ -47,7 +42,6 @@ module QA def api_post_body { - assignee_ids: assignee_ids, labels: labels, title: title }.tap do |hash| diff --git a/qa/qa/resource/repository/push.rb b/qa/qa/resource/repository/push.rb index 68674248be2..a5827fb6e73 100644 --- a/qa/qa/resource/repository/push.rb +++ b/qa/qa/resource/repository/push.rb @@ -8,9 +8,9 @@ module QA class Push < Base attr_accessor :file_name, :file_content, :commit_message, :branch_name, :new_branch, :output, :repository_http_uri, - :repository_ssh_uri, :ssh_key, :user, :use_lfs, :tag_name + :repository_ssh_uri, :ssh_key, :user, :use_lfs - attr_writer :remote_branch, :gpg_key_id + attr_writer :remote_branch def initialize @file_name = 'file.txt' @@ -21,8 +21,6 @@ module QA @repository_http_uri = "" @ssh_key = nil @use_lfs = false - @tag_name = nil - @gpg_key_id = nil end def remote_branch @@ -69,43 +67,29 @@ module QA email = user.email end - unless @gpg_key_id.nil? - repository.gpg_key_id = @gpg_key_id - end - @output += repository.clone repository.configure_identity(username, email) @output += repository.checkout(branch_name, new_branch: new_branch) - if @tag_name - @output += repository.delete_tag(@tag_name) - else - if @directory - @directory.each_child do |f| - @output += repository.add_file(f.basename, f.read) if f.file? - end - elsif @files - @files.each do |f| - repository.add_file(f[:name], f[:content]) - end - else - @output += repository.add_file(file_name, file_content) + if @directory + @directory.each_child do |f| + @output += repository.add_file(f.basename, f.read) if f.file? end - - @output += commit_to repository - @output += repository.push_changes("#{branch_name}:#{remote_branch}") + elsif @files + @files.each do |f| + repository.add_file(f[:name], f[:content]) + end + else + @output += repository.add_file(file_name, file_content) end + @output += repository.commit(commit_message) + @output += repository.push_changes("#{branch_name}:#{remote_branch}") + repository.delete_ssh_key end end - - private - - def commit_to(repository) - @gpg_key_id.nil? ? repository.commit(@commit_message) : repository.commit_with_gpg(@commit_message) - end end end end diff --git a/qa/qa/resource/tag.rb b/qa/qa/resource/tag.rb deleted file mode 100644 index ac4fccec525..00000000000 --- a/qa/qa/resource/tag.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -module QA - module Resource - class Tag < Base - attr_accessor :project, :name, :ref - - def resource_web_url(resource) - super - rescue ResourceURLMissingError - # this particular resource does not expose a web_url property - end - - def api_get_path - "/projects/#{project.id}/repository/tags/#{name}" - end - - def api_post_path - "/projects/#{project.id}/repository/tags" - end - - def api_post_body - { - tag_name: name, - ref: ref - } - end - end - end -end diff --git a/qa/qa/resource/user_gpg.rb b/qa/qa/resource/user_gpg.rb deleted file mode 100644 index 25d74ad8ce5..00000000000 --- a/qa/qa/resource/user_gpg.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module QA - module Resource - class UserGPG < Base - attr_accessor :id, :gpg - attr_reader :key_id - - def initialize - @gpg = Runtime::GPG.new - @key_id = @gpg.key_id - end - - def fabricate_via_api! - super - @id = self.api_response[:id] - rescue ResourceFabricationFailedError => error - if error.message.include? 'has already been taken' - self - else - raise ResourceFabricationFailedError error - end - end - - def resource_web_url(resource) - super - rescue ResourceURLMissingError - # this particular resource does not expose a web_url property - end - - def api_get_path - "/user/gpg_keys/#{@id}" - end - - def api_post_path - '/user/gpg_keys' - end - - def api_post_body - { - key: @gpg.key - } - end - end - end -end diff --git a/qa/qa/runtime/gpg.rb b/qa/qa/runtime/gpg.rb deleted file mode 100644 index 9f8baf7e580..00000000000 --- a/qa/qa/runtime/gpg.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module QA - module Runtime - class GPG - attr_reader :key, :key_id - - def initialize - @key_id = 'B8358D73048DACC4' - import_key(File.expand_path('qa/ee/fixtures/gpg/admin.asc')) - @key = collect_key.first - end - - private - - def import_key(path) - import_key = "gpg --import #{path}" - execute(import_key) - end - - def collect_key - get_ascii_format = "gpg --armor --export #{@key_id}" - execute(get_ascii_format) - end - - def execute(command) - Open3.capture2e(*command) do |stdin, out, wait| - out.each_char { |char| print char } - - if wait.value.exited? && wait.value.exitstatus.nonzero? - raise CommandError, "Command `#{command}` failed!" - end - end - end - end - end -end diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb index 3c26a3ad691..011e4a548a5 100644 --- a/qa/qa/runtime/user.rb +++ b/qa/qa/runtime/user.rb @@ -25,10 +25,6 @@ module QA Runtime::Env.user_password || default_password end - def email - default_email - end - def ldap_user? Runtime::Env.ldap_username && Runtime::Env.ldap_password end diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb index 45c14d0537c..e3fd835bb01 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/mentions_spec.rb @@ -11,7 +11,6 @@ module QA project = Resource::Project.fabricate_via_api! do |resource| resource.name = 'project-to-test-mention' - resource.visibility = 'private' end project.visit! diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb index 059362704b4..448d4980727 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb @@ -25,8 +25,8 @@ module QA settings.expand_mirroring_repositories do |mirror_settings| # Configure the source project to push to the target project mirror_settings.repository_url = target_project_uri - mirror_settings.mirror_direction = 'Push' - mirror_settings.authentication_method = 'Password' + mirror_settings.mirror_direction = :push + mirror_settings.authentication_method = :password mirror_settings.password = Runtime::User.password mirror_settings.mirror_repository mirror_settings.update target_project_uri diff --git a/qa/qa/support/page/logging.rb b/qa/qa/support/page/logging.rb index 6b6e12f86de..93d8fa99c0a 100644 --- a/qa/qa/support/page/logging.rb +++ b/qa/qa/support/page/logging.rb @@ -4,12 +4,6 @@ module QA module Support module Page module Logging - def assert_no_element(name) - log("asserting no element :#{name}") - - super - end - def refresh log("refreshing #{current_url}") @@ -59,10 +53,9 @@ module QA elements end - def click_element(name, page = nil, **kwargs) + def click_element(name, page = nil) msg = ["clicking :#{name}"] msg << ", expecting to be at #{page.class}" if page - msg << "with args #{kwargs}" log(msg.compact.join(' ')) |