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.' desc: 'Login password for a remote scan, if required.'
option :key, type: :string, default: nil, option :key, type: :string, default: nil,
desc: 'Login key or certificate file for a remote scan.' 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, option :disable_sudo, type: :boolean, default: false,
desc: 'To not run remote scans via sudo.' desc: 'To not run remote scans via sudo.'
option :sudo_password, type: :string, default: nil, option :sudo_password, type: :string, default: nil,

View file

@ -24,11 +24,14 @@ module Vulcano
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 unless uri.host.nil? and uri.scheme.nil?
conf['host'] = conf['host'] || uri.host conf['backend'] ||= uri.scheme
conf['port'] = conf['port'] || uri.port conf['host'] ||= uri.host
conf['user'] = conf['user'] || uri.user conf['port'] ||= uri.port
conf['password'] = conf['password'] || uri.password conf['user'] ||= uri.user
conf['password'] ||= uri.password
conf['path'] ||= uri.path
end
# return the updated config # return the updated config
conf conf

View file

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

View file

@ -16,7 +16,7 @@ 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/path',
} }
res = Vulcano::Backend.target_config(org) res = Vulcano::Backend.target_config(org)
res['backend'].must_equal 'ssh' res['backend'].must_equal 'ssh'
@ -25,17 +25,19 @@ describe 'Vulcano::Backend' do
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']
res['path'].must_equal '/path'
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/path',
'backend' => rand, 'backend' => rand,
'host' => rand, 'host' => rand,
'user' => rand, 'user' => rand,
'password' => rand, 'password' => rand,
'port' => rand, 'port' => rand,
'path' => rand
} }
res = Vulcano::Backend.target_config(org) res = Vulcano::Backend.target_config(org)
res.must_equal org res.must_equal org
@ -51,6 +53,7 @@ describe 'Vulcano::Backend' do
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['path'].must_be_nil
res['target'].must_equal org['target'] res['target'].must_equal org['target']
end end
end end