diff options
-rw-r--r-- | app/views/layouts/nav/sidebar/_group.html.haml | 2 | ||||
-rw-r--r-- | qa/qa.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/component/select2.rb | 7 | ||||
-rw-r--r-- | qa/qa/page/main/menu.rb | 6 | ||||
-rw-r--r-- | qa/qa/resource/api_fabricator.rb | 7 | ||||
-rw-r--r-- | qa/qa/resource/base.rb | 1 | ||||
-rw-r--r-- | qa/qa/resource/group.rb | 4 | ||||
-rw-r--r-- | qa/qa/resource/user.rb | 14 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 6 | ||||
-rw-r--r-- | qa/qa/support/api.rb | 28 |
10 files changed, 63 insertions, 13 deletions
diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml index 3cd5168c1f7..477030a20c1 100644 --- a/app/views/layouts/nav/sidebar/_group.html.haml +++ b/app/views/layouts/nav/sidebar/_group.html.haml @@ -108,7 +108,7 @@ = link_to group_group_members_path(@group) do .nav-icon-container = sprite_icon('users') - %span.nav-item-name + %span.nav-item-name.qa-group-members-item = _('Members') %ul.sidebar-sub-level-items.is-fly-out-only = nav_link(path: 'group_members#index', html_options: { class: "fly-out-top-item" } ) do @@ -329,6 +329,7 @@ module QA module Page autoload :Logging, 'qa/support/page/logging' end + autoload :Api, 'qa/support/api' end end diff --git a/qa/qa/page/component/select2.rb b/qa/qa/page/component/select2.rb index 30829eb0221..6d07d5a10e6 100644 --- a/qa/qa/page/component/select2.rb +++ b/qa/qa/page/component/select2.rb @@ -3,7 +3,12 @@ module QA module Component module Select2 def select_item(item_text) - find('ul.select2-result-sub > li', text: item_text).click + find('.select2-result-label', text: item_text).click + end + + def search_and_select(item_text) + find('.select2-input').set(item_text) + select_item(item_text) end end end diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index fb45ebef1b6..cc2724618e9 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -68,6 +68,12 @@ module QA end end + def has_admin_area_link?(wait: Capybara.default_max_wait_time) + using_wait_time(wait) do + page.has_selector?(element_selector_css(:admin_area_link)) + end + end + private def within_top_menu diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb index 3762a94f312..98eebac0880 100644 --- a/qa/qa/resource/api_fabricator.rb +++ b/qa/qa/resource/api_fabricator.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true -require 'airborne' require 'active_support/core_ext/object/deep_dup' require 'capybara/dsl' module QA module Resource module ApiFabricator - include Airborne include Capybara::DSL HTTP_STATUS_OK = 200 @@ -43,6 +41,7 @@ module QA private + include Support::Api attr_writer :api_resource, :api_response def resource_web_url(resource) @@ -84,10 +83,6 @@ module QA end end - def parse_body(response) - JSON.parse(response.body, symbolize_names: true) - end - def process_api_response(parsed_response) self.api_response = parsed_response self.api_resource = transform_api_resource(parsed_response.deep_dup) diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index f3eefb70520..dcea144ab74 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -2,6 +2,7 @@ require 'forwardable' require 'capybara/dsl' +require 'active_support/core_ext/array/extract_options' module QA module Resource diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb index dce15e4f10b..a7a6f931e28 100644 --- a/qa/qa/resource/group.rb +++ b/qa/qa/resource/group.rb @@ -51,6 +51,10 @@ module QA "/groups/#{CGI.escape("#{sandbox.path}/#{path}")}" end + def api_members_path + "#{api_get_path}/members" + end + def api_post_path '/groups' end diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb index 9be88ba4211..c26f0c84a1f 100644 --- a/qa/qa/resource/user.rb +++ b/qa/qa/resource/user.rb @@ -6,7 +6,8 @@ module QA module Resource class User < Base attr_reader :unique_id - attr_writer :username, :password + attr_writer :username, :password, :name, :email + attr_accessor :provider, :extern_uid def initialize @unique_id = SecureRandom.hex(8) @@ -73,7 +74,7 @@ module QA username: username, name: name, skip_confirmation: true - } + }.merge(ldap_post_body) end def self.fabricate_or_use(username, password) @@ -89,6 +90,15 @@ module QA private + def ldap_post_body + return {} unless extern_uid && provider + + { + extern_uid: extern_uid, + provider: provider + } + end + def fetch_id(username) users = parse_body(api_get_from("/users?username=#{username}")) diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 0d573859238..7b2768548dd 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -5,7 +5,7 @@ module QA module Env extend self - attr_writer :personal_access_token + attr_writer :personal_access_token, :ldap_username, :ldap_password # The environment variables used to indicate if the environment under test # supports the given feature @@ -92,11 +92,11 @@ module QA end def ldap_username - ENV['GITLAB_LDAP_USERNAME'] + @ldap_username ||= ENV['GITLAB_LDAP_USERNAME'] end def ldap_password - ENV['GITLAB_LDAP_PASSWORD'] + @ldap_password ||= ENV['GITLAB_LDAP_PASSWORD'] end def sandbox_name diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb new file mode 100644 index 00000000000..1107d43161e --- /dev/null +++ b/qa/qa/support/api.rb @@ -0,0 +1,28 @@ +module QA + module Support + module Api + def post(url, payload) + RestClient::Request.execute( + method: :post, + url: url, + payload: payload, + verify_ssl: false) + rescue RestClient::ExceptionWithResponse => e + e.response + end + + def get(url) + RestClient::Request.execute( + method: :get, + url: url, + verify_ssl: false) + rescue RestClient::ExceptionWithResponse => e + e.response + end + + def parse_body(response) + JSON.parse(response.body, symbolize_names: true) + end + end + end +end |