diff options
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/integration/defaults.rb | 5 | ||||
| -rwxr-xr-x | spec/unit/ssl/certificate_request.rb | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb index fb00f8646..0e9a03fcb 100755 --- a/spec/integration/defaults.rb +++ b/spec/integration/defaults.rb @@ -204,4 +204,9 @@ describe "Puppet defaults" do Puppet.settings[:report_server].should == "report_server" end end + + it "should have a :caname setting that defaults to the cert name" do + Puppet.settings[:certname] = "foo" + Puppet.settings[:ca_name].should == "foo" + end end diff --git a/spec/unit/ssl/certificate_request.rb b/spec/unit/ssl/certificate_request.rb index 85e1d5470..29bbc7bc1 100755 --- a/spec/unit/ssl/certificate_request.rb +++ b/spec/unit/ssl/certificate_request.rb @@ -117,6 +117,21 @@ describe Puppet::SSL::CertificateRequest do @instance.generate(@key) end + it "should set the CN to the CSR name when the CSR is not for a CA" do + subject = mock 'subject' + OpenSSL::X509::Name.expects(:new).with { |subject| subject[0][1] == @instance.name }.returns(subject) + @request.expects(:subject=).with(subject) + @instance.generate(@key) + end + + it "should set the CN to the :ca_name setting when the CSR is for a CA" do + subject = mock 'subject' + Puppet.settings.expects(:value).with(:ca_name).returns "mycertname" + OpenSSL::X509::Name.expects(:new).with { |subject| subject[0][1] == "mycertname" }.returns(subject) + @request.expects(:subject=).with(subject) + Puppet::SSL::CertificateRequest.new(Puppet::SSL::CA_NAME).generate(@key) + end + it "should set the version to 0" do @request.expects(:version=).with(0) @instance.generate(@key) |
