diff --git a/lib/rouster.rb b/lib/rouster.rb index e26cb67..7d62fdd 100644 --- a/lib/rouster.rb +++ b/lib/rouster.rb @@ -360,7 +360,7 @@ def is_available_via_ssh? if @ssh.nil? or @ssh.closed? begin res = self.connect_ssh_tunnel() - rescue Rouster::InternalError, Net::SSH::Disconnect, Errno::ECONNREFUSED => e + rescue Rouster::InternalError, Net::SSH::Disconnect, Errno::ECONNREFUSED, Errno::ECONNRESET => e res = false end diff --git a/lib/rouster/testing.rb b/lib/rouster/testing.rb index 81028e8..34c4c86 100644 --- a/lib/rouster/testing.rb +++ b/lib/rouster/testing.rb @@ -581,13 +581,17 @@ def validate_port(number, expectations, fail_fast=false) when :address lr = Array.new - addresses = ports[expectations[:protocol]][number][:address] - addresses.each_key do |address| - lr.push(address.eql?(v.to_s)) - end - - local = ! lr.find{|e| e.true? }.nil? # this feels jankity + if ports[expectations[:protocol]][number] + addresses = ports[expectations[:protocol]][number][:address] + addresses.each_key do |address| + lr.push(address.eql?(v.to_s)) + end + local = ! lr.find{|e| e.true? }.nil? # this feels jankity + else + # this port isn't open in the first place, won't match any addresses we expect to see it on + local = false + end else raise InternalError.new(sprintf('unknown expectation[%s / %s]', k, v)) end diff --git a/test/unit/testing/test_validate_port.rb b/test/unit/testing/test_validate_port.rb index 55a2be8..e4fd960 100644 --- a/test/unit/testing/test_validate_port.rb +++ b/test/unit/testing/test_validate_port.rb @@ -91,6 +91,11 @@ def test_negative_constrained end + def test_negative_port_dne + assert_equal(false, @app.validate_port(4567, { :ensure => true, :address => '*' })) + assert_equal(false, @app.validate_port(4567, { :ensure => true, :address => '127.0.0.1' })) + end + def teardown # noop end