diff options
author | Luke Kanies <luke@madstop.com> | 2008-04-17 21:39:24 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-04-17 21:39:24 -0500 |
commit | 71db9b58349f75a54649d9b0d1fead8d01593f7a (patch) | |
tree | 4e17f61f1b53863477e6917818bb1893a55693b1 /spec/integration/ssl/certificate_request.rb | |
parent | e5c4687593766955de09e5613c892ce82a2a989d (diff) | |
download | puppet-71db9b58349f75a54649d9b0d1fead8d01593f7a.tar.gz puppet-71db9b58349f75a54649d9b0d1fead8d01593f7a.tar.xz puppet-71db9b58349f75a54649d9b0d1fead8d01593f7a.zip |
Adding integration tests for a lot of the SSL code.
This flushed out some problems, and things mostly look good
now, but I don't think we're quite there yet.
Diffstat (limited to 'spec/integration/ssl/certificate_request.rb')
-rwxr-xr-x | spec/integration/ssl/certificate_request.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/integration/ssl/certificate_request.rb b/spec/integration/ssl/certificate_request.rb new file mode 100755 index 000000000..d3567bcce --- /dev/null +++ b/spec/integration/ssl/certificate_request.rb @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby +# +# Created by Luke Kanies on 2008-4-17. +# Copyright (c) 2008. All rights reserved. + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/ssl/certificate_request' +require 'tempfile' + +describe Puppet::SSL::Host do + before do + # Get a safe temporary file + file = Tempfile.new("csr_integration_testing") + @dir = file.path + file.delete + + Puppet.settings[:confdir] = @dir + Puppet.settings[:vardir] = @dir + + @csr = Puppet::SSL::CertificateRequest.new("luke.madstop.com") + + @key = OpenSSL::PKey::RSA.new(512) + end + + after { + system("rm -rf %s" % @dir) + Puppet.settings.clear + + # This is necessary so the terminus instances don't lie around. + Puppet::SSL::CertificateRequest.indirection.clear_cache + } + + it "should be able to generate CSRs" do + @csr.generate(@key) + end + + it "should be able to save CSRs" do + @csr.save + end + + it "should be able to find saved certificate requests via the Indirector" do + @csr.generate(@key) + @csr.save + + Puppet::SSL::CertificateRequest.find("luke.madstop.com").should be_instance_of(Puppet::SSL::CertificateRequest) + end + + it "should save the completely CSR when saving" do + @csr.generate(@key) + @csr.save + + Puppet::SSL::CertificateRequest.find("luke.madstop.com").content.to_s.should == @csr.content.to_s + end +end |