summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-04-17 21:51:14 -0500
committerLuke Kanies <luke@madstop.com>2008-04-17 21:51:14 -0500
commitf7e0990fb436ce14e5f7ed295c004438d7735f95 (patch)
tree0738121f153946f348e891ba6a879e326b8c312a
parent71db9b58349f75a54649d9b0d1fead8d01593f7a (diff)
downloadpuppet-f7e0990fb436ce14e5f7ed295c004438d7735f95.tar.gz
puppet-f7e0990fb436ce14e5f7ed295c004438d7735f95.tar.xz
puppet-f7e0990fb436ce14e5f7ed295c004438d7735f95.zip
Setting the expiration date of certificate objects to the expiry of the actual
cert.
-rw-r--r--lib/puppet/ssl/certificate.rb5
-rwxr-xr-xspec/unit/ssl/certificate.rb15
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/puppet/ssl/certificate.rb b/lib/puppet/ssl/certificate.rb
index 4887708f8..16af85d06 100644
--- a/lib/puppet/ssl/certificate.rb
+++ b/lib/puppet/ssl/certificate.rb
@@ -11,4 +11,9 @@ class Puppet::SSL::Certificate < Puppet::SSL::Base
extend Puppet::Indirector
indirects :certificate, :terminus_class => :file
+
+ def expiration
+ return nil unless content
+ return content.not_after
+ end
end
diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb
index a30591946..1cb164d3f 100755
--- a/spec/unit/ssl/certificate.rb
+++ b/spec/unit/ssl/certificate.rb
@@ -38,6 +38,21 @@ describe Puppet::SSL::Certificate do
@certificate.should respond_to(:content)
end
+ it "should return a nil expiration if there is no actual certificate" do
+ @certificate.stubs(:content).returns nil
+
+ @certificate.expiration.should be_nil
+ end
+
+ it "should use the expiration of the certificate as its expiration date" do
+ cert = stub 'cert'
+ @certificate.stubs(:content).returns cert
+
+ cert.expects(:not_after).returns "sometime"
+
+ @certificate.expiration.should == "sometime"
+ end
+
it "should be able to read certificates from disk" do
path = "/my/path"
File.expects(:read).with(path).returns("my certificate")