diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 23:25:18 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-02-12 23:49:09 +0800 |
commit | 565fdd63cf49c266c7a6a2a0d2a843339a9d30e6 (patch) | |
tree | 3567619e22cdf16df541c67aaf6f7809d8f4e14b /qa/qa/specs/features/project | |
parent | 2f34ef34fa230c1954e47504cd8ead1a6ab019fe (diff) | |
download | gitlab-ce-565fdd63cf49c266c7a6a2a0d2a843339a9d30e6.tar.gz |
Rearrange the test structure and introduce
a new repository location class.
Diffstat (limited to 'qa/qa/specs/features/project')
-rw-r--r-- | qa/qa/specs/features/project/deploy_key_clone_spec.rb | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 297e677175f..9b4897a1f96 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -3,71 +3,86 @@ require 'digest/sha1' module QA feature 'cloning code using a deploy key', :core, :docker do let(:runner_name) { "qa-runner-#{Time.now.to_i}" } + let(:key) { Runtime::RSAKey.new } - after do - Service::Runner.new(runner_name).remove! - end - - scenario 'user sets up a deploy key to clone code using pipelines' do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } - - project = Factory::Resource::Project.fabricate! do |resource| + given(:project) do + Factory::Resource::Project.fabricate! do |resource| resource.name = 'deploy-key-clone-project' end + end - Factory::Resource::Runner.fabricate! do |runner| - runner.project = project - runner.name = runner_name - runner.tags = %w[qa docker] - runner.image = 'gitlab/gitlab-runner:ubuntu' + def fabricate_runner + Factory::Resource::Runner.fabricate! do |resource| + resource.project = project + resource.name = runner_name + resource.tags = %w[qa docker] + resource.image = 'gitlab/gitlab-runner:ubuntu' end + end - key = Runtime::RSAKey.new - + def fabricate_deploy_key Factory::Resource::DeployKey.fabricate! do |resource| resource.project = project resource.title = 'deploy key title' resource.key = key.public_key end + end + def fabricate_secret_variable Factory::Resource::SecretVariable.fabricate! do |resource| resource.project = project resource.key = 'DEPLOY_KEY' resource.value = key.to_pem end + end - project.visit! - - repository_url = Page::Project::Show.act do + def fabricate_gitlab_ci + repository_uri = Page::Project::Show.act do choose_repository_clone_ssh - repository_location + repository_location_uri end - repository_uri = Git::Repository.parse_uri(repository_url) - - gitlab_ci = <<~YAML + <<~YAML cat-config: script: - mkdir -p ~/.ssh - - ssh-keyscan -p #{repository_uri.port || 22} #{repository_uri.host} >> ~/.ssh/known_hosts + - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts - eval $(ssh-agent -s) - echo "$DEPLOY_KEY" | ssh-add - - - git clone #{repository_url} + - git clone #{repository_uri.git_uri} - sha1sum #{project.name}/.gitlab-ci.yml tags: - qa - docker YAML + end - sha1sum = Digest::SHA1.hexdigest(gitlab_ci) - - Factory::Repository::Push.fabricate! do |push| - push.project = project - push.file_name = '.gitlab-ci.yml' - push.commit_message = 'Add .gitlab-ci.yml' - push.file_content = gitlab_ci + def fabricate_push(gitlab_ci) + Factory::Repository::Push.fabricate! do |resource| + resource.project = project + resource.file_name = '.gitlab-ci.yml' + resource.commit_message = 'Add .gitlab-ci.yml' + resource.file_content = gitlab_ci end + end + + after do + Service::Runner.new(runner_name).remove! + end + + scenario 'user sets up a deploy key to clone code using pipelines' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + + fabricate_runner + fabricate_deploy_key + fabricate_secret_variable + + project.visit! + + gitlab_ci = fabricate_gitlab_ci + fabricate_push(gitlab_ci) + sha1sum = Digest::SHA1.hexdigest(gitlab_ci) Page::Project::Show.act { wait_for_push } Page::Menu::Side.act { click_ci_cd_pipelines } |