From 1c3dd604312b5a4358acc57db303fbd3ad882e23 Mon Sep 17 00:00:00 2001 From: Conor Horan-Kates Date: Mon, 8 Aug 2016 11:16:27 -0700 Subject: [PATCH 1/3] implementation fix for #89 --- lib/rouster/testing.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/rouster/testing.rb b/lib/rouster/testing.rb index 81028e8..0ac968a 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].has_key?(:address) + 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 From 7918751cf69d7ae30a6822106628627568d87e1e Mon Sep 17 00:00:00 2001 From: Conor Horan-Kates Date: Mon, 8 Aug 2016 11:21:15 -0700 Subject: [PATCH 2/3] adding tests, minor change to impl to correctly fix bug --- lib/rouster/testing.rb | 2 +- test/unit/testing/test_validate_port.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rouster/testing.rb b/lib/rouster/testing.rb index 0ac968a..34c4c86 100644 --- a/lib/rouster/testing.rb +++ b/lib/rouster/testing.rb @@ -581,7 +581,7 @@ def validate_port(number, expectations, fail_fast=false) when :address lr = Array.new - if ports[expectations[:protocol]][number].has_key?(:address) + if ports[expectations[:protocol]][number] addresses = ports[expectations[:protocol]][number][:address] addresses.each_key do |address| lr.push(address.eql?(v.to_s)) 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 From f9787ce2f7718103fe57f543b980890ac3f5305d Mon Sep 17 00:00:00 2001 From: Conor Horan-Kates Date: Thu, 25 Aug 2016 12:24:27 -0700 Subject: [PATCH 3/3] fixing unrelated bug that isn't 100% reproducible, but is a problem --- lib/rouster.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouster.rb b/lib/rouster.rb index 1b7d0af..b08ed6d 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