diff options
| author | Luke Kanies <luke@madstop.com> | 2008-04-18 11:47:44 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-04-18 11:47:44 -0500 |
| commit | 67f9d6977a21a96bf0a2a4d1d9ebde190a58e7bc (patch) | |
| tree | 4e38a2282df7d4cd979634b54786c66c2cd492b0 /spec/unit/ssl | |
| parent | 7cca66985a0f84b3904702df842d461c2b6431b7 (diff) | |
| download | puppet-67f9d6977a21a96bf0a2a4d1d9ebde190a58e7bc.tar.gz puppet-67f9d6977a21a96bf0a2a4d1d9ebde190a58e7bc.tar.xz puppet-67f9d6977a21a96bf0a2a4d1d9ebde190a58e7bc.zip | |
Changing the Inventory class to rebuild when the
first cert is added, so it's easier to test.
Diffstat (limited to 'spec/unit/ssl')
| -rwxr-xr-x | spec/unit/ssl/inventory.rb | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/spec/unit/ssl/inventory.rb b/spec/unit/ssl/inventory.rb index 8b5038af5..874fb2c73 100755 --- a/spec/unit/ssl/inventory.rb +++ b/spec/unit/ssl/inventory.rb @@ -18,71 +18,76 @@ describe Puppet::SSL::Inventory do end describe "when initializing" do - it "should build the inventory file if one does not exist" do + it "should set its path to the inventory file" do Puppet.settings.stubs(:value).with(:cert_inventory).returns "/inven/tory" - - FileTest.expects(:exist?).with("/inven/tory").returns false - - @class.any_instance.expects(:rebuild) - - @class.new + @class.new.path.should == "/inven/tory" end end - describe "when creating the inventory file" do + describe "when managing an inventory" do before do Puppet.settings.stubs(:value).with(:cert_inventory).returns "/inven/tory" - Puppet.settings.stubs(:write) - FileTest.stubs(:exist?).with("/inven/tory").returns false - Puppet::SSL::Certificate.stubs(:search).returns [] - end + FileTest.stubs(:exist?).with("/inven/tory").returns true - it "should log that it is building a new inventory file" do - Puppet.expects(:notice) + @inventory = @class.new - @class.new + @cert = mock 'cert' end - it "should use the Settings to write to the file" do - Puppet.settings.expects(:write).with(:cert_inventory) + describe "and creating the inventory file" do + before do + Puppet.settings.stubs(:write) + FileTest.stubs(:exist?).with("/inven/tory").returns false - @class.new - end + Puppet::SSL::Certificate.stubs(:search).returns [] + end - it "should add a header to the file" do - fh = mock 'filehandle' - Puppet.settings.stubs(:write).yields fh - fh.expects(:print).with { |str| str =~ /^#/ } + it "should log that it is building a new inventory file" do + Puppet.expects(:notice) - @class.new - end + @inventory.rebuild + end - it "should add formatted information on all existing certificates" do - cert1 = mock 'cert1' - cert2 = mock 'cert2' + it "should use the Settings to write to the file" do + Puppet.settings.expects(:write).with(:cert_inventory) - Puppet::SSL::Certificate.expects(:search).with("*").returns [cert1, cert2] + @inventory.rebuild + end - @class.any_instance.expects(:add).with(cert1) - @class.any_instance.expects(:add).with(cert2) + it "should add a header to the file" do + fh = mock 'filehandle' + Puppet.settings.stubs(:write).yields fh + fh.expects(:print).with { |str| str =~ /^#/ } - @class.new - end - end + @inventory.rebuild + end - describe "when managing an inventory" do - before do - Puppet.settings.stubs(:value).with(:cert_inventory).returns "/inven/tory" + it "should add formatted information on all existing certificates" do + cert1 = mock 'cert1' + cert2 = mock 'cert2' - FileTest.stubs(:exist?).with("/inven/tory").returns true + Puppet::SSL::Certificate.expects(:search).with("*").returns [cert1, cert2] - @inventory = @class.new + @class.any_instance.expects(:add).with(cert1) + @class.any_instance.expects(:add).with(cert2) - @cert = mock 'cert' + @inventory.rebuild + end end describe "and adding a certificate" do + it "should build the inventory file if one does not exist" do + Puppet.settings.stubs(:value).with(:cert_inventory).returns "/inven/tory" + Puppet.settings.stubs(:write) + + FileTest.expects(:exist?).with("/inven/tory").returns false + + @inventory.expects(:rebuild) + + @inventory.add(@cert) + end + it "should use the Settings to write to the file" do Puppet.settings.expects(:write).with(:cert_inventory, "a") |
