summaryrefslogtreecommitdiffstats
path: root/spec/unit/ssl
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-04-17 16:49:16 -0500
committerLuke Kanies <luke@madstop.com>2008-04-17 16:49:16 -0500
commitc5f0eff51626baa76ebc5bd4bee9d319a0b220c5 (patch)
treea0e045f7b640250f8ddacbe473c0cfe6dee4626e /spec/unit/ssl
parent3d24b12d73aad0bac74e4b2f1e214b79f3ca9231 (diff)
downloadpuppet-c5f0eff51626baa76ebc5bd4bee9d319a0b220c5.tar.gz
puppet-c5f0eff51626baa76ebc5bd4bee9d319a0b220c5.tar.xz
puppet-c5f0eff51626baa76ebc5bd4bee9d319a0b220c5.zip
Fixing the CA so it actually automatically generates its certificate.
Diffstat (limited to 'spec/unit/ssl')
-rwxr-xr-xspec/unit/ssl/certificate_authority.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/spec/unit/ssl/certificate_authority.rb b/spec/unit/ssl/certificate_authority.rb
index 37832ecf2..c6ffcb809 100755
--- a/spec/unit/ssl/certificate_authority.rb
+++ b/spec/unit/ssl/certificate_authority.rb
@@ -45,8 +45,6 @@ describe Puppet::SSL::CertificateAuthority do
end
end
- it "should generate a self-signed certificate if its Host instance has no certificate"
-
describe "when generating a self-signed CA certificate" do
before do
Puppet.settings.stubs(:use)
@@ -103,6 +101,8 @@ describe Puppet::SSL::CertificateAuthority do
@cacert.stubs(:content).returns "cacertificate"
Puppet::SSL::CertificateAuthority.any_instance.stubs(:certificate).returns @cacert
@ca = Puppet::SSL::CertificateAuthority.new
+
+ @ca.host.stubs(:certificate).returns @cacert
# Stub out the factory
@name = "myhost"
@@ -204,16 +204,15 @@ describe Puppet::SSL::CertificateAuthority do
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.stubs(:find).with(@name, :in => :ca_file).returns @request
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
@cert.stubs :save
end
- it "should fail if the CA certificate cannot be found" do
- @ca.expects(:certificate).returns nil
+ it "should generate a self-signed certificate if its Host instance has no certificate" do
+ @ca.host.expects(:certificate).times(2).returns(nil).then.returns mock("ca_certificate")
+ @ca.expects(:generate_ca_certificate)
- Puppet::SSL::CertificateRequest.stubs(:find).returns "csr"
-
- lambda { @ca.sign("myhost") }.should raise_error(ArgumentError)
+ @ca.sign(@name)
end
it "should use a certificate type of :server" do
@@ -225,13 +224,13 @@ describe Puppet::SSL::CertificateAuthority do
end
it "should use look up a CSR for the host in the :ca_file terminus" do
- Puppet::SSL::CertificateRequest.expects(:find).with(@name, :in => :ca_file).returns @request
+ Puppet::SSL::CertificateRequest.expects(:find).with(@name).returns @request
@ca.sign(@name)
end
it "should fail if no CSR can be found for the host" do
- Puppet::SSL::CertificateRequest.expects(:find).with(@name, :in => :ca_file).returns nil
+ Puppet::SSL::CertificateRequest.expects(:find).with(@name).returns nil
lambda { @ca.sign(@name) }.should raise_error(ArgumentError)
end
@@ -271,7 +270,7 @@ describe Puppet::SSL::CertificateAuthority do
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.stubs(:find).with(@name, :in => :ca_file).returns @request
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
@cert.stubs :save
Puppet::SSL::Certificate.expects(:new).with(@name).returns @cert
@@ -282,7 +281,7 @@ describe Puppet::SSL::CertificateAuthority do
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.stubs(:find).with(@name, :in => :ca_file).returns @request
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
@cert.stubs :save
@ca.sign(@name).should equal(@cert)
end