Commit 9a538b9e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Introduce Key namespace so we could put more keys

parent 8230b774
...@@ -11,9 +11,12 @@ module QA ...@@ -11,9 +11,12 @@ module QA
autoload :Scenario, 'qa/runtime/scenario' autoload :Scenario, 'qa/runtime/scenario'
autoload :Browser, 'qa/runtime/browser' autoload :Browser, 'qa/runtime/browser'
autoload :Env, 'qa/runtime/env' autoload :Env, 'qa/runtime/env'
autoload :RSAKey, 'qa/runtime/rsa_key'
autoload :Address, 'qa/runtime/address' autoload :Address, 'qa/runtime/address'
autoload :API, 'qa/runtime/api' autoload :API, 'qa/runtime/api'
module Key
autoload :RSA, 'qa/runtime/key/rsa'
end
end end
## ##
......
require 'net/ssh'
require 'forwardable'
module QA
module Runtime
module Key
class RSA
extend Forwardable
attr_reader :key
def_delegators :@key, :fingerprint, :to_pem
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
end
require 'net/ssh'
require 'forwardable'
module QA
module Runtime
class RSAKey
extend Forwardable
attr_reader :key
def_delegators :@key, :fingerprint, :to_pem
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
...@@ -4,7 +4,7 @@ module QA ...@@ -4,7 +4,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
key = Runtime::RSAKey.new key = Runtime::Key::RSA.new
deploy_key_title = 'deploy key title' deploy_key_title = 'deploy key title'
deploy_key_value = key.public_key deploy_key_value = key.public_key
......
...@@ -3,7 +3,7 @@ require 'digest/sha1' ...@@ -3,7 +3,7 @@ require 'digest/sha1'
module QA module QA
feature 'cloning code using a deploy key', :core, :docker do feature 'cloning code using a deploy key', :core, :docker do
let(:runner_name) { "qa-runner-#{Time.now.to_i}" } let(:runner_name) { "qa-runner-#{Time.now.to_i}" }
let(:key) { Runtime::RSAKey.new } let(:key) { Runtime::Key::RSA.new }
given(:project) do given(:project) do
Factory::Resource::Project.fabricate! do |resource| Factory::Resource::Project.fabricate! do |resource|
......
describe QA::Runtime::RSAKey do describe QA::Runtime::Key::RSA do
describe '#public_key' do describe '#public_key' do
subject { described_class.new.public_key } subject { described_class.new.public_key }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment