Commit fe09606a authored by Sofia Vistas's avatar Sofia Vistas

Merge branch 'refactor-nuget-test-auth-tokens' into 'master'

Refactor nuget to use supported auth tokens

See merge request gitlab-org/gitlab!68272
parents 441741f2 ed1493af
......@@ -68,8 +68,25 @@ module QA
end
end
def go_to_repository_settings
hover_group_settings do
within_submenu do
click_element(:sidebar_menu_item_link, menu_item: 'Repository')
end
end
end
private
def hover_settings
within_sidebar do
scroll_to_element(:sidebar_menu_link, menu_item: 'Settings')
find_element(:sidebar_menu_link, menu_item: 'Settings').hover
yield
end
end
def hover_issues
within_sidebar do
scroll_to_element(:sidebar_menu_link, menu_item: 'Issues')
......
# frozen_string_literal: true
module QA
module Page
module Group
module Settings
class GroupDeployTokens < Page::Base
view 'app/views/shared/deploy_tokens/_form.html.haml' do
element :deploy_token_name_field
element :deploy_token_expires_at_field
element :deploy_token_read_repository_checkbox
element :deploy_token_read_package_registry_checkbox
element :deploy_token_read_registry_checkbox
element :deploy_token_write_package_registry_checkbox
element :create_deploy_token_button
end
view 'app/views/shared/deploy_tokens/_new_deploy_token.html.haml' do
element :created_deploy_token_container
element :deploy_token_user_field
element :deploy_token_field
end
def fill_token_name(name)
fill_element(:deploy_token_name_field, name)
end
def fill_token_expires_at(expires_at)
fill_element(:deploy_token_expires_at_field, expires_at.to_s + "\n")
end
def fill_scopes(read_repository: false, read_registry: false, read_package_registry: false, write_package_registry: false )
check_element(:deploy_token_read_repository_checkbox) if read_repository
check_element(:deploy_token_read_package_registry_checkbox) if read_package_registry
check_element(:deploy_token_read_registry_checkbox) if read_registry
check_element(:deploy_token_write_package_registry_checkbox) if write_package_registry
end
def add_token
click_element(:create_deploy_token_button)
end
def token_username
within_new_project_deploy_token do
find_element(:deploy_token_user_field).value
end
end
def token_password
within_new_project_deploy_token do
find_element(:deploy_token_field).value
end
end
private
def within_new_project_deploy_token
has_element?(:created_deploy_token_container, wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME)
within_element(:created_deploy_token_container) do
yield
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Group
module Settings
class Repository < Page::Base
include QA::Page::Settings::Common
view 'app/views/shared/deploy_tokens/_index.html.haml' do
element :deploy_tokens_settings_content
end
def expand_deploy_tokens(&block)
expand_content(:deploy_tokens_settings_content) do
Settings::GroupDeployTokens.perform(&block)
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Resource
class GroupDeployToken < Base
attr_accessor :name, :expires_at
attribute :username do
Page::Group::Settings::Repository.perform do |repository_page|
repository_page.expand_deploy_tokens(&:token_username)
end
end
attribute :password do
Page::Group::Settings::Repository.perform do |repository_page|
repository_page.expand_deploy_tokens(&:token_password)
end
end
attribute :group do
Group.fabricate! do |resource|
resource.name = 'group-with-deploy-token'
resource.description = 'group for adding deploy token test'
end
end
attribute :project do
Project.fabricate! do |resource|
resource.name = 'project-to-deploy'
resource.description = 'project for adding deploy token test'
end
end
def fabricate!
group.visit!
Page::Group::Menu.perform(&:go_to_repository_settings)
Page::Group::Settings::Repository.perform do |setting|
setting.expand_deploy_tokens do |page|
page.fill_token_name(name)
page.fill_token_expires_at(expires_at)
page.fill_scopes(read_repository: true, read_package_registry: true, write_package_registry: true)
page.add_token
end
end
end
end
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