diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-01-25 17:35:56 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-01-25 17:35:56 +0300 |
commit | 7d26eddeceb485e0baa2913b01438ae70344b94f (patch) | |
tree | e5c250ef6403461b8895d47bf2a9e6cd020ad3ac /qa | |
parent | 3d4a7f63cbf197465fa556ece387b57f57176d10 (diff) | |
parent | 9df130ff2291849bc345494f78cb239fb300d59d (diff) |
Merge remote-tracking branch 'upstream/master' into qa-secret-variables-scenario
* upstream/master:
Make Gitaly RepositoryExists opt-out
Fix .batch_lfs_pointers accepting a lazy enumerator
Look at notes created just before merge when deciding if an MR can be reverted
Update missing paths
Default to HTTPS for all Gravatar URLs
Add note within ux documentation that further changes should be made within the design.gitlab project
Moves status icon into a vue file and adds tests Moves merging component into a vue file, adds i18n and better test cases
Prefer local variables instead
Add an test for QA::Runtime::RSAKey
Move initialize method later.
Also test if the fingerprint is correct
Generate ssh key on the fly for QA
Diffstat (limited to 'qa')
-rw-r--r-- | qa/Gemfile | 1 | ||||
-rw-r--r-- | qa/Gemfile.lock | 2 | ||||
-rw-r--r-- | qa/qa.rb | 1 | ||||
-rw-r--r-- | qa/qa/factory/resource/deploy_key.rb | 6 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 16 | ||||
-rw-r--r-- | qa/qa/page/project/settings/deploy_keys.rb | 22 | ||||
-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 | 8 | ||||
-rw-r--r-- | qa/spec/runtime/rsa_key.rb | 9 |
10 files changed, 78 insertions, 19 deletions
diff --git a/qa/Gemfile b/qa/Gemfile index d69c71003ae..c3e61568f3d 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -6,4 +6,5 @@ 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 gem 'airborne', '~> 0.2.13' diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index 565adac7499..51d2e4d7a10 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -46,6 +46,7 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.1) + net-ssh (4.1.0) netrc (0.11.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) @@ -97,6 +98,7 @@ DEPENDENCIES airborne (~> 0.2.13) capybara (~> 2.16.1) capybara-screenshot (~> 1.0.18) + net-ssh pry-byebug (~> 3.5.1) rake (~> 12.3.0) rspec (~> 3.7) @@ -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' autoload :Address, 'qa/runtime/address' autoload :API, 'qa/runtime/api' end diff --git a/qa/qa/factory/resource/deploy_key.rb b/qa/qa/factory/resource/deploy_key.rb index 25d2af6e321..ff0b4a46b77 100644 --- a/qa/qa/factory/resource/deploy_key.rb +++ b/qa/qa/factory/resource/deploy_key.rb @@ -10,6 +10,12 @@ module QA end end + product :fingerprint do + Page::Project::Settings::Repository.act do + expand_deploy_keys(&:key_fingerprint) + end + end + dependency Factory::Resource::Project, as: :project do |project| project.name = 'project-to-deploy' project.description = 'project for adding deploy key test' diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index ea4c920c82c..81ba80cdbaf 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -41,7 +41,21 @@ module QA end def click_element(name) - find(Page::Element.new(name).selector_css).click + find_element(name).click + end + + def find_element(name) + find(element_selector_css(name)) + end + + def within_element(name) + page.within(element_selector_css(name)) do + yield + end + end + + def element_selector_css(name) + Page::Element.new(name).selector_css end def self.path diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb index f9e40bf4252..332e84724c7 100644 --- a/qa/qa/page/project/settings/deploy_keys.rb +++ b/qa/qa/page/project/settings/deploy_keys.rb @@ -14,8 +14,8 @@ module QA end view 'app/assets/javascripts/deploy_keys/components/key.vue' do - element :key_title, /class=".*title.*"/ - element :key_title_field, '{{ deployKey.title }}' + element :key_title, /class=".*qa-key-title.*"/ + element :key_fingerprint, /class=".*qa-key-fingerprint.*"/ end def fill_key_title(title) @@ -31,8 +31,22 @@ module QA end def key_title - page.within('.qa-project-deploy-keys') do - page.find('.title').text + within_project_deploy_keys do + find_element(:key_title).text + end + end + + def key_fingerprint + within_project_deploy_keys do + find_element(:key_fingerprint).text + end + end + + private + + def within_project_deploy_keys + within_element(:project_deploy_keys) do + yield end end end diff --git a/qa/qa/runtime/rsa_key.rb b/qa/qa/runtime/rsa_key.rb new file mode 100644 index 00000000000..d456062bce7 --- /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 + + attr_reader :key + def_delegators :@key, :fingerprint + + def initialize(bits = 4096) + @key = OpenSSL::PKey::RSA.new(bits) + end + + 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 7a123e539e1..b9998dda895 100644 --- a/qa/qa/specs/features/project/add_deploy_key_spec.rb +++ b/qa/qa/specs/features/project/add_deploy_key_spec.rb @@ -1,18 +1,20 @@ 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 } + key = Runtime::RSAKey.new + deploy_key_title = 'deploy key title' + deploy_key_value = key.public_key + deploy_key = Factory::Resource::DeployKey.fabricate! do |resource| resource.title = deploy_key_title resource.key = deploy_key_value end expect(deploy_key.title).to eq(deploy_key_title) + expect(deploy_key.fingerprint).to eq(key.fingerprint) end end end diff --git a/qa/spec/runtime/rsa_key.rb b/qa/spec/runtime/rsa_key.rb new file mode 100644 index 00000000000..ff277b9077b --- /dev/null +++ b/qa/spec/runtime/rsa_key.rb @@ -0,0 +1,9 @@ +describe QA::Runtime::RSAKey do + describe '#public_key' do + subject { described_class.new.public_key } + + it 'generates a public RSA key' do + expect(subject).to match(/\Assh\-rsa AAAA[0-9A-Za-z+\/]+={0,3}\z/) + end + end +end |