diff options
21 files changed, 660 insertions, 591 deletions
diff --git a/lib/puppet/executables/client/certhandler.rb b/lib/puppet/executables/client/certhandler.rb index d2ead3950..b041397ae 100644 --- a/lib/puppet/executables/client/certhandler.rb +++ b/lib/puppet/executables/client/certhandler.rb @@ -4,13 +4,21 @@ module Puppet module Client class CertHandler attr_writer :wait_for_cert, :one_time + attr_reader :new_cert def initialize(wait_time, is_one_time) @wait_for_cert = wait_time @one_time = is_one_time @new_cert = false end + + # Did we just read a cert? + def new_cert? + new_cert + end + # Read, or retrieve if necessary, our certificate. Returns true if we retrieved + # a new cert, false if the cert already exists. def read_retrieve #NOTE: ACS this is checking that a file exists, maybe next time just do that? unless read_cert @@ -19,7 +27,7 @@ module Puppet retrieve_cert end - !@new_cert + ! new_cert? end def retrieve_cert @@ -46,13 +54,14 @@ module Puppet end def read_cert - Puppet::Network::HttpPool.read_cert + Puppet::Network::HttpPool.read_cert end def read_new_cert if Puppet::Network::HttpPool.read_cert # If we read it in, then we need to get rid of our existing http connection. - # The @new_cert flag will help us do that + # The @new_cert flag will help us do that, in that it provides a way + # to notify that the cert status has changed. @new_cert = true Puppet.notice "Got signed certificate" else diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 8c6abde8a..3c14c8a40 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -48,10 +48,16 @@ module Puppet::Network::HTTP::Handler raise ArgumentError, "No data to save" if !data or data.empty? args = params(request) obj = model.from_yaml(data) - result = obj.save(args).to_yaml + result = save_object(obj, args).to_yaml encode_result(request, response, result) end + # LAK:NOTE This has to be here for testing; it's a stub-point so + # we keep infinite recursion from happening. + def save_object(object, args) + object.save(args) + end + def do_exception(request, response, exception, status=404) encode_result(request, response, exception.to_yaml, status) end diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb index d1257d5cb..520ad67f0 100644 --- a/lib/puppet/network/http/mongrel/rest.rb +++ b/lib/puppet/network/http/mongrel/rest.rb @@ -2,7 +2,7 @@ require 'puppet/network/http/handler' class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler - include Puppet::Network::HTTP::Handler + include Puppet::Network::HTTP::Handler def initialize(args={}) super() diff --git a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb index 71ee6aeed..d1035b0db 100644 --- a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +++ b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb @@ -1,17 +1,17 @@ class AddCreatedAtToAllTables < ActiveRecord::Migration - def self.up - ActiveRecord::Base.connection.tables.each do |t| - unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") - add_column t.to_s, :created_at, :datetime - end - end - end + def self.up + ActiveRecord::Base.connection.tables.each do |t| + unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") + add_column t.to_s, :created_at, :datetime + end + end + end - def self.down - ActiveRecord::Base.connection.tables.each do |t| - unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") - remove_column t.to_s, :created_at - end - end - end + def self.down + ActiveRecord::Base.connection.tables.each do |t| + unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") + remove_column t.to_s, :created_at + end + end + end end diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb index cafcce713..7edd0b865 100644..100755 --- a/spec/integration/indirector/rest.rb +++ b/spec/integration/indirector/rest.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/network/server' require 'puppet/indirector' @@ -5,22 +7,22 @@ require 'puppet/indirector/rest' # a fake class that will be indirected via REST class Puppet::TestIndirectedFoo - extend Puppet::Indirector - indirects :test_indirected_foo, :terminus_setting => :test_indirected_foo_terminus - - attr_reader :value - - def initialize(value = 0) - @value = value - end - - def self.from_yaml(yaml) - YAML.load(yaml) - end - - def name - "bob" - end + extend Puppet::Indirector + indirects :test_indirected_foo, :terminus_setting => :test_indirected_foo_terminus + + attr_reader :value + + def initialize(value = 0) + @value = value + end + + def self.from_yaml(yaml) + YAML.load(yaml) + end + + def name + "bob" + end end # empty Terminus class -- this would normally have to be in a directory findable by the autoloader, but we short-circuit that below @@ -29,432 +31,434 @@ end describe Puppet::Indirector::REST do - describe "when using webrick" do - before :each do - Puppet[:servertype] = 'webrick' - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :test_indirected_foo ] } - @server = Puppet::Network::Server.new(@params) - @server.listen + describe "when using webrick" do + before :each do + Puppet[:servertype] = 'webrick' + @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :test_indirected_foo ] } + @server = Puppet::Network::Server.new(@params) + @server.listen - # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. - Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) - Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest + # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. + Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) + Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest - # Stub the connection information. - Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) - end - - describe "when finding a model instance over REST" do - describe "when a matching model instance can be found" do - before :each do - @model_instance = Puppet::TestIndirectedFoo.new(23) - @mock_model = stub('faked model', :find => @model_instance) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - Puppet::TestIndirectedFoo.find('bar') - lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error - end - - it 'should return an instance of the model class' do - Puppet::TestIndirectedFoo.find('bar').class.should == Puppet::TestIndirectedFoo - end - - it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.find('bar').value.should == @model_instance.value + # Stub the connection information. + Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) end - - it 'should set an expiration on model instance' do - Puppet::TestIndirectedFoo.find('bar').expiration.should_not be_nil - end - end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :find => nil) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return nil" do - Puppet::TestIndirectedFoo.find('bar').should be_nil - end - end + describe "when finding a model instance over REST" do + describe "when a matching model instance can be found" do + before :each do + @model_instance = Puppet::TestIndirectedFoo.new(23) + @mock_model = stub('faked model', :find => @model_instance) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error + end - describe "when an exception is encountered in looking up a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:find).raises(RuntimeError) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) - end - end - end - - describe "when searching for model instances over REST" do - describe "when matching model instances can be found" do - before :each do - @model_instances = [ Puppet::TestIndirectedFoo.new(23), Puppet::TestIndirectedFoo.new(24) ] - @mock_model = stub('faked model', :search => @model_instances) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - lambda { Puppet::TestIndirectedFoo.search('bar') }.should_not raise_error - end - - it 'should return all matching results' do - Puppet::TestIndirectedFoo.search('bar').length.should == @model_instances.length - end - - it 'should return model instances' do - Puppet::TestIndirectedFoo.search('bar').each do |result| - result.class.should == Puppet::TestIndirectedFoo - end - end - - it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&: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 + it 'should return an instance of the model class' do + Puppet::TestIndirectedFoo.find('bar').class.should == Puppet::TestIndirectedFoo + end + + it 'should return the instance of the model class associated with the provided lookup key' do + Puppet::TestIndirectedFoo.find('bar').value.should == @model_instance.value + end + + it 'should set an expiration on model instance' do + Puppet::TestIndirectedFoo.find('bar').expiration.should_not be_nil + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :find => nil) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return nil" do + Puppet::TestIndirectedFoo.find('bar').should be_nil + end + end + + describe "when an exception is encountered in looking up a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:find).raises(RuntimeError) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + end end - end end - end + + describe "when searching for model instances over REST" do + describe "when matching model instances can be found" do + before :each do + @model_instances = [ Puppet::TestIndirectedFoo.new(23), Puppet::TestIndirectedFoo.new(24) ] + @mock_model = stub('faked model', :search => @model_instances) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.search('bar') }.should_not raise_error + end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :find => nil) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return nil" do - Puppet::TestIndirectedFoo.find('bar').should be_nil - end - end + it 'should return all matching results' do + Puppet::TestIndirectedFoo.search('bar').length.should == @model_instances.length + end - describe "when an exception is encountered in looking up a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:find).raises(RuntimeError) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + it 'should return model instances' do + Puppet::TestIndirectedFoo.search('bar').each do |result| + result.class.should == Puppet::TestIndirectedFoo + end + end + + it 'should return the instance of the model class associated with the provided lookup key' do + Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&: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 + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :find => nil) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return nil" do + Puppet::TestIndirectedFoo.find('bar').should be_nil + end + end + + describe "when an exception is encountered in looking up a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:find).raises(RuntimeError) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + end + end end - end - end - describe "when destroying a model instance over REST" do - describe "when a matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :destroy => true) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should_not raise_error - end - - it 'should return success' do - Puppet::TestIndirectedFoo.destroy('bar').should == true - end - end + describe "when destroying a model instance over REST" do + describe "when a matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :destroy => true) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should_not raise_error + end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :destroy => false) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return failure" do - Puppet::TestIndirectedFoo.destroy('bar').should == false + it 'should return success' do + Puppet::TestIndirectedFoo.destroy('bar').should == true + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :destroy => false) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return failure" do + Puppet::TestIndirectedFoo.destroy('bar').should == false + end + end + + describe "when an exception is encountered in destroying a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:destroy).raises(RuntimeError) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should raise_error(RuntimeError) + end + end end - end + + describe "when saving a model instance over REST" do + before :each do + @instance = Puppet::TestIndirectedFoo.new(42) + @mock_model = stub('faked model', :from_yaml => @instance) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).returns(@instance) + end + + describe "when a successful save can be performed" do + before :each do + end + + it "should not fail" do + lambda { @instance.save }.should_not raise_error + end - describe "when an exception is encountered in destroying a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:destroy).raises(RuntimeError) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should raise_error(RuntimeError) + it 'should return an instance of the model class' do + @instance.save.class.should == Puppet::TestIndirectedFoo + end + + it 'should return a matching instance of the model class' do + @instance.save.value.should == @instance.value + end + end + + describe "when a save cannot be completed" do + before :each do + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).returns(false) + end + + it "should return failure" do + @instance.save.should == false + end + end + + describe "when an exception is encountered in performing a save" do + before :each do + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).raises(RuntimeError) + end + + it "should raise an exception" do + lambda { @instance.save }.should raise_error(RuntimeError) + end + end end - end - end - describe "when saving a model instance over REST" do - before :each do - @instance = Puppet::TestIndirectedFoo.new(42) - @mock_model = stub('faked model', :from_yaml => @instance) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).returns(@instance) - end - - describe "when a successful save can be performed" do - before :each do - end - - it "should not fail" do - lambda { @instance.save }.should_not raise_error - end - - it 'should return an instance of the model class' do - @instance.save.class.should == Puppet::TestIndirectedFoo - end - - it 'should return a matching instance of the model class' do - @instance.save.value.should == @instance.value - end - end - - describe "when a save cannot be completed" do - before :each do - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).returns(false) - end - - it "should return failure" do - @instance.save.should == false - end - end - - describe "when an exception is encountered in performing a save" do - before :each do - Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:save_object).raises(RuntimeError) + after :each do + @server.unlisten end - - it "should raise an exception" do - lambda { @instance.save }.should raise_error(RuntimeError) - end - end - end - - after :each do - @server.unlisten end - 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 => 34343, :handlers => [ :test_indirected_foo ] } - @server = Puppet::Network::Server.new(@params) - @server.listen + 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 => 34343, :handlers => [ :test_indirected_foo ] } + @server = Puppet::Network::Server.new(@params) + @server.listen - # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. - Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) - Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest + # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. + Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) + Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest - # Stub the connection information. - Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) - end - - describe "when finding a model instance over REST" do - describe "when a matching model instance can be found" do - before :each do - @model_instance = Puppet::TestIndirectedFoo.new(23) - @mock_model = stub('faked model', :find => @model_instance) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error - end - - it 'should return an instance of the model class' do - Puppet::TestIndirectedFoo.find('bar').class.should == Puppet::TestIndirectedFoo + # Stub the connection information. + Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) end - - it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.find('bar').value.should == @model_instance.value - end - - it 'should set an expiration on model instance' do - Puppet::TestIndirectedFoo.find('bar').expiration.should_not be_nil - end - end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :find => nil) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return nil" do - Puppet::TestIndirectedFoo.find('bar').should be_nil - end - end + describe "when finding a model instance over REST" do + describe "when a matching model instance can be found" do + before :each do + @model_instance = Puppet::TestIndirectedFoo.new(23) + @mock_model = stub('faked model', :find => @model_instance) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error + end - describe "when an exception is encountered in looking up a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:find).raises(RuntimeError) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + it 'should return an instance of the model class' do + Puppet::TestIndirectedFoo.find('bar').class.should == Puppet::TestIndirectedFoo + end + + it 'should return the instance of the model class associated with the provided lookup key' do + Puppet::TestIndirectedFoo.find('bar').value.should == @model_instance.value + end + + it 'should set an expiration on model instance' do + Puppet::TestIndirectedFoo.find('bar').expiration.should_not be_nil + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :find => nil) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return nil" do + Puppet::TestIndirectedFoo.find('bar').should be_nil + end + end + + describe "when an exception is encountered in looking up a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:find).raises(RuntimeError) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + end + end end - end - end - describe "when searching for model instances over REST" do - describe "when matching model instances can be found" do - before :each do - @model_instances = [ Puppet::TestIndirectedFoo.new(23), Puppet::TestIndirectedFoo.new(24) ] - @mock_model = stub('faked model', :search => @model_instances) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - lambda { Puppet::TestIndirectedFoo.search('bar') }.should_not raise_error - end - - it 'should return all matching results' do - Puppet::TestIndirectedFoo.search('bar').length.should == @model_instances.length - end - - it 'should return model instances' do - Puppet::TestIndirectedFoo.search('bar').each do |result| - result.class.should == Puppet::TestIndirectedFoo - end - end - - it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value) - end - - it 'should set an expiration on model instances' do - Puppet::TestIndirectedFoo.search('bar').each do |result| - result.expiration.should_not be_nil - end - end - end + describe "when searching for model instances over REST" do + describe "when matching model instances can be found" do + before :each do + @model_instances = [ Puppet::TestIndirectedFoo.new(23), Puppet::TestIndirectedFoo.new(24) ] + @mock_model = stub('faked model', :search => @model_instances) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.search('bar') }.should_not raise_error + end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :find => nil) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return nil" do - Puppet::TestIndirectedFoo.find('bar').should be_nil - end - end + it 'should return all matching results' do + Puppet::TestIndirectedFoo.search('bar').length.should == @model_instances.length + end - describe "when an exception is encountered in looking up a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:find).raises(RuntimeError) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + it 'should return model instances' do + Puppet::TestIndirectedFoo.search('bar').each do |result| + result.class.should == Puppet::TestIndirectedFoo + end + end + + it 'should return the instance of the model class associated with the provided lookup key' do + Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value) + end + + it 'should set an expiration on model instances' do + Puppet::TestIndirectedFoo.search('bar').each do |result| + result.expiration.should_not be_nil + end + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :find => nil) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return nil" do + Puppet::TestIndirectedFoo.find('bar').should be_nil + end + end + + describe "when an exception is encountered in looking up a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:find).raises(RuntimeError) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + end + end end - end - end - describe "when destroying a model instance over REST" do - describe "when a matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :destroy => true) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should not fail" do - lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should_not raise_error - end - - it 'should return success' do - Puppet::TestIndirectedFoo.destroy('bar').should == true - end - end + describe "when destroying a model instance over REST" do + describe "when a matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :destroy => true) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should_not raise_error + end - describe "when no matching model instance can be found" do - before :each do - @mock_model = stub('faked model', :destroy => false) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should return failure" do - Puppet::TestIndirectedFoo.destroy('bar').should == false + it 'should return success' do + Puppet::TestIndirectedFoo.destroy('bar').should == true + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :destroy => false) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return failure" do + Puppet::TestIndirectedFoo.destroy('bar').should == false + end + end + + describe "when an exception is encountered in destroying a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:destroy).raises(RuntimeError) + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should raise_error(RuntimeError) + end + end end - end + + describe "when saving a model instance over REST" do + before :each 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 + + describe "when a successful save can be performed" do + before :each do + end + + it "should not fail" do + lambda { @instance.save }.should_not raise_error + end - describe "when an exception is encountered in destroying a model instance" do - before :each do - @mock_model = stub('faked model') - @mock_model.stubs(:destroy).raises(RuntimeError) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model) - end - - it "should raise an exception" do - lambda { Puppet::TestIndirectedFoo.destroy('bar') }.should raise_error(RuntimeError) + it 'should return an instance of the model class' do + @instance.save.class.should == Puppet::TestIndirectedFoo + end + + it 'should return a matching instance of the model class' do + @instance.save.value.should == @instance.value + end + end + + describe "when a save cannot be completed" do + before :each do + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).returns(false) + end + + it "should return failure" do + @instance.save.should == false + end + end + + describe "when an exception is encountered in performing a save" do + before :each do + Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).raises(RuntimeError) + end + + it "should raise an exception" do + lambda { @instance.save }.should raise_error(RuntimeError) + end + end end - end - end - describe "when saving a model instance over REST" do - before :each 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) - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).returns(@instance) - end - - describe "when a successful save can be performed" do - before :each do - end - - it "should not fail" do - lambda { @instance.save }.should_not raise_error - end - - it 'should return an instance of the model class' do - @instance.save.class.should == Puppet::TestIndirectedFoo - end - - it 'should return a matching instance of the model class' do - @instance.save.value.should == @instance.value + after :each do + @server.unlisten end - end - - describe "when a save cannot be completed" do - before :each do - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).returns(false) - end - - it "should return failure" do - @instance.save.should == false - end - end - - describe "when an exception is encountered in performing a save" do - before :each do - Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).raises(RuntimeError) - end - - it "should raise an exception" do - lambda { @instance.save }.should raise_error(RuntimeError) - end - end - end - - after :each do - @server.unlisten end - end end diff --git a/spec/integration/network/server/mongrel.rb b/spec/integration/network/server/mongrel.rb index 65caf78c9..180fdf7ad 100644..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 ] } - @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
\ No newline at end of file +end diff --git a/spec/integration/network/server/webrick.rb b/spec/integration/network/server/webrick.rb index 0ab8d89e4..41714271f 100644..100755 --- a/spec/integration/network/server/webrick.rb +++ b/spec/integration/network/server/webrick.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 webrick" do - before :each do - Puppet[:servertype] = 'webrick' - @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :node ] } - end - - describe "before listening" do - it "should not be reachable at the specified address and port" do - lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error - end - end - - 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.listen - lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error - end + describe "when using webrick" do + before :each do + Puppet[:servertype] = 'webrick' + @params = { :address => "127.0.0.1", :port => 34343, :handlers => [ :node ] } + end + + describe "before listening" do + it "should not be reachable at the specified address and port" do + lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error + end + end + + 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.listen + 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.listen + @server2 = Puppet::Network::Server.new(@params.merge(:port => 34343)) + lambda { @server2.listen }.should 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.listen - @server2 = Puppet::Network::Server.new(@params.merge(:port => 34343)) - lambda { @server2.listen }.should raise_error - end - - after :each do - @server.unlisten if @server.listening? - end - end - - describe "after unlistening" do - it "should not be reachable on the port and address assigned" do - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.listen - @server.unlisten - lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error(Errno::ECONNREFUSED) - end + after :each do + @server.unlisten if @server.listening? + end + end + + describe "after unlistening" do + it "should not be reachable on the port and address assigned" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.listen + @server.unlisten + lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error(Errno::ECONNREFUSED) + end + end end - end -end
\ No newline at end of file +end diff --git a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb index e2f3d4728..0b4a5abdb 100644 --- a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +++ b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb @@ -1,7 +1,7 @@ dir = File.expand_path(File.dirname(__FILE__)) [ "#{dir}/../../lib", "#{dir}/../../test/lib"].each do |dir| - fulldir = File.expand_path(dir) - $LOAD_PATH.unshift(fulldir) unless $LOAD_PATH.include?(fulldir) + fulldir = File.expand_path(dir) + $LOAD_PATH.unshift(fulldir) unless $LOAD_PATH.include?(fulldir) end require 'spec' @@ -9,35 +9,35 @@ require 'puppettest' require 'puppettest/runnable_test' module Spec - module Runner - class ExampleGroupRunner - def run - prepare - success = true - example_groups.each do |example_group| - next unless example_group.runnable? - success = success & example_group.run + module Runner + class ExampleGroupRunner + def run + prepare + success = true + example_groups.each do |example_group| + next unless example_group.runnable? + success = success & example_group.run + end + return success + ensure + finish + end end - return success - ensure - finish - end end - end end module Spec - module Example - class ExampleGroup - extend PuppetTest::RunnableTest + module Example + class ExampleGroup + extend PuppetTest::RunnableTest + end end - end end module Test - module Unit - class TestCase - extend PuppetTest::RunnableTest + module Unit + class TestCase + extend PuppetTest::RunnableTest + end end - end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index db14b47cb..7909adca3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,7 +23,7 @@ require 'spec' Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file } Spec::Runner.configure do |config| - config.mock_with :mocha + config.mock_with :mocha # config.prepend_before :all do # setup_mocks_for_rspec diff --git a/spec/unit/executables/client/certhandler.rb b/spec/unit/executables/client/certhandler.rb index 0a7b77f15..4f8f8139c 100755 --- a/spec/unit/executables/client/certhandler.rb +++ b/spec/unit/executables/client/certhandler.rb @@ -14,67 +14,109 @@ describe cert_handler, "when handling certificates" do Puppet::Network::Client.stubs(:ca).returns(caclient_class) end - it "should return true if the certificate exists" do - Puppet::Network::HttpPool.expects(:read_cert).returns(true) - cert_handler.new(1,true).read_retrieve.should be_true - end - - it "should return false when getting a new cert" do - Puppet::Network::HttpPool.expects(:read_cert).returns(true) - @caclient.stubs(:request_cert).returns(true) - ch = cert_handler.new(1,true) - ch.stubs(:read_cert).returns(false) - ch.read_retrieve.should be_false + describe "when reading or retrieving the certificate" do + before do + @handler = cert_handler.new(1,true) + end + + it "should attempt to read the certificate" do + @handler.expects(:read_cert).returns true + @handler.read_retrieve + end + + it "should delegate to Puppet::Network::HttpPool to read the certificate" do + Puppet::Network::HttpPool.expects(:read_cert).returns(true) + @handler.read_retrieve + end + + it "should not attempt to retrieve a certificate if one can be read" do + @handler.stubs(:read_cert).returns true + @handler.expects(:retrieve_cert).never + @handler.read_retrieve + end + + it "should attempt to retrieve a certificate if none can be read" do + @handler.stubs(:read_cert).returns false + @handler.expects(:retrieve_cert) + @handler.read_retrieve + end + + it "should delegate to caclient to retrieve a certificate" do + @handler.stubs(:read_cert).returns false + @caclient.expects(:request_cert).returns(true) + @handler.stubs(:read_new_cert).returns(true) + @handler.read_retrieve + end + + it "should return true if the certificate exists" do + @handler.stubs(:read_cert).returns true + @handler.read_retrieve.should be_true + end + + it "should return false when getting a new cert" do + #This is the second call to httppool that happens in 'read_new_cert' + Puppet::Network::HttpPool.expects(:read_cert).returns(true) + @caclient.stubs(:request_cert).returns(true) + @handler.stubs(:read_cert).returns(false) + @handler.read_retrieve.should be_false + end end describe "when waiting for cert" do + before do + @handler = cert_handler.new(1,false) + @handler.stubs(:read_cert).returns false + #all waiting for cert tests should loop, which will always happen if sleep is called + #yeah, I put the expectation in the setup, deal with it + @handler.expects(:sleep).with(1) + + #This is needed to get out of the loop + @handler.stubs(:read_new_cert).returns(true) + end + it "should loop when the cert request does not return a certificate" do @caclient.stubs(:request_cert).times(2).returns(false).then.returns(true) - ch = cert_handler.new(1,false) - ch.expects(:sleep) - ch.expects(:read_new_cert).returns(true) - ch.read_retrieve + @handler.retrieve_cert end it "should loop when the cert request raises an Error" do @caclient.stubs(:request_cert).times(2).raises(StandardError, 'Testing').then.returns(true) - ch = cert_handler.new(1,false) - ch.expects(:sleep) - ch.expects(:read_new_cert).returns(true) - ch.read_retrieve + @handler.retrieve_cert end it "should loop when the new cert can't be read" do @caclient.stubs(:request_cert).returns(true) - ch = cert_handler.new(1,false) - ch.expects(:sleep) - ch.expects(:read_new_cert).times(2).returns(false).then.returns(true) - ch.read_retrieve + @handler.stubs(:read_new_cert).times(2).returns(false).then.returns(true) + @handler.retrieve_cert end end describe "when in one time mode" do + before do + #true puts us in onetime mode + @handler = cert_handler.new(1,true) + @handler.stubs(:read_cert).returns false + end + it "should exit if the cert request does not return a certificate" do @caclient.stubs(:request_cert).returns(false) - ch = cert_handler.new(1,true) - ch.expects(:exit).with(1).raises(SystemExit) - lambda { ch.read_retrieve }.should raise_error(SystemExit) + @handler.expects(:exit).with(1).raises(SystemExit) + lambda { @handler.retrieve_cert }.should raise_error(SystemExit) end it "should exit if the cert request raises an exception" do @caclient.stubs(:request_cert).raises(StandardError, 'Testing') - ch = cert_handler.new(1,true) - ch.expects(:exit).with(23).raises(SystemExit) - lambda { ch.read_retrieve }.should raise_error(SystemExit) + @handler.expects(:exit).with(23).raises(SystemExit) + lambda { @handler.retrieve_cert }.should raise_error(SystemExit) end it "should exit if the new cert can't be read" do @caclient.stubs(:request_cert).returns(true) + #this is the second, call to httppool inside read_new_cert Puppet::Network::HttpPool.stubs(:read_cert).returns(false) - ch = cert_handler.new(1,true) - ch.expects(:exit).with(34).raises(SystemExit) - lambda { ch.read_retrieve }.should raise_error(SystemExit) + @handler.expects(:exit).with(34).raises(SystemExit) + lambda { @handler.retrieve_cert }.should raise_error(SystemExit) end end end diff --git a/spec/unit/indirector/module_files.rb b/spec/unit/indirector/module_files.rb index 0f6dbb6df..f5b92e1fd 100755 --- a/spec/unit/indirector/module_files.rb +++ b/spec/unit/indirector/module_files.rb @@ -10,24 +10,24 @@ require 'puppet/indirector/module_files' describe Puppet::Indirector::ModuleFiles do - before :each do - Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) - Puppet::Indirector::Terminus.stubs(:register_terminus_class) - @model = mock 'model' - @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model - Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection) - - @module_files_class = Class.new(Puppet::Indirector::ModuleFiles) do - def self.to_s - "Testing::Mytype" - end - end - - @module_files = @module_files_class.new - - @uri = "puppetmounts://host/modules/my/local/file" - @module = Puppet::Module.new("mymod", "/module/path") - end + before :each do + Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) + Puppet::Indirector::Terminus.stubs(:register_terminus_class) + @model = mock 'model' + @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model + Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection) + + @module_files_class = Class.new(Puppet::Indirector::ModuleFiles) do + def self.to_s + "Testing::Mytype" + end + end + + @module_files = @module_files_class.new + + @uri = "puppetmounts://host/modules/my/local/file" + @module = Puppet::Module.new("mymod", "/module/path") + end describe Puppet::Indirector::ModuleFiles, " when finding files" do diff --git a/spec/unit/network/client.rb b/spec/unit/network/client.rb index e9467aad0..e9467aad0 100644..100755 --- a/spec/unit/network/client.rb +++ b/spec/unit/network/client.rb diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb index 79a0a88d4..79a0a88d4 100644..100755 --- a/spec/unit/network/http.rb +++ b/spec/unit/network/http.rb diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb index ccfca2f55..ccfca2f55 100644..100755 --- a/spec/unit/network/http/mongrel.rb +++ b/spec/unit/network/http/mongrel.rb diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb index 1dd7de40a..3df925133 100644..100755 --- a/spec/unit/network/http/mongrel/rest.rb +++ b/spec/unit/network/http/mongrel/rest.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' diff --git a/spec/unit/network/http/mongrel/xmlrpc.rb b/spec/unit/network/http/mongrel/xmlrpc.rb index e69de29bb..e69de29bb 100644..100755 --- a/spec/unit/network/http/mongrel/xmlrpc.rb +++ b/spec/unit/network/http/mongrel/xmlrpc.rb diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index 05ed2f0e2..78bd39145 100644..100755 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -82,21 +82,21 @@ end describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol" do - it "should require a protocol" do - lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should raise_error(ArgumentError) - end - - it "should accept a protocol" do - lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol("bob") }.should_not raise_error(ArgumentError) - end - - it "should use a WEBrick + REST class when a REST protocol is specified" do - Puppet::Network::HTTP::WEBrick.class_for_protocol("rest").should == Puppet::Network::HTTP::WEBrickREST - end - - it "should fail when an unknown protocol is specified" do - lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol("abcdefg") }.should raise_error - end + it "should require a protocol" do + lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should raise_error(ArgumentError) + end + + it "should accept a protocol" do + lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol("bob") }.should_not raise_error(ArgumentError) + end + + it "should use a WEBrick + REST class when a REST protocol is specified" do + Puppet::Network::HTTP::WEBrick.class_for_protocol("rest").should == Puppet::Network::HTTP::WEBrickREST + end + + it "should fail when an unknown protocol is specified" do + lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol("abcdefg") }.should raise_error + end end describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb index 1e0166d71..45e5f0bd2 100644..100755 --- a/spec/unit/network/http/webrick/rest.rb +++ b/spec/unit/network/http/webrick/rest.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' diff --git a/spec/unit/network/http/webrick/xmlrpc.rb b/spec/unit/network/http/webrick/xmlrpc.rb index e69de29bb..e69de29bb 100644..100755 --- a/spec/unit/network/http/webrick/xmlrpc.rb +++ b/spec/unit/network/http/webrick/xmlrpc.rb diff --git a/spec/unit/network/server.rb b/spec/unit/network/server.rb index 4e47c22fd..4e47c22fd 100644..100755 --- a/spec/unit/network/server.rb +++ b/spec/unit/network/server.rb diff --git a/spec/unit/util/warnings.rb b/spec/unit/util/warnings.rb index 46bd1cc2d..46bd1cc2d 100644..100755 --- a/spec/unit/util/warnings.rb +++ b/spec/unit/util/warnings.rb |