mirror of
https://github.com/inspec/inspec
synced 2024-09-21 06:51:56 +00:00
Raises error for Connection error.
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
b4ccc15121
commit
13fa3e930d
2 changed files with 7 additions and 1 deletions
|
@ -73,6 +73,11 @@ module Inspec::Resources
|
|||
protocol: proto, ciphers: e.map(&:cipher),
|
||||
timeout: x.resource.timeout, retries: x.resource.retries, servername: x.resource.host)]
|
||||
end
|
||||
|
||||
if !res[0].empty? && res[0][1].key?("error") && res[0][1]["error"].include?("Connection error Errno::ECONNREFUSED")
|
||||
raise "#{res[0][1]["error"]}"
|
||||
end
|
||||
|
||||
Hash[res]
|
||||
end
|
||||
.install_filter_methods_on_resource(self, :scan_config)
|
||||
|
|
|
@ -42,7 +42,8 @@ describe "Inspec::Resources::SSL" do
|
|||
it "verify host unreachable" do
|
||||
SSLShake.expects(:hello).at_least_once.returns({ "error" => "Connection error Errno::ECONNREFUSED, can't connect to localhost:443." })
|
||||
resource = load_resource("ssl", host: "localhost")
|
||||
_(resource.enabled?).must_equal false
|
||||
err = _ { resource.enabled? }.must_raise(RuntimeError)
|
||||
_(err.message).must_equal "Connection error Errno::ECONNREFUSED, can't connect to localhost:443."
|
||||
end
|
||||
|
||||
it "error with nil host" do
|
||||
|
|
Loading…
Reference in a new issue