mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
ssl resource to use inspec.backend.hostname and require train 0.19.1
This commit is contained in:
parent
913a8fdc40
commit
8a470c16f1
2 changed files with 10 additions and 12 deletions
|
@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||
spec.require_paths = ['lib']
|
||||
|
||||
spec.add_dependency 'train', '>=0.19.0', '<1.0'
|
||||
spec.add_dependency 'train', '>=0.19.1', '<1.0'
|
||||
spec.add_dependency 'thor', '~> 0.19'
|
||||
spec.add_dependency 'json', '>= 1.8', '< 3.0'
|
||||
spec.add_dependency 'rainbow', '~> 2'
|
||||
|
|
|
@ -44,18 +44,16 @@ class SSL < Inspec.resource(1)
|
|||
attr_reader :host, :port
|
||||
|
||||
def initialize(opts = {})
|
||||
@host = opts[:host] ||
|
||||
inspec.backend.instance_variable_get(:@hostname)
|
||||
# FIXME: This can be removed when/if @hostname is available as a property for 'Train::Transports::WinRM::Connection'
|
||||
# Train enhancement request for this here: https://github.com/chef/train/issues/128
|
||||
if @host.nil? && inspec.backend.class.to_s == 'Train::Transports::WinRM::Connection'
|
||||
@host = URI.parse(inspec.backend.instance_variable_get(:@options)[:endpoint]).hostname
|
||||
end
|
||||
if @host.nil? && inspec.backend.class.to_s == 'Train::Transports::Local::Connection'
|
||||
@host = 'localhost'
|
||||
end
|
||||
@host = opts[:host]
|
||||
if @host.nil?
|
||||
fail 'Cannot determine host for SSL test. Please specify it or use a different target.'
|
||||
# Transports like SSH and WinRM will provide a hostname
|
||||
if inspec.backend.respond_to?('hostname')
|
||||
@host = inspec.backend.hostname
|
||||
elsif inspec.backend.class.to_s == 'Train::Transports::Local::Connection'
|
||||
@host = 'localhost'
|
||||
else
|
||||
fail 'Cannot determine host for SSL test. Please specify it or use a different target.'
|
||||
end
|
||||
end
|
||||
@port = opts[:port] || 443
|
||||
@timeout = opts[:timeout]
|
||||
|
|
Loading…
Reference in a new issue