mirror of
https://github.com/inspec/inspec
synced 2024-11-22 12:43:07 +00:00
use string for backend conf
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
21f0a37764
commit
f54fa6537a
3 changed files with 30 additions and 30 deletions
|
@ -15,14 +15,14 @@ module Vulcano
|
||||||
def self.target_config( config )
|
def self.target_config( config )
|
||||||
conf = config.dup
|
conf = config.dup
|
||||||
|
|
||||||
return conf if conf[:target].to_s.empty?
|
return conf if conf['target'].to_s.empty?
|
||||||
|
|
||||||
uri = URI::parse(conf[:target].to_s)
|
uri = URI::parse(conf['target'].to_s)
|
||||||
conf[:backend] = conf[:backend] || uri.scheme
|
conf['backend'] = conf['backend'] || uri.scheme
|
||||||
conf[:host] = conf[:host] || uri.host
|
conf['host'] = conf['host'] || uri.host
|
||||||
conf[:port] = conf[:port] || uri.port
|
conf['port'] = conf['port'] || uri.port
|
||||||
conf[:user] = conf[:user] || uri.user
|
conf['user'] = conf['user'] || uri.user
|
||||||
conf[:password] = conf[:password] || uri.password
|
conf['password'] = conf['password'] || uri.password
|
||||||
|
|
||||||
# return the updated config
|
# return the updated config
|
||||||
conf
|
conf
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Vulcano::Backends
|
||||||
def initialize(conf)
|
def initialize(conf)
|
||||||
@conf = conf
|
@conf = conf
|
||||||
@files = {}
|
@files = {}
|
||||||
type = @conf['backend']
|
type = @conf['backend'].to_s
|
||||||
|
|
||||||
configure_shared_options
|
configure_shared_options
|
||||||
|
|
||||||
|
|
|
@ -13,27 +13,27 @@ describe 'Vulcano::Backend' do
|
||||||
describe 'target config helper' do
|
describe 'target config helper' do
|
||||||
it 'configures resolves target' do
|
it 'configures resolves target' do
|
||||||
org = {
|
org = {
|
||||||
target: 'ssh://user:pass@host.com:123'
|
'target' => 'ssh://user:pass@host.com:123',
|
||||||
}
|
}
|
||||||
res = Vulcano::Backend.target_config(org)
|
res = Vulcano::Backend.target_config(org)
|
||||||
res[:backend].must_equal 'ssh'
|
res['backend'].must_equal 'ssh'
|
||||||
res[:host].must_equal 'host.com'
|
res['host'].must_equal 'host.com'
|
||||||
res[:user].must_equal 'user'
|
res['user'].must_equal 'user'
|
||||||
res[:password].must_equal 'pass'
|
res['password'].must_equal 'pass'
|
||||||
res[:port].must_equal 123
|
res['port'].must_equal 123
|
||||||
res[:target].must_equal org[:target]
|
res['target'].must_equal org['target']
|
||||||
org.keys.must_equal [:target]
|
org.keys.must_equal ['target']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'resolves a target while keeping existing fields' do
|
it 'resolves a target while keeping existing fields' do
|
||||||
org = {
|
org = {
|
||||||
target: 'ssh://user:pass@host.com:123',
|
'target' => 'ssh://user:pass@host.com:123',
|
||||||
backend: rand,
|
'backend' => rand,
|
||||||
host: rand,
|
'host' => rand,
|
||||||
user: rand,
|
'user' => rand,
|
||||||
password: rand,
|
'password' => rand,
|
||||||
port: rand,
|
'port' => rand,
|
||||||
target: rand,
|
'target' => rand,
|
||||||
}
|
}
|
||||||
res = Vulcano::Backend.target_config(org)
|
res = Vulcano::Backend.target_config(org)
|
||||||
res.must_equal org
|
res.must_equal org
|
||||||
|
@ -41,15 +41,15 @@ describe 'Vulcano::Backend' do
|
||||||
|
|
||||||
it 'keeps the configuration when incorrect target is supplied' do
|
it 'keeps the configuration when incorrect target is supplied' do
|
||||||
org = {
|
org = {
|
||||||
target: 'wrong',
|
'target' => 'wrong',
|
||||||
}
|
}
|
||||||
res = Vulcano::Backend.target_config(org)
|
res = Vulcano::Backend.target_config(org)
|
||||||
res[:backend].must_be_nil
|
res['backend'].must_be_nil
|
||||||
res[:host].must_be_nil
|
res['host'].must_be_nil
|
||||||
res[:user].must_be_nil
|
res['user'].must_be_nil
|
||||||
res[:password].must_be_nil
|
res['password'].must_be_nil
|
||||||
res[:port].must_be_nil
|
res['port'].must_be_nil
|
||||||
res[:target].must_equal org[:target]
|
res['target'].must_equal org['target']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue