diff options
-rwxr-xr-x | spec/integration/indirector/certificate/rest.rb | 2 | ||||
-rwxr-xr-x | spec/integration/indirector/certificate_request/rest.rb | 2 | ||||
-rwxr-xr-x | spec/integration/indirector/certificate_revocation_list/rest.rb | 2 | ||||
-rw-r--r-- | spec/integration/indirector/report/rest.rb | 2 | ||||
-rwxr-xr-x | spec/integration/indirector/rest.rb | 7 | ||||
-rwxr-xr-x | spec/integration/network/server/mongrel.rb | 20 | ||||
-rwxr-xr-x | spec/integration/network/server/webrick.rb | 18 |
7 files changed, 42 insertions, 11 deletions
diff --git a/spec/integration/indirector/certificate/rest.rb b/spec/integration/indirector/certificate/rest.rb index 8512fa95a..3ebd1e5f7 100755 --- a/spec/integration/indirector/certificate/rest.rb +++ b/spec/integration/indirector/certificate/rest.rb @@ -35,7 +35,7 @@ describe "Certificate REST Terminus" do @host = Puppet::SSL::Host.new(Puppet[:certname]) - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :certificate ] } + @params = { :port => 34343, :handlers => [ :certificate ] } @server = Puppet::Network::Server.new(@params) @server.listen diff --git a/spec/integration/indirector/certificate_request/rest.rb b/spec/integration/indirector/certificate_request/rest.rb index a1dc5c017..211188ecc 100755 --- a/spec/integration/indirector/certificate_request/rest.rb +++ b/spec/integration/indirector/certificate_request/rest.rb @@ -40,7 +40,7 @@ describe "Certificate Request REST Terminus" do Puppet::SSL::Host.ca_location = :none Puppet::SSL::Host.destroy("foo.madstop.com") - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :certificate_request ] } + @params = { :port => 34343, :handlers => [ :certificate_request ] } @server = Puppet::Network::Server.new(@params) @server.listen diff --git a/spec/integration/indirector/certificate_revocation_list/rest.rb b/spec/integration/indirector/certificate_revocation_list/rest.rb index dce0cf05b..f308543f0 100755 --- a/spec/integration/indirector/certificate_revocation_list/rest.rb +++ b/spec/integration/indirector/certificate_revocation_list/rest.rb @@ -32,7 +32,7 @@ describe "Certificate REST Terminus" do ca = Puppet::SSL::CertificateAuthority.new ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :certificate_revocation_list ] } + @params = { :port => 34343, :handlers => [ :certificate_revocation_list ] } @server = Puppet::Network::Server.new(@params) @server.listen diff --git a/spec/integration/indirector/report/rest.rb b/spec/integration/indirector/report/rest.rb index 7903ac9fb..6525065a7 100644 --- a/spec/integration/indirector/report/rest.rb +++ b/spec/integration/indirector/report/rest.rb @@ -35,7 +35,7 @@ describe "Report REST Terminus" do @host = Puppet::SSL::Host.new(Puppet[:certname]) - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :report ] } + @params = { :port => 34343, :handlers => [ :report ] } @server = Puppet::Network::Server.new(@params) @server.listen diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb index ede073d45..26f3d60a8 100755 --- a/spec/integration/indirector/rest.rb +++ b/spec/integration/indirector/rest.rb @@ -32,9 +32,6 @@ end describe Puppet::Indirector::REST do before do - Puppet[:masterport] = 34343 - Puppet[:server] = "localhost" - # Get a safe temporary file @tmpfile = Tempfile.new("webrick_integration_testing") @dir = @tmpfile.path + "_dir" @@ -67,7 +64,7 @@ describe Puppet::Indirector::REST do ca = Puppet::SSL::CertificateAuthority.new ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :test_indirected_foo ], :xmlrpc_handlers => [ :status ] } + @params = { :port => 34343, :handlers => [ :test_indirected_foo ], :xmlrpc_handlers => [ :status ] } @server = Puppet::Network::Server.new(@params) @server.listen @@ -293,7 +290,7 @@ describe Puppet::Indirector::REST do before :each do Puppet[:servertype] = 'mongrel' - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :test_indirected_foo ] } + @params = { :port => 34343, :handlers => [ :test_indirected_foo ] } # Make sure we never get a cert, since mongrel can't speak ssl Puppet::SSL::Certificate.stubs(:find).returns nil diff --git a/spec/integration/network/server/mongrel.rb b/spec/integration/network/server/mongrel.rb index 180fdf7ad..d621220e2 100755 --- a/spec/integration/network/server/mongrel.rb +++ b/spec/integration/network/server/mongrel.rb @@ -10,10 +10,13 @@ describe Puppet::Network::Server do before :each do Puppet[:servertype] = 'mongrel' - @params = { :address => "127.0.0.1", :port => 34346, :handlers => [ :node ] } + Puppet[:server] = '127.0.0.1' + @params = { :port => 34346, :handlers => [ :node ] } @server = Puppet::Network::Server.new(@params) end + after { Puppet.settings.clear } + describe "before listening" do it "should not be reachable at the specified address and port" do lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED) @@ -26,6 +29,21 @@ describe Puppet::Network::Server do lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error end + it "should default to '127.0.0.1' as its bind address" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } + @server.listen + end + + it "should use any specified bind address" do + Puppet[:bindaddress] = "0.0.0.0" + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "0.0.0.0" } + @server.listen + end + it "should not allow multiple servers to listen on the same address and port" do @server.listen @server2 = Puppet::Network::Server.new(@params) diff --git a/spec/integration/network/server/webrick.rb b/spec/integration/network/server/webrick.rb index 5cd573141..06916573f 100755 --- a/spec/integration/network/server/webrick.rb +++ b/spec/integration/network/server/webrick.rb @@ -9,7 +9,8 @@ describe Puppet::Network::Server do describe "when using webrick" do before :each do Puppet[:servertype] = 'webrick' - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] } + Puppet[:server] = '127.0.0.1' + @params = { :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] } # Get a safe temporary file @tmpfile = Tempfile.new("webrick_integration_testing") @@ -46,6 +47,21 @@ describe Puppet::Network::Server do lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error end + it "should default to '0.0.0.0' as its bind address" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "0.0.0.0" } + @server.listen + end + + it "should use any specified bind address" do + Puppet[:bindaddress] = "127.0.0.1" + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } + @server.listen + end + it "should not allow multiple servers to listen on the same address and port" do @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) @server.listen |