diff options
author | Stan Hu <stanhu@gmail.com> | 2018-10-08 15:31:57 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-10-12 06:07:41 -0700 |
commit | bf4568811a5eb62aa51f7f7b4f9835112bd787e4 (patch) | |
tree | 33693816a747cea0816acee9c56717734a8aaacb /qa | |
parent | a5ecb5bbdac05c3b1a96ecb918ce6a4ceed37d75 (diff) | |
download | gitlab-ce-bf4568811a5eb62aa51f7f7b4f9835112bd787e4.tar.gz |
Add GitLab QA spec for adding a deploy token
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 2 | ||||
-rw-r--r-- | qa/qa/factory/resource/deploy_token.rb | 48 | ||||
-rw-r--r-- | qa/qa/page/project/settings/deploy_tokens.rb | 64 | ||||
-rw-r--r-- | qa/qa/page/project/settings/repository.rb | 6 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb | 23 |
5 files changed, 143 insertions, 0 deletions
@@ -49,6 +49,7 @@ module QA autoload :ProjectImportedFromGithub, 'qa/factory/resource/project_imported_from_github' autoload :MergeRequestFromFork, 'qa/factory/resource/merge_request_from_fork' autoload :DeployKey, 'qa/factory/resource/deploy_key' + autoload :DeployToken, 'qa/factory/resource/deploy_token' autoload :Branch, 'qa/factory/resource/branch' autoload :SecretVariable, 'qa/factory/resource/secret_variable' autoload :Runner, 'qa/factory/resource/runner' @@ -177,6 +178,7 @@ module QA autoload :Repository, 'qa/page/project/settings/repository' autoload :CICD, 'qa/page/project/settings/ci_cd' autoload :DeployKeys, 'qa/page/project/settings/deploy_keys' + autoload :DeployTokens, 'qa/page/project/settings/deploy_tokens' autoload :ProtectedBranches, 'qa/page/project/settings/protected_branches' autoload :SecretVariables, 'qa/page/project/settings/secret_variables' autoload :Runners, 'qa/page/project/settings/runners' diff --git a/qa/qa/factory/resource/deploy_token.rb b/qa/qa/factory/resource/deploy_token.rb new file mode 100644 index 00000000000..159f79ac50b --- /dev/null +++ b/qa/qa/factory/resource/deploy_token.rb @@ -0,0 +1,48 @@ +module QA + module Factory + module Resource + class DeployToken < Factory::Base + attr_accessor :name, :expires_at + + product :username do |resource| + Page::Project::Settings::Repository.act do + expand_deploy_tokens do |token| + token.token_username + end + end + end + + product :password do |password| + Page::Project::Settings::Repository.act do + expand_deploy_tokens do |token| + token.token_password + end + end + end + + dependency Factory::Resource::Project, as: :project do |project| + project.name = 'project-to-deploy' + project.description = 'project for adding deploy token test' + end + + def fabricate! + project.visit! + + Page::Project::Menu.act do + click_repository_settings + end + + Page::Project::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_registry: false) + + page.add_token + end + end + end + end + end + end +end diff --git a/qa/qa/page/project/settings/deploy_tokens.rb b/qa/qa/page/project/settings/deploy_tokens.rb new file mode 100644 index 00000000000..2d42372cbc5 --- /dev/null +++ b/qa/qa/page/project/settings/deploy_tokens.rb @@ -0,0 +1,64 @@ +module QA + module Page + module Project + module Settings + class DeployTokens < Page::Base + view 'app/views/projects/deploy_tokens/_form.html.haml' do + element :deploy_token_name + element :deploy_token_expires_at + element :deploy_token_read_repository + element :deploy_token_read_registry + element :create_deploy_token + end + + view 'app/views/projects/deploy_tokens/_new_deploy_token.html.haml' do + element :created_deploy_token_section + element :deploy_token_user + element :deploy_token + end + + def fill_token_name(name) + fill_element :deploy_token_name, name + end + + def fill_token_expires_at(expires_at) + fill_element :deploy_token_expires_at, expires_at.to_s + "\n" + end + + def fill_scopes(read_repository:, read_registry:) + check_element :deploy_token_read_repository if read_repository + check_element :deploy_token_read_registry if read_registry + end + + def add_token + click_element :create_deploy_token + end + + def token_username + within_new_project_deploy_token do + find_element(:deploy_token_user).value + end + end + + def token_password + within_new_project_deploy_token do + find_element(:deploy_token).value + end + end + + private + + def within_new_project_deploy_token + wait(reload: false) do + has_css?(element_selector_css(:created_deploy_token_section)) + end + + within_element(:created_deploy_token_section) do + yield + end + end + end + end + end + end +end diff --git a/qa/qa/page/project/settings/repository.rb b/qa/qa/page/project/settings/repository.rb index 1ed5f455a85..53ebe28970b 100644 --- a/qa/qa/page/project/settings/repository.rb +++ b/qa/qa/page/project/settings/repository.rb @@ -24,6 +24,12 @@ module QA ProtectedBranches.perform(&block) end end + + def expand_deploy_tokens(&block) + expand_section(:deploy_tokens_settings) do + DeployTokens.perform(&block) + end + end end end end diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb new file mode 100644 index 00000000000..e521597e07f --- /dev/null +++ b/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module QA + context :release do + describe 'Deploy token creation' do + it 'user adds a deploy token' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + + deploy_token_name = 'deploy token name' + deploy_token_expires_at = Date.today + 7 # 1 Week from now + + deploy_token = Factory::Resource::DeployToken.fabricate! do |resource| + resource.name = deploy_token_name + resource.expires_at = deploy_token_expires_at + end + + expect(deploy_token.username.length).to be > 0 + expect(deploy_token.password.length).to be > 0 + end + end + end +end |