diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-01-18 20:07:37 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-01-22 10:41:52 +0300 |
commit | ccceb26617a28ee6acda0d46a3997428c9f7e56a (patch) | |
tree | 6ad1eded0cc56de5d551b04444f8cc4114960279 /qa | |
parent | ba02e3a5dfb0fb95a1a32b81e893b6fe2ea39b9e (diff) |
Generate ssh key on the fly for QA
Diffstat (limited to 'qa')
-rw-r--r-- | qa/Gemfile | 1 | ||||
-rw-r--r-- | qa/Gemfile.lock | 4 | ||||
-rw-r--r-- | qa/qa.rb | 1 | ||||
-rw-r--r-- | qa/qa/runtime/rsa_key.rb | 21 | ||||
-rw-r--r-- | qa/qa/runtime/user.rb | 11 | ||||
-rw-r--r-- | qa/qa/specs/features/project/add_deploy_key_spec.rb | 2 |
6 files changed, 27 insertions, 13 deletions
diff --git a/qa/Gemfile b/qa/Gemfile index 4c866a3f893..1cc40f2d2d0 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -6,3 +6,4 @@ gem 'capybara-screenshot', '~> 1.0.18' gem 'rake', '~> 12.3.0' gem 'rspec', '~> 3.7' gem 'selenium-webdriver', '~> 3.8.0' +gem 'net-ssh', require: false diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index 88d5fe834a0..7aa442b8c8e 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -24,6 +24,7 @@ GEM method_source (0.9.0) mini_mime (1.0.0) mini_portile2 (2.3.0) + net-ssh (4.1.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) pry (0.11.3) @@ -63,10 +64,11 @@ PLATFORMS DEPENDENCIES capybara (~> 2.16.1) capybara-screenshot (~> 1.0.18) + net-ssh pry-byebug (~> 3.5.1) rake (~> 12.3.0) rspec (~> 3.7) selenium-webdriver (~> 3.8.0) BUNDLED WITH - 1.16.0 + 1.16.1 @@ -11,6 +11,7 @@ module QA autoload :Scenario, 'qa/runtime/scenario' autoload :Browser, 'qa/runtime/browser' autoload :Env, 'qa/runtime/env' + autoload :RSAKey, 'qa/runtime/rsa_key' end ## diff --git a/qa/qa/runtime/rsa_key.rb b/qa/qa/runtime/rsa_key.rb new file mode 100644 index 00000000000..e9b6ea66dbd --- /dev/null +++ b/qa/qa/runtime/rsa_key.rb @@ -0,0 +1,21 @@ +require 'net/ssh' +require 'forwardable' + +module QA + module Runtime + class RSAKey + extend Forwardable + + def initialize(bits = 4096) + @key = OpenSSL::PKey::RSA.new(bits) + end + + attr_reader :key + def_delegators :@key, :fingerprint + + def public_key + @public_key ||= "#{key.ssh_type} #{[key.to_blob].pack('m0')}" + end + end + end +end diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb index 2832439d9e0..60027c89ab1 100644 --- a/qa/qa/runtime/user.rb +++ b/qa/qa/runtime/user.rb @@ -10,17 +10,6 @@ module QA def password ENV['GITLAB_PASSWORD'] || '5iveL!fe' end - - def ssh_key - <<~KEY.delete("\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 diff --git a/qa/qa/specs/features/project/add_deploy_key_spec.rb b/qa/qa/specs/features/project/add_deploy_key_spec.rb index 43a85213501..abff641ccce 100644 --- a/qa/qa/specs/features/project/add_deploy_key_spec.rb +++ b/qa/qa/specs/features/project/add_deploy_key_spec.rb @@ -1,7 +1,7 @@ module QA feature 'deploy keys support', :core do given(:deploy_key_title) { 'deploy key title' } - given(:deploy_key_value) { Runtime::User.ssh_key } + given(:deploy_key_value) { Runtime::RSAKey.new.public_key } scenario 'user adds a deploy key' do Runtime::Browser.visit(:gitlab, Page::Main::Login) |