diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-03-09 20:14:27 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-03-29 19:40:32 +0800 |
commit | 1783a3d510d19d0cc906290f4ec82806319a97d1 (patch) | |
tree | 48f7d8c2f1462e217586f3018bb451f8151884eb /qa | |
parent | 211b2f390c3311f5880b3de6a2fb16f7865ebaae (diff) | |
download | gitlab-ce-1783a3d510d19d0cc906290f4ec82806319a97d1.tar.gz |
Run through all kinds of ssh keys for deploy key
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/runtime/key/base.rb | 5 | ||||
-rw-r--r-- | qa/qa/specs/features/project/deploy_key_clone_spec.rb | 114 |
2 files changed, 67 insertions, 52 deletions
diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb index 85f339033e5..0f74d314c56 100644 --- a/qa/qa/runtime/key/base.rb +++ b/qa/qa/runtime/key/base.rb @@ -2,9 +2,12 @@ module QA module Runtime module Key class Base - attr_reader :private_key, :public_key, :fingerprint + attr_reader :name, :bits, :private_key, :public_key, :fingerprint def initialize(name, bits) + @name = name + @bits = bits + Dir.mktmpdir do |dir| path = "#{dir}/id_#{name}" 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 0e240bf9029..c5428fee0d5 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -3,7 +3,6 @@ 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::Key::RSA.new } given(:project) do Factory::Resource::Project.fabricate! do |resource| @@ -15,66 +14,79 @@ module QA 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 } + keys = [ + Runtime::Key::RSA.new(2048), + Runtime::Key::RSA.new(4096), + Runtime::Key::RSA.new(8192), + Runtime::Key::DSA.new, + Runtime::Key::ECDSA.new(256), + Runtime::Key::ECDSA.new(384), + Runtime::Key::ECDSA.new(521), + Runtime::Key::ED25519.new + ] - 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 + keys.each do |key| + scenario "user sets up a deploy key with #{key.name}(#{key.bits}) to clone code using pipelines" do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } - Factory::Resource::DeployKey.fabricate! do |resource| - resource.project = project - resource.title = 'deploy key title' - resource.key = key.public_key - end + 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 - Factory::Resource::SecretVariable.fabricate! do |resource| - resource.project = project - resource.key = 'DEPLOY_KEY' - resource.value = key.private_key - end + Factory::Resource::DeployKey.fabricate! do |resource| + resource.project = project + resource.title = 'deploy key title' + resource.key = key.public_key + end - project.visit! + Factory::Resource::SecretVariable.fabricate! do |resource| + resource.project = project + resource.key = 'DEPLOY_KEY' + resource.value = key.private_key + end - repository_uri = Page::Project::Show.act do - choose_repository_clone_ssh - repository_location_uri - end + project.visit! - gitlab_ci = <<~YAML - cat-config: - script: - - mkdir -p ~/.ssh - - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts - - eval $(ssh-agent -s) - - echo "$DEPLOY_KEY" | ssh-add - - - git clone #{repository_uri.git_uri} - - sha1sum #{project.name}/.gitlab-ci.yml - tags: - - qa - - docker - YAML + repository_uri = Page::Project::Show.act do + choose_repository_clone_ssh + repository_location_uri + end - 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 + gitlab_ci = <<~YAML + cat-config: + script: + - mkdir -p ~/.ssh + - ssh-keyscan -p #{repository_uri.port} #{repository_uri.host} >> ~/.ssh/known_hosts + - eval $(ssh-agent -s) + - echo "$DEPLOY_KEY" | ssh-add - + - git clone #{repository_uri.git_uri} + - sha1sum #{project.name}/.gitlab-ci.yml + tags: + - qa + - docker + YAML + + 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 - sha1sum = Digest::SHA1.hexdigest(gitlab_ci) + sha1sum = Digest::SHA1.hexdigest(gitlab_ci) - Page::Project::Show.act { wait_for_push } - Page::Menu::Side.act { click_ci_cd_pipelines } - Page::Project::Pipeline::Index.act { go_to_latest_pipeline } - Page::Project::Pipeline::Show.act { go_to_first_job } + Page::Project::Show.act { wait_for_push } + Page::Menu::Side.act { click_ci_cd_pipelines } + Page::Project::Pipeline::Index.act { go_to_latest_pipeline } + Page::Project::Pipeline::Show.act { go_to_first_job } - Page::Project::Job::Show.perform do |job| - expect(job.output).to include(sha1sum) + Page::Project::Job::Show.perform do |job| + expect(job.output).to include(sha1sum) + end end end end |