summaryrefslogtreecommitdiffstats
path: root/spec/integration
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-06-14 13:53:56 -0500
committerLuke Kanies <luke@madstop.com>2008-06-14 13:53:56 -0500
commit6a61198f9293674a4bf0aa75bfbca10e20f64d20 (patch)
tree0b1b6c4ffe6e69c3c9d3e9650620e3afbd486f18 /spec/integration
parenteaa6eabc680cb6264594e30fd6a56e3e36765269 (diff)
parent7b2c310e18b214424ae082e6ed2354a07b708c6f (diff)
Merge branch '0.24.x'
Also added the fixes to make the certhandler tests pass even when certs exist; I'll deal with the conflict later. Conflicts: CHANGELOG bin/puppetd lib/puppet/network/http/handler.rb lib/puppet/network/http/mongrel/rest.rb spec/integration/indirector/rest.rb spec/integration/network/server/mongrel.rb spec/integration/network/server/webrick.rb spec/unit/network/http/webrick.rb
Diffstat (limited to 'spec/integration')
-rwxr-xr-xspec/integration/indirector/rest.rb33
-rwxr-xr-xspec/integration/network/server/mongrel.rb74
-rwxr-xr-xspec/integration/network/server/webrick.rb6
3 files changed, 60 insertions, 53 deletions
diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb
index 859648f7d..584fedde0 100755
--- a/spec/integration/indirector/rest.rb
+++ b/spec/integration/indirector/rest.rb
@@ -29,8 +29,6 @@ end
class Puppet::TestIndirectedFoo::Rest < Puppet::Indirector::REST
end
-# This way the retrieval of the class by name works.
-Puppet::Indirector::Terminus.register_terminus_class(Puppet::TestIndirectedFoo::Rest)
describe Puppet::Indirector::REST do
before do
@@ -65,18 +63,11 @@ 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 ] }
@server = Puppet::Network::Server.new(@params)
@server.listen
end
-
- after do
- @server.unlisten
- @tmpfile.delete
- Puppet.settings.clear
- Puppet::Util::Cacher.invalidate
- end
describe "when finding a model instance over REST" do
describe "when a matching model instance can be found" do
@@ -87,7 +78,6 @@ describe Puppet::Indirector::REST do
end
it "should not fail" do
- Puppet::TestIndirectedFoo.find('bar')
lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error
end
@@ -151,7 +141,15 @@ describe Puppet::Indirector::REST do
end
it 'should return the instance of the model class associated with the provided lookup key' do
- Puppet::TestIndirectedFoo.search('bar').collect{ |x| x.value }.should == @model_instances.collect{ |x| x.value }
+ Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
+ end
+
+ it 'should set a version timestamp on model instances' do
+ pending("Luke looking at why this version magic might not be working") do
+ Puppet::TestIndirectedFoo.search('bar').each do |result|
+ result.version.should_not be_nil
+ end
+ end
end
end
@@ -264,6 +262,10 @@ describe Puppet::Indirector::REST do
end
end
end
+
+ after :each do
+ @server.unlisten
+ end
end
describe "when using mongrel" do
@@ -283,7 +285,7 @@ describe Puppet::Indirector::REST do
@server.listen
end
- after :each do
+ after do
@server.unlisten
end
@@ -359,7 +361,7 @@ describe Puppet::Indirector::REST do
end
it 'should return the instance of the model class associated with the provided lookup key' do
- Puppet::TestIndirectedFoo.search('bar').collect{ |x| x.value }.should == @model_instances.collect{ |x| x.value }
+ Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
end
it 'should set an expiration on model instances' do
@@ -438,6 +440,9 @@ describe Puppet::Indirector::REST do
@instance = Puppet::TestIndirectedFoo.new(42)
@mock_model = stub('faked model', :from_yaml => @instance)
Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model)
+
+ # LAK:NOTE This stub is necessary to prevent the REST call from calling
+ # REST.save again, thus producing painful infinite recursion.
Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).returns(@instance)
end
diff --git a/spec/integration/network/server/mongrel.rb b/spec/integration/network/server/mongrel.rb
index 08fd49b17..180fdf7ad 100755
--- a/spec/integration/network/server/mongrel.rb
+++ b/spec/integration/network/server/mongrel.rb
@@ -1,46 +1,48 @@
+#!/usr/bin/env ruby
+
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/network/server'
require 'socket'
describe Puppet::Network::Server do
- describe "when using mongrel" do
- confine "Mongrel is not available" => Puppet.features.mongrel?
-
- before :each do
- Puppet[:servertype] = 'mongrel'
- @params = { :address => "127.0.0.1", :port => 34346, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] }
- @server = Puppet::Network::Server.new(@params)
- end
+ describe "when using mongrel" do
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
+ before :each do
+ Puppet[:servertype] = 'mongrel'
+ @params = { :address => "127.0.0.1", :port => 34346, :handlers => [ :node ] }
+ @server = Puppet::Network::Server.new(@params)
+ end
- 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)
- end
- end
+ 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)
+ end
+ end
- describe "when listening" do
- it "should be reachable on the specified address and port" do
- @server.listen
- lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error
- end
+ describe "when listening" do
+ it "should be reachable on the specified address and port" do
+ @server.listen
+ lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error
+ end
- it "should not allow multiple servers to listen on the same address and port" do
- @server.listen
- @server2 = Puppet::Network::Server.new(@params)
- lambda { @server2.listen }.should raise_error
- end
- end
-
- describe "after unlistening" do
- it "should not be reachable on the port and address assigned" do
- @server.listen
- @server.unlisten
- lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)
- end
+ it "should not allow multiple servers to listen on the same address and port" do
+ @server.listen
+ @server2 = Puppet::Network::Server.new(@params)
+ lambda { @server2.listen }.should raise_error
+ end
+ end
+
+ describe "after unlistening" do
+ it "should not be reachable on the port and address assigned" do
+ @server.listen
+ @server.unlisten
+ lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)
+ end
+ end
+
+ after :each do
+ @server.unlisten if @server.listening?
+ end
end
-
- after :each do
- @server.unlisten if @server.listening?
- end
- end
end
diff --git a/spec/integration/network/server/webrick.rb b/spec/integration/network/server/webrick.rb
index 0e66ee955..e74920782 100755
--- a/spec/integration/network/server/webrick.rb
+++ b/spec/integration/network/server/webrick.rb
@@ -41,13 +41,13 @@ describe Puppet::Network::Server do
describe "when listening" do
it "should be reachable on the specified address and port" do
- @server = Puppet::Network::Server.new(@params.merge(:port => 34343))
+ @server = Puppet::Network::Server.new(@params.merge(:port => 34343))
@server.listen
- lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error
+ lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error
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 = Puppet::Network::Server.new(@params.merge(:port => 34343))
@server.listen
@server2 = Puppet::Network::Server.new(@params.merge(:port => 34343))
lambda { @server2.listen }.should raise_error