Commit d632475b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'qa-add-deploy-key' into 'master'

QA: Add a scenario for adding a deploy key

See merge request gitlab-org/gitlab-ce!16096
parents 377024ec 60fc3925
......@@ -3,7 +3,7 @@
.settings-header
%h4
Deploy Keys
%button.btn.js-settings-toggle
%button.btn.js-settings-toggle.qa-expand-deploy-keys
= expanded ? 'Collapse' : 'Expand'
%p
Deploy keys allow read-only or read-write (if enabled) access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one.
......
......@@ -24,6 +24,7 @@ module QA
autoload :Sandbox, 'qa/factory/resource/sandbox'
autoload :Group, 'qa/factory/resource/group'
autoload :Project, 'qa/factory/resource/project'
autoload :DeployKey, 'qa/factory/resource/deploy_key'
end
module Repository
......@@ -69,10 +70,15 @@ module QA
module Main
autoload :Login, 'qa/page/main/login'
autoload :Menu, 'qa/page/main/menu'
autoload :OAuth, 'qa/page/main/oauth'
end
module Menu
autoload :Main, 'qa/page/menu/main'
autoload :Side, 'qa/page/menu/side'
autoload :Admin, 'qa/page/menu/admin'
end
module Dashboard
autoload :Projects, 'qa/page/dashboard/projects'
autoload :Groups, 'qa/page/dashboard/groups'
......@@ -86,10 +92,15 @@ module QA
module Project
autoload :New, 'qa/page/project/new'
autoload :Show, 'qa/page/project/show'
module Settings
autoload :Common, 'qa/page/project/settings/common'
autoload :Repository, 'qa/page/project/settings/repository'
autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
end
end
module Admin
autoload :Menu, 'qa/page/admin/menu'
autoload :Settings, 'qa/page/admin/settings'
end
......
module QA
module Factory
module Resource
class DeployKey < Factory::Base
attr_accessor :title, :key
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-to-deploy'
project.description = 'project for adding deploy key test'
end
def fabricate!
project.visit!
Page::Menu::Side.act do
click_repository_setting
end
Page::Project::Settings::Repository.perform do |setting|
setting.expand_deploy_keys do |page|
page.fill_key_title(title)
page.fill_key_value(key)
page.add_key
end
end
end
end
end
end
end
......@@ -11,7 +11,7 @@ module QA
end
def fabricate!
Page::Main::Menu.act { go_to_groups }
Page::Menu::Main.act { go_to_groups }
Page::Dashboard::Groups.perform do |page|
if page.has_group?(@name)
......
......@@ -6,15 +6,15 @@ module QA
raise ArgumentError unless traits.include?(:enabled)
Page::Main::Login.act { sign_in_using_credentials }
Page::Main::Menu.act { go_to_admin_area }
Page::Admin::Menu.act { go_to_settings }
Page::Menu::Main.act { go_to_admin_area }
Page::Menu::Admin.act { go_to_settings }
Page::Admin::Settings.act do
enable_hashed_storage
save_settings
end
QA::Page::Main::Menu.act { sign_out }
QA::Page::Menu::Main.act { sign_out }
end
end
end
......
module QA
module Page
module Admin
class Menu < Page::Base
module Menu
class Admin < Page::Base
def go_to_license
click_link 'License'
end
......
module QA
module Page
module Main
class Menu < Page::Base
module Menu
class Main < Page::Base
def go_to_groups
within_top_menu { click_link 'Groups' }
end
......
module QA
module Page
module Menu
class Side < Page::Base
def click_repository_setting
hover_setting do
click_link('Repository')
end
end
private
def hover_setting
within_sidebar do
find('.nav-item-name', text: 'Settings').hover
yield
end
end
def within_sidebar
page.within('.sidebar-top-level-items') do
yield
end
end
end
end
end
end
module QA
module Page
module Project
module Settings
module Common
def expand(selector)
page.within('#content-body') do
find(selector).click
yield
end
end
end
end
end
end
end
module QA
module Page
module Project
module Settings
class DeployKeys < Page::Base
def fill_key_title(title)
fill_in 'deploy_key_title', with: title
end
def fill_key_value(key)
fill_in 'deploy_key_key', with: key
end
def add_key
click_on 'Add key'
end
def has_key_title?(title)
page.within('.deploy-keys') do
page.find('.title', text: title)
end
end
end
end
end
end
end
module QA
module Page
module Project
module Settings
class Repository < Page::Base
include Common
def expand_deploy_keys(&block)
expand('.qa-expand-deploy-keys') do
DeployKeys.perform(&block)
end
end
end
end
end
end
end
......@@ -10,6 +10,17 @@ module QA
def password
ENV['GITLAB_PASSWORD'] || '5iveL!fe'
end
def ssh_key
<<~KEY.tr("\n", '')
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFf6RYK3qu/RKF/3ndJmL5xgMLp3O9
6x8lTay+QGZ0+9FnnAXMdUqBq/ZU6d/gyMB4IaW3nHzM1w049++yAB6UPCzMB8Uo27K5
/jyZCtj7Vm9PFNjF/8am1kp46c/SeYicQgQaSBdzIW3UDEa1Ef68qroOlvpi9PYZ/tA7
M0YP0K5PXX+E36zaIRnJVMPT3f2k+GnrxtjafZrwFdpOP/Fol5BQLBgcsyiU+LM1SuaC
rzd8c9vyaTA1CxrkxaZh+buAi0PmdDtaDrHd42gqZkXCKavyvgM5o2CkQ5LJHCgzpXy0
5qNFzmThBSkb+XtoxbyagBiGbVZtSVow6Xa7qewz= dummy@gitlab.com
KEY
end
end
end
end
......@@ -7,7 +7,7 @@ module QA
# TODO, since `Signed in successfully` message was removed
# this is the only way to tell if user is signed in correctly.
#
Page::Main::Menu.perform do |menu|
Page::Menu::Main.perform do |menu|
expect(menu).to have_personal_area
end
end
......
......@@ -3,7 +3,7 @@ module QA
scenario 'creating a group with a mattermost team' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Page::Main::Menu.act { go_to_groups }
Page::Menu::Main.act { go_to_groups }
Page::Dashboard::Groups.perform do |page|
page.go_to_new_group
......
module QA
feature 'deploy keys support', :core do
given(:deploy_key_title) { 'deploy key title' }
given(:deploy_key_value) { Runtime::User.ssh_key }
scenario 'user adds a deploy key' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::DeployKey.fabricate! do |deploy_key|
deploy_key.title = deploy_key_title
deploy_key.key = deploy_key_value
end
Page::Project::Settings::Repository.perform do |setting|
setting.expand_deploy_keys do |page|
expect(page).to have_key_title(deploy_key_title)
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