This class was previously using a cached_attr for its 'localhost' attribute, representing the Puppet::SSL::Host entry corresponding to the cert in Puppet[:certname]. We now no longer expire this attribute. This has the effect that a change to certname during the lifetime of an agent will not be reflected in the certificate it uses. If this behavior is desired, it will need to be reimplemented another way.
Reviewed-By: Jacob Helwig <[email protected]> --- lib/puppet/ssl/host.rb | 13 ++++--------- spec/unit/ssl/host_spec.rb | 12 +----------- test/network/handler/master.rb | 5 ----- test/network/server/webrick.rb | 26 +++++--------------------- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index b9215ef..08a8ace 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -4,7 +4,6 @@ require 'puppet/ssl/key' require 'puppet/ssl/certificate' require 'puppet/ssl/certificate_request' require 'puppet/ssl/certificate_revocation_list' -require 'puppet/util/cacher' # The class that manages all aspects of our SSL certificates -- # private keys, public keys, requests, etc. @@ -27,14 +26,10 @@ class Puppet::SSL::Host # This accessor is used in instances for indirector requests to hold desired state attr_accessor :desired_state - class << self - include Puppet::Util::Cacher - - cached_attr(:localhost) do - result = new - result.generate unless result.certificate - result.key # Make sure it's read in - result + def self.localhost + @localhost ||= new.tap do |l| + l.generate unless l.certificate + l.key # Make sure it's read in end end diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb index e168094..f004516 100755 --- a/spec/unit/ssl/host_spec.rb +++ b/spec/unit/ssl/host_spec.rb @@ -13,7 +13,7 @@ describe Puppet::SSL::Host, :fails_on_windows => true do after do # Cleaned out any cached localhost instance. - Puppet::Util::Cacher.expire + Puppet::SSL::Host.instance_variable_set(:@localhost, nil) Puppet::SSL::Host.ca_location = :none end @@ -82,16 +82,6 @@ describe Puppet::SSL::Host, :fails_on_windows => true do Puppet::SSL::Host.localhost.should == Puppet::SSL::Host.localhost end - it "should be able to expire the cached instance" do - one = stub 'host1', :certificate => "eh", :key => 'foo' - two = stub 'host2', :certificate => "eh", :key => 'foo' - Puppet::SSL::Host.expects(:new).times(2).returns(one).then.returns(two) - - Puppet::SSL::Host.localhost.should equal(one) - Puppet::Util::Cacher.expire - Puppet::SSL::Host.localhost.should equal(two) - end - it "should be able to verify its certificate matches its key" do Puppet::SSL::Host.new("foo").should respond_to(:certificate_matches_key?) end diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 4c0374a..9326e4b 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -16,11 +16,6 @@ class TestMaster < Test::Unit::TestCase Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog) end - def teardown - super - Puppet::Util::Cacher.expire - end - def test_freshness_is_always_now now1 = mock 'now1' Time.stubs(:now).returns(now1) diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index 9eed5d8..e1fd689 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -11,10 +11,7 @@ class TestWebrickServer < Test::Unit::TestCase def setup Puppet::Util::SUIDManager.stubs(:asuser).yields - super - end - - def teardown + Puppet::SSL::Host.instance_variable_set(:@localhost, nil) super end @@ -23,11 +20,8 @@ class TestWebrickServer < Test::Unit::TestCase def test_basics server = nil assert_raise(Puppet::Error, "server succeeded with no cert") do - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :Status => nil } @@ -35,11 +29,8 @@ class TestWebrickServer < Test::Unit::TestCase end assert_nothing_raised("Could not create simple server") do - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :CA => {}, # so that certs autogenerate :Status => nil @@ -75,11 +66,8 @@ class TestWebrickServer < Test::Unit::TestCase client = nil assert_nothing_raised { - - client = Puppet::Network::Client.status.new( - + client = Puppet::Network::Client.status.new( :Server => "localhost", - :Port => @@port ) } @@ -90,17 +78,13 @@ class TestWebrickServer < Test::Unit::TestCase server = nil Puppet[:certdnsnames] = "localhost" assert_nothing_raised { - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :CA => {}, # so that certs autogenerate :Status => nil } ) - } pid = fork { -- 1.7.5.4 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
