puppet 2.6.11 → 2.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +33 -0
- data/conf/redhat/puppet.spec +7 -4
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/cert.rb +17 -3
- data/lib/puppet/application/kick.rb +0 -2
- data/lib/puppet/defaults.rb +52 -3
- data/lib/puppet/network/handler/ca.rb +16 -106
- data/lib/puppet/network/handler/master.rb +0 -3
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/ssl/certificate.rb +6 -0
- data/lib/puppet/ssl/certificate_authority.rb +86 -11
- data/lib/puppet/ssl/certificate_authority/interface.rb +64 -19
- data/lib/puppet/ssl/certificate_factory.rb +112 -91
- data/lib/puppet/ssl/certificate_request.rb +88 -1
- data/lib/puppet/ssl/host.rb +16 -3
- data/lib/puppet/type/file.rb +0 -1
- data/lib/puppet/util/command_line/puppetca +23 -2
- data/lib/puppet/util/monkey_patches.rb +69 -0
- data/lib/puppet/util/settings.rb +5 -0
- data/spec/integration/defaults_spec.rb +11 -0
- data/spec/integration/network/handler_spec.rb +1 -1
- data/spec/unit/configurer_spec.rb +2 -2
- data/spec/unit/network/handler/ca_spec.rb +86 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +92 -53
- data/spec/unit/ssl/certificate_authority_spec.rb +133 -23
- data/spec/unit/ssl/certificate_factory_spec.rb +90 -70
- data/spec/unit/ssl/certificate_request_spec.rb +62 -1
- data/spec/unit/ssl/certificate_spec.rb +31 -0
- data/spec/unit/ssl/host_spec.rb +44 -2
- data/spec/unit/util/settings_spec.rb +10 -0
- data/test/language/functions.rb +0 -1
- data/test/language/snippets.rb +0 -9
- data/test/lib/puppettest/exetest.rb +1 -1
- data/test/lib/puppettest/servertest.rb +0 -1
- data/test/rails/rails.rb +0 -1
- data/test/ral/type/filesources.rb +0 -60
- metadata +5 -34
- data/lib/puppet/network/client.rb +0 -179
- data/lib/puppet/network/client/ca.rb +0 -56
- data/lib/puppet/network/client/file.rb +0 -6
- data/lib/puppet/network/client/proxy.rb +0 -27
- data/lib/puppet/network/client/report.rb +0 -26
- data/lib/puppet/network/client/runner.rb +0 -10
- data/lib/puppet/network/client/status.rb +0 -4
- data/lib/puppet/network/http_server.rb +0 -3
- data/lib/puppet/network/http_server/mongrel.rb +0 -150
- data/lib/puppet/network/http_server/webrick.rb +0 -155
- data/lib/puppet/network/xmlrpc/client.rb +0 -211
- data/lib/puppet/sslcertificates.rb +0 -146
- data/lib/puppet/sslcertificates/ca.rb +0 -375
- data/lib/puppet/sslcertificates/certificate.rb +0 -255
- data/lib/puppet/sslcertificates/inventory.rb +0 -38
- data/lib/puppet/sslcertificates/monkey_patch.rb +0 -6
- data/lib/puppet/sslcertificates/support.rb +0 -146
- data/spec/integration/network/client_spec.rb +0 -19
- data/spec/unit/network/client_spec.rb +0 -45
- data/spec/unit/network/xmlrpc/client_spec.rb +0 -172
- data/spec/unit/sslcertificates/ca_spec.rb +0 -110
- data/test/certmgr/certmgr.rb +0 -308
- data/test/certmgr/inventory.rb +0 -69
- data/test/certmgr/support.rb +0 -105
- data/test/network/client/ca.rb +0 -69
- data/test/network/client/dipper.rb +0 -34
- data/test/network/handler/ca.rb +0 -273
- data/test/network/server/mongrel_test.rb +0 -99
- data/test/network/server/webrick.rb +0 -128
- data/test/network/xmlrpc/client.rb +0 -45
data/lib/puppet/ssl/host.rb
CHANGED
@@ -138,11 +138,24 @@ class Puppet::SSL::Host
|
|
138
138
|
@certificate_request ||= CertificateRequest.find(name)
|
139
139
|
end
|
140
140
|
|
141
|
+
def this_csr_is_for_the_current_host
|
142
|
+
name == Puppet[:certname].downcase
|
143
|
+
end
|
144
|
+
|
141
145
|
# Our certificate request requires the key but that's all.
|
142
|
-
def generate_certificate_request
|
146
|
+
def generate_certificate_request(options = {})
|
143
147
|
generate_key unless key
|
148
|
+
|
149
|
+
# If this is for the current machine...
|
150
|
+
if this_csr_is_for_the_current_host
|
151
|
+
# ...add our configured dns_alt_names
|
152
|
+
if Puppet[:dns_alt_names] and Puppet[:dns_alt_names] != ''
|
153
|
+
options[:dns_alt_names] ||= Puppet[:dns_alt_names]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
144
157
|
@certificate_request = CertificateRequest.new(name)
|
145
|
-
@certificate_request.generate(key.content)
|
158
|
+
@certificate_request.generate(key.content, options)
|
146
159
|
begin
|
147
160
|
@certificate_request.save
|
148
161
|
rescue
|
@@ -185,7 +198,7 @@ class Puppet::SSL::Host
|
|
185
198
|
# should use it to sign our request; else, just try to read
|
186
199
|
# the cert.
|
187
200
|
if ! certificate and ca = Puppet::SSL::CertificateAuthority.instance
|
188
|
-
ca.sign(self.name)
|
201
|
+
ca.sign(self.name, true)
|
189
202
|
end
|
190
203
|
end
|
191
204
|
|
data/lib/puppet/type/file.rb
CHANGED
@@ -56,6 +56,10 @@
|
|
56
56
|
# Generate a certificate for a named client. A certificate/keypair will be
|
57
57
|
# generated for each client named on the command line.
|
58
58
|
#
|
59
|
+
# When generate is used the additional `--subject-alt-name` argument can be
|
60
|
+
# used. The names, separated by `:`, passed will be added as the
|
61
|
+
# subjectAltName of the final certificate.
|
62
|
+
#
|
59
63
|
# help::
|
60
64
|
# Print this help message
|
61
65
|
#
|
@@ -83,6 +87,19 @@
|
|
83
87
|
# Sign an outstanding certificate request. Unless '--all' is specified,
|
84
88
|
# hosts must be listed after all flags.
|
85
89
|
#
|
90
|
+
# Puppet will refuse to sign a CSR that requests a `subjectAltName`
|
91
|
+
# extension unless you specify `--allow-subject-alt-name`. This is required
|
92
|
+
# because of the critical security risks around allowing `subjectAltName`
|
93
|
+
# from client generated certificates.
|
94
|
+
#
|
95
|
+
# To further enforce security, if `--allow-subject-alt-name` is given Puppet
|
96
|
+
# will refuse to sign any certificate that does not have request additional
|
97
|
+
# names.
|
98
|
+
#
|
99
|
+
# Finally, Puppet will still enforce security policy over the
|
100
|
+
# `subjectAltName` field, and will refuse to allow unknown values, or
|
101
|
+
# wildcards, as part of the certificate.
|
102
|
+
#
|
86
103
|
# verbose::
|
87
104
|
# Enable verbosity.
|
88
105
|
#
|
@@ -98,6 +115,12 @@
|
|
98
115
|
# culain.madstop.com
|
99
116
|
# $ puppet cert -s culain.madstop.com
|
100
117
|
#
|
118
|
+
# Signing a certificate with `subjectAltName` set, which will be requested
|
119
|
+
# automatically when you bring up a new master in a distributed CA
|
120
|
+
# environment:
|
121
|
+
#
|
122
|
+
# $ puppet cert --sign --allow-subject-alt-name master12.local
|
123
|
+
#
|
101
124
|
# = Author
|
102
125
|
#
|
103
126
|
# Luke Kanies
|
@@ -106,5 +129,3 @@
|
|
106
129
|
#
|
107
130
|
# Copyright (c) 2005 Puppet Labs, LLC
|
108
131
|
# Licensed under the GNU Public License
|
109
|
-
|
110
|
-
#Puppet::Application[:cert].run
|
@@ -69,3 +69,72 @@ class Object
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
# Workaround for yaml_initialize, which isn't supported before Ruby
|
74
|
+
# 1.8.3.
|
75
|
+
if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2'
|
76
|
+
YAML.add_ruby_type( /^object/ ) { |tag, val|
|
77
|
+
type, obj_class = YAML.read_type_class( tag, Object )
|
78
|
+
r = YAML.object_maker( obj_class, val )
|
79
|
+
if r.respond_to? :yaml_initialize
|
80
|
+
r.instance_eval { instance_variables.each { |name| remove_instance_variable name } }
|
81
|
+
r.yaml_initialize(tag, val)
|
82
|
+
end
|
83
|
+
r
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
class Array
|
88
|
+
# Ruby < 1.8.7 doesn't have this method but we use it in tests
|
89
|
+
def combination(num)
|
90
|
+
return [] if num < 0 || num > size
|
91
|
+
return [[]] if num == 0
|
92
|
+
return map{|e| [e] } if num == 1
|
93
|
+
tmp = self.dup
|
94
|
+
self[0, size - (num - 1)].inject([]) do |ret, e|
|
95
|
+
tmp.shift
|
96
|
+
ret += tmp.combination(num - 1).map{|a| a.unshift(e) }
|
97
|
+
end
|
98
|
+
end unless method_defined? :combination
|
99
|
+
|
100
|
+
alias :count :length unless method_defined? :count
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
class Symbol
|
105
|
+
def to_proc
|
106
|
+
Proc.new { |*args| args.shift.__send__(self, *args) }
|
107
|
+
end unless method_defined? :to_proc
|
108
|
+
end
|
109
|
+
|
110
|
+
module Enumerable
|
111
|
+
# Use *args so we can distinguish no argument from nil.
|
112
|
+
def count(*args)
|
113
|
+
seq = 0
|
114
|
+
if !args.empty?
|
115
|
+
item = args[0]
|
116
|
+
each { |o| seq += 1 if item == o }
|
117
|
+
elsif block_given?
|
118
|
+
each { |o| seq += 1 if yield(o) }
|
119
|
+
else
|
120
|
+
each { seq += 1 }
|
121
|
+
end
|
122
|
+
seq
|
123
|
+
end unless method_defined? :count
|
124
|
+
end
|
125
|
+
|
126
|
+
class String
|
127
|
+
def lines(separator = $/)
|
128
|
+
lines = split(separator)
|
129
|
+
block_given? and lines.each {|line| yield line }
|
130
|
+
lines
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class IO
|
135
|
+
def lines(separator = $/)
|
136
|
+
lines = split(separator)
|
137
|
+
block_given? and lines.each {|line| yield line }
|
138
|
+
lines
|
139
|
+
end
|
140
|
+
end
|
data/lib/puppet/util/settings.rb
CHANGED
@@ -495,6 +495,11 @@ class Puppet::Util::Settings
|
|
495
495
|
end
|
496
496
|
type = legacy_to_mode(type, param)
|
497
497
|
@sync.synchronize do # yay, thread-safe
|
498
|
+
# Allow later inspection to determine if the setting was set on the
|
499
|
+
# command line, or through some other code path. Used for the
|
500
|
+
# `dns_alt_names` option during cert generate. --daniel 2011-10-18
|
501
|
+
setting.setbycli = true if type == :cli
|
502
|
+
|
498
503
|
@values[type][param] = value
|
499
504
|
@cache.clear
|
500
505
|
|
@@ -45,6 +45,17 @@ describe "Puppet defaults" do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
describe "when :certdnsnames is set" do
|
49
|
+
it "should not fail" do
|
50
|
+
expect { Puppet[:certdnsnames] = 'fred:wilma' }.should_not raise_error
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should warn the value is ignored" do
|
54
|
+
Puppet.expects(:warning).with {|msg| msg =~ /CVE-2011-3872/ }
|
55
|
+
Puppet[:certdnsnames] = 'fred:wilma'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
48
59
|
describe "when configuring the :crl" do
|
49
60
|
it "should warn if :cacrl is set to false" do
|
50
61
|
Puppet.expects(:warning)
|
@@ -242,7 +242,7 @@ describe Puppet::Configurer do
|
|
242
242
|
Puppet.settings[:prerun_command] = "/my/command"
|
243
243
|
Puppet::Util.expects(:execute).with(["/my/command"]).raises(Puppet::ExecutionFailure, "Failed")
|
244
244
|
|
245
|
-
report.expects(:<<).with { |log| log.message.
|
245
|
+
report.expects(:<<).with { |log| log.message.include?("Could not run command from prerun_command") }
|
246
246
|
|
247
247
|
@agent.run.should be_nil
|
248
248
|
end
|
@@ -265,7 +265,7 @@ describe Puppet::Configurer do
|
|
265
265
|
Puppet.settings[:postrun_command] = "/my/command"
|
266
266
|
Puppet::Util.expects(:execute).with(["/my/command"]).raises(Puppet::ExecutionFailure, "Failed")
|
267
267
|
|
268
|
-
report.expects(:<<).with { |log| log.message.
|
268
|
+
report.expects(:<<).with { |log| log.message.include?("Could not run command from postrun_command") }
|
269
269
|
|
270
270
|
@agent.run.should be_nil
|
271
271
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'puppet/network/handler/ca'
|
4
|
+
|
5
|
+
describe Puppet::Network::Handler::CA do
|
6
|
+
include PuppetSpec::Files
|
7
|
+
|
8
|
+
describe "#getcert" do
|
9
|
+
let(:host) { "testhost" }
|
10
|
+
let(:x509_name) { OpenSSL::X509::Name.new [['CN', host]] }
|
11
|
+
let(:key) { Puppet::SSL::Key.new(host).generate }
|
12
|
+
|
13
|
+
let(:csr) do
|
14
|
+
csr = OpenSSL::X509::Request.new
|
15
|
+
csr.subject = x509_name
|
16
|
+
csr.public_key = key.public_key
|
17
|
+
csr
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:ca) { Puppet::SSL::CertificateAuthority.new }
|
21
|
+
let(:cacert) { ca.instance_variable_get(:@certificate) }
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
Puppet[:confdir] = tmpdir('conf')
|
25
|
+
|
26
|
+
Puppet::SSL::CertificateAuthority.stubs(:ca?).returns true
|
27
|
+
Puppet::SSL::CertificateAuthority.stubs(:singleton_instance).returns ca
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should do nothing if the master is not a CA" do
|
31
|
+
Puppet::SSL::CertificateAuthority.stubs(:ca?).returns false
|
32
|
+
|
33
|
+
csr = OpenSSL::X509::Request.new
|
34
|
+
subject.getcert(csr.to_pem).should == ''
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when a certificate already exists for the host" do
|
38
|
+
let!(:cert) { ca.generate(host) }
|
39
|
+
|
40
|
+
it "should return the existing cert if it matches the public key of the CSR" do
|
41
|
+
csr.public_key = cert.content.public_key
|
42
|
+
|
43
|
+
subject.getcert(csr.to_pem).should == [cert.to_s, cacert.to_s]
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should fail if the public key of the CSR does not match the existing cert" do
|
47
|
+
expect do
|
48
|
+
subject.getcert(csr.to_pem)
|
49
|
+
end.to raise_error(Puppet::Error, /Certificate request does not match existing certificate/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when autosign is enabled" do
|
54
|
+
before :each do
|
55
|
+
Puppet[:autosign] = true
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return the new cert and the CA cert" do
|
59
|
+
cert_str, cacert_str = subject.getcert(csr.to_pem)
|
60
|
+
|
61
|
+
returned_cert = Puppet::SSL::Certificate.from_s(cert_str)
|
62
|
+
returned_cacert = Puppet::SSL::Certificate.from_s(cacert_str)
|
63
|
+
|
64
|
+
returned_cert.name.should == host
|
65
|
+
returned_cacert.content.subject.cmp(cacert.content.subject).should == 0
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "when autosign is disabled" do
|
70
|
+
before :each do
|
71
|
+
Puppet[:autosign] = false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should save the CSR without signing it" do
|
75
|
+
subject.getcert(csr.to_pem)
|
76
|
+
|
77
|
+
Puppet::SSL::Certificate.find(host).should be_nil
|
78
|
+
Puppet::SSL::CertificateRequest.find(host).should be_a(Puppet::SSL::CertificateRequest)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not return a cert" do
|
82
|
+
subject.getcert(csr.to_pem).should be_nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -32,13 +32,13 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
32
32
|
end
|
33
33
|
describe "when initializing" do
|
34
34
|
it "should set its method using its settor" do
|
35
|
-
@class.
|
36
|
-
|
35
|
+
instance = @class.new(:generate, :to => :all)
|
36
|
+
instance.method.should == :generate
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should set its subjects using the settor" do
|
40
|
-
@class.
|
41
|
-
|
40
|
+
instance = @class.new(:generate, :to => :all)
|
41
|
+
instance.subjects.should == :all
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should set the digest if given" do
|
@@ -54,23 +54,27 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
54
54
|
|
55
55
|
describe "when setting the method" do
|
56
56
|
it "should set the method" do
|
57
|
-
@class.new(:generate, :to => :all)
|
57
|
+
instance = @class.new(:generate, :to => :all)
|
58
|
+
instance.method = :list
|
59
|
+
|
60
|
+
instance.method.should == :list
|
58
61
|
end
|
59
62
|
|
60
63
|
it "should fail if the method isn't a member of the INTERFACE_METHODS array" do
|
61
|
-
|
62
|
-
|
63
|
-
lambda { @class.new(:thing, :to => :all) }.should raise_error(ArgumentError)
|
64
|
+
lambda { @class.new(:thing, :to => :all) }.should raise_error(ArgumentError, /Invalid method thing to apply/)
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
describe "when setting the subjects" do
|
68
69
|
it "should set the subjects" do
|
69
|
-
@class.new(:generate, :to => :all)
|
70
|
+
instance = @class.new(:generate, :to => :all)
|
71
|
+
instance.subjects = :signed
|
72
|
+
|
73
|
+
instance.subjects.should == :signed
|
70
74
|
end
|
71
75
|
|
72
76
|
it "should fail if the subjects setting isn't :all or an array" do
|
73
|
-
lambda { @class.new(:generate, "other") }.should raise_error(ArgumentError)
|
77
|
+
lambda { @class.new(:generate, :to => "other") }.should raise_error(ArgumentError, /Subjects must be an array or :all; not other/)
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
@@ -118,8 +122,8 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
118
122
|
it "should call :generate on the CA for each host specified" do
|
119
123
|
@applier = @class.new(:generate, :to => %w{host1 host2})
|
120
124
|
|
121
|
-
@ca.expects(:generate).with("host1")
|
122
|
-
@ca.expects(:generate).with("host2")
|
125
|
+
@ca.expects(:generate).with("host1", {})
|
126
|
+
@ca.expects(:generate).with("host2", {})
|
123
127
|
|
124
128
|
@applier.apply(@ca)
|
125
129
|
end
|
@@ -150,15 +154,24 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
150
154
|
|
151
155
|
describe ":sign" do
|
152
156
|
describe "and an array of names was provided" do
|
153
|
-
|
154
|
-
@applier = @class.new(:sign, :to => %w{host1 host2})
|
155
|
-
end
|
157
|
+
let(:applier) { @class.new(:sign, @options.merge(:to => %w{host1 host2})) }
|
156
158
|
|
157
159
|
it "should sign the specified waiting certificate requests" do
|
158
|
-
@
|
159
|
-
@ca.expects(:sign).with("host2")
|
160
|
+
@options = {:allow_dns_alt_names => false}
|
160
161
|
|
161
|
-
@
|
162
|
+
@ca.expects(:sign).with("host1", false)
|
163
|
+
@ca.expects(:sign).with("host2", false)
|
164
|
+
|
165
|
+
applier.apply(@ca)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should sign the certificate requests with alt names if specified" do
|
169
|
+
@options = {:allow_dns_alt_names => true}
|
170
|
+
|
171
|
+
@ca.expects(:sign).with("host1", true)
|
172
|
+
@ca.expects(:sign).with("host2", true)
|
173
|
+
|
174
|
+
applier.apply(@ca)
|
162
175
|
end
|
163
176
|
end
|
164
177
|
|
@@ -166,8 +179,8 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
166
179
|
it "should sign all waiting certificate requests" do
|
167
180
|
@ca.stubs(:waiting?).returns(%w{cert1 cert2})
|
168
181
|
|
169
|
-
@ca.expects(:sign).with("cert1")
|
170
|
-
@ca.expects(:sign).with("cert2")
|
182
|
+
@ca.expects(:sign).with("cert1", nil)
|
183
|
+
@ca.expects(:sign).with("cert2", nil)
|
171
184
|
|
172
185
|
@applier = @class.new(:sign, :to => :all)
|
173
186
|
@applier.apply(@ca)
|
@@ -183,63 +196,89 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
183
196
|
end
|
184
197
|
|
185
198
|
describe ":list" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
199
|
+
before :each do
|
200
|
+
certish = stub('certish', :subject_alt_names => [])
|
201
|
+
Puppet::SSL::Certificate.indirection.stubs(:find).returns certish
|
202
|
+
Puppet::SSL::CertificateRequest.indirection.stubs(:find).returns certish
|
203
|
+
|
204
|
+
@ca.expects(:waiting?).returns %w{host1 host2 host3}
|
205
|
+
@ca.expects(:list).returns %w{host4 host5 host6}
|
206
|
+
@ca.stubs(:fingerprint).returns "fingerprint"
|
207
|
+
@ca.stubs(:verify)
|
208
|
+
end
|
190
209
|
|
191
|
-
|
210
|
+
describe "and an empty array was provided" do
|
211
|
+
it "should print all certificate requests" do
|
212
|
+
applier = @class.new(:list, :to => [])
|
192
213
|
|
193
|
-
|
214
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
215
|
+
host1 (fingerprint)
|
216
|
+
host2 (fingerprint)
|
217
|
+
host3 (fingerprint)
|
218
|
+
OUTPUT
|
194
219
|
|
195
|
-
|
220
|
+
applier.apply(@ca)
|
196
221
|
end
|
197
222
|
end
|
198
223
|
|
199
224
|
describe "and :all was provided" do
|
200
225
|
it "should print a string containing all certificate requests and certificates" do
|
201
|
-
@ca.
|
202
|
-
@ca.expects(:list).returns %w{host3 host4}
|
203
|
-
@ca.stubs(:verify)
|
204
|
-
@ca.stubs(:fingerprint).returns "fingerprint"
|
205
|
-
@ca.expects(:verify).with("host3").raises(Puppet::SSL::CertificateAuthority::CertificateVerificationError.new(23), "certificate revoked")
|
226
|
+
@ca.stubs(:verify).with("host4").raises(Puppet::SSL::CertificateAuthority::CertificateVerificationError.new(23), "certificate revoked")
|
206
227
|
|
207
|
-
|
228
|
+
applier = @class.new(:list, :to => :all)
|
208
229
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
230
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
231
|
+
host1 (fingerprint)
|
232
|
+
host2 (fingerprint)
|
233
|
+
host3 (fingerprint)
|
234
|
+
+ host5 (fingerprint)
|
235
|
+
+ host6 (fingerprint)
|
236
|
+
- host4 (fingerprint) (certificate revoked)
|
237
|
+
OUTPUT
|
213
238
|
|
214
|
-
|
239
|
+
applier.apply(@ca)
|
215
240
|
end
|
216
241
|
end
|
217
242
|
|
218
243
|
describe "and :signed was provided" do
|
219
244
|
it "should print a string containing all signed certificate requests and certificates" do
|
220
|
-
@
|
245
|
+
applier = @class.new(:list, :to => :signed)
|
221
246
|
|
222
|
-
|
247
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
248
|
+
+ host4 (fingerprint)
|
249
|
+
+ host5 (fingerprint)
|
250
|
+
+ host6 (fingerprint)
|
251
|
+
OUTPUT
|
223
252
|
|
224
|
-
|
253
|
+
applier.apply(@ca)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should include subject alt names if they are on the certificate request" do
|
257
|
+
request = stub 'request', :subject_alt_names => ["DNS:foo", "DNS:bar"]
|
258
|
+
Puppet::SSL::CertificateRequest.indirection.stubs(:find).returns(request)
|
259
|
+
|
260
|
+
applier = @class.new(:list, :to => ['host1'])
|
261
|
+
|
262
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
263
|
+
host1 (fingerprint) (alt names: DNS:foo, DNS:bar)
|
264
|
+
OUTPUT
|
265
|
+
|
266
|
+
applier.apply(@ca)
|
225
267
|
end
|
226
268
|
end
|
227
269
|
|
228
270
|
describe "and an array of names was provided" do
|
229
|
-
it "should print
|
230
|
-
@
|
231
|
-
@ca.expects(:list).returns %w{host3 host4}
|
232
|
-
@ca.stubs(:fingerprint).returns "fingerprint"
|
233
|
-
@ca.stubs(:verify)
|
234
|
-
|
235
|
-
@applier = @class.new(:list, :to => %w{host1 host2 host3 host4})
|
271
|
+
it "should print all named hosts" do
|
272
|
+
applier = @class.new(:list, :to => %w{host1 host2 host4 host5})
|
236
273
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
274
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
275
|
+
host1 (fingerprint)
|
276
|
+
host2 (fingerprint)
|
277
|
+
+ host4 (fingerprint)
|
278
|
+
+ host5 (fingerprint)
|
279
|
+
OUTPUT
|
241
280
|
|
242
|
-
|
281
|
+
applier.apply(@ca)
|
243
282
|
end
|
244
283
|
end
|
245
284
|
end
|