From 934fbba81cb18f05e07675d79a2e830c4e95c918 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sat, 19 Apr 2008 15:30:11 -0500 Subject: Making the SSL::Host's destroy method a class method, rather than an instance method. --- spec/unit/ssl/host.rb | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'spec/unit/ssl') diff --git a/spec/unit/ssl/host.rb b/spec/unit/ssl/host.rb index d3756a016..b214aa44a 100755 --- a/spec/unit/ssl/host.rb +++ b/spec/unit/ssl/host.rb @@ -125,6 +125,36 @@ describe Puppet::SSL::Host do end end + it "should have a class method for destroying all files related to a given host" do + Puppet::SSL::Host.should respond_to(:destroy) + end + + describe "when destroying a host's SSL files" do + before do + Puppet::SSL::Key.stubs(:destroy).returns false + Puppet::SSL::Certificate.stubs(:destroy).returns false + Puppet::SSL::CertificateRequest.stubs(:destroy).returns false + end + + it "should destroy its certificate, certificate request, and key" do + Puppet::SSL::Key.expects(:destroy).with("myhost") + Puppet::SSL::Certificate.expects(:destroy).with("myhost") + Puppet::SSL::CertificateRequest.expects(:destroy).with("myhost") + + Puppet::SSL::Host.destroy("myhost") + end + + it "should return true if any of the classes returned true" do + Puppet::SSL::Certificate.expects(:destroy).with("myhost").returns true + + Puppet::SSL::Host.destroy("myhost").should be_true + end + + it "should return false if none of the classes returned true" do + Puppet::SSL::Host.destroy("myhost").should be_false + end + end + describe "when managing its private key" do before do @realkey = "mykey" @@ -229,22 +259,6 @@ describe Puppet::SSL::Host do end end - describe "when being destroyed" do - before do - @host.stubs(:key).returns Puppet::SSL::Key.new("myname") - @host.stubs(:certificate).returns Puppet::SSL::Certificate.new("myname") - @host.stubs(:certificate_request).returns Puppet::SSL::CertificateRequest.new("myname") - end - - it "should destroy its certificate, certificate request, and key" do - Puppet::SSL::Key.expects(:destroy).with(@host.name) - Puppet::SSL::Certificate.expects(:destroy).with(@host.name) - Puppet::SSL::CertificateRequest.expects(:destroy).with(@host.name) - - @host.destroy - end - end - it "should have a method for listing certificate hosts" do Puppet::SSL::Host.should respond_to(:search) end -- cgit