Merge pull request #63 from chef/winrm-path

Merged change 44e998f6-a6be-44aa-8803-ee057a613d0b

From review branch winrm-path into master

Signed-off-by: chartmann <chartmann@chef.io>
This commit is contained in:
chef-delivery 2015-10-03 16:07:47 -07:00
commit 76996144d2
4 changed files with 19 additions and 8 deletions

View file

@ -57,6 +57,8 @@ class VulcanoCLI < Thor
desc: 'Login password for a remote scan, if required.'
option :key, type: :string, default: nil,
desc: 'Login key or certificate file for a remote scan.'
option :path, type: :string, default: nil,
desc: 'Login path to use in connectin to the target.'
option :disable_sudo, type: :boolean, default: false,
desc: 'To not run remote scans via sudo.'
option :sudo_password, type: :string, default: nil,

View file

@ -24,11 +24,14 @@ module Vulcano
return conf if conf['target'].to_s.empty?
uri = URI.parse(conf['target'].to_s)
conf['backend'] = conf['backend'] || uri.scheme
conf['host'] = conf['host'] || uri.host
conf['port'] = conf['port'] || uri.port
conf['user'] = conf['user'] || uri.user
conf['password'] = conf['password'] || uri.password
unless uri.host.nil? and uri.scheme.nil?
conf['backend'] ||= uri.scheme
conf['host'] ||= uri.host
conf['port'] ||= uri.port
conf['user'] ||= uri.user
conf['password'] ||= uri.password
conf['path'] ||= uri.path
end
# return the updated config
conf

View file

@ -18,7 +18,10 @@ class Vulcano::Backends::SpecinfraHelper
port ||= 5985
end
"#{scheme}://#{host}:#{port}/wsman"
path = conf['path'] || '/wsman'
path.prepend('/') unless path.start_with?('/')
"#{scheme}://#{host}:#{port}#{path}"
end
def self.configure(conf)

View file

@ -16,7 +16,7 @@ describe 'Vulcano::Backend' do
describe 'target config helper' do
it 'configures resolves target' do
org = {
'target' => 'ssh://user:pass@host.com:123',
'target' => 'ssh://user:pass@host.com:123/path',
}
res = Vulcano::Backend.target_config(org)
res['backend'].must_equal 'ssh'
@ -25,17 +25,19 @@ describe 'Vulcano::Backend' do
res['password'].must_equal 'pass'
res['port'].must_equal 123
res['target'].must_equal org['target']
res['path'].must_equal '/path'
org.keys.must_equal ['target']
end
it 'resolves a target while keeping existing fields' do
org = {
'target' => 'ssh://user:pass@host.com:123',
'target' => 'ssh://user:pass@host.com:123/path',
'backend' => rand,
'host' => rand,
'user' => rand,
'password' => rand,
'port' => rand,
'path' => rand
}
res = Vulcano::Backend.target_config(org)
res.must_equal org
@ -51,6 +53,7 @@ describe 'Vulcano::Backend' do
res['user'].must_be_nil
res['password'].must_be_nil
res['port'].must_be_nil
res['path'].must_be_nil
res['target'].must_equal org['target']
end
end