puppet 2.7.5 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/CHANGELOG +121 -0
  2. data/conf/redhat/puppet.spec +16 -7
  3. data/lib/puppet.rb +1 -1
  4. data/lib/puppet/application/cert.rb +17 -3
  5. data/lib/puppet/application/device.rb +1 -0
  6. data/lib/puppet/application/kick.rb +0 -2
  7. data/lib/puppet/application/resource.rb +73 -66
  8. data/lib/puppet/configurer/plugin_handler.rb +6 -2
  9. data/lib/puppet/defaults.rb +60 -5
  10. data/lib/puppet/face/ca.rb +11 -2
  11. data/lib/puppet/face/certificate.rb +33 -4
  12. data/lib/puppet/file_serving/fileset.rb +1 -1
  13. data/lib/puppet/file_serving/indirection_hooks.rb +2 -2
  14. data/lib/puppet/file_serving/metadata.rb +43 -4
  15. data/lib/puppet/indirector.rb +0 -1
  16. data/lib/puppet/indirector/request.rb +3 -4
  17. data/lib/puppet/indirector/resource/active_record.rb +3 -10
  18. data/lib/puppet/indirector/resource/ral.rb +2 -2
  19. data/lib/puppet/indirector/rest.rb +1 -1
  20. data/lib/puppet/network/handler/ca.rb +16 -106
  21. data/lib/puppet/network/handler/master.rb +0 -3
  22. data/lib/puppet/network/handler/runner.rb +1 -0
  23. data/lib/puppet/parser/scope.rb +10 -0
  24. data/lib/puppet/provider/file/posix.rb +72 -34
  25. data/lib/puppet/provider/file/windows.rb +100 -0
  26. data/lib/puppet/provider/group/windows_adsi.rb +2 -2
  27. data/lib/puppet/provider/user/windows_adsi.rb +19 -4
  28. data/lib/puppet/resource.rb +16 -0
  29. data/lib/puppet/resource/catalog.rb +1 -1
  30. data/lib/puppet/ssl/certificate.rb +2 -2
  31. data/lib/puppet/ssl/certificate_authority.rb +86 -10
  32. data/lib/puppet/ssl/certificate_authority/interface.rb +64 -19
  33. data/lib/puppet/ssl/certificate_factory.rb +112 -91
  34. data/lib/puppet/ssl/certificate_request.rb +88 -1
  35. data/lib/puppet/ssl/host.rb +20 -3
  36. data/lib/puppet/type/file.rb +15 -34
  37. data/lib/puppet/type/file/group.rb +11 -91
  38. data/lib/puppet/type/file/mode.rb +11 -41
  39. data/lib/puppet/type/file/owner.rb +18 -34
  40. data/lib/puppet/type/file/source.rb +22 -7
  41. data/lib/puppet/type/group.rb +4 -3
  42. data/lib/puppet/type/user.rb +4 -1
  43. data/lib/puppet/util.rb +59 -6
  44. data/lib/puppet/util/adsi.rb +11 -0
  45. data/lib/puppet/util/log.rb +4 -0
  46. data/lib/puppet/util/log/destinations.rb +7 -1
  47. data/lib/puppet/util/monkey_patches.rb +19 -0
  48. data/lib/puppet/util/network_device/config.rb +4 -5
  49. data/lib/puppet/util/settings.rb +5 -0
  50. data/lib/puppet/util/suidmanager.rb +0 -1
  51. data/lib/puppet/util/windows.rb +4 -0
  52. data/lib/puppet/util/windows/error.rb +16 -0
  53. data/lib/puppet/util/windows/security.rb +593 -0
  54. data/spec/integration/defaults_spec.rb +27 -0
  55. data/spec/integration/network/handler_spec.rb +1 -1
  56. data/spec/integration/type/file_spec.rb +382 -145
  57. data/spec/integration/util/windows/security_spec.rb +468 -0
  58. data/spec/shared_behaviours/file_serving.rb +4 -3
  59. data/spec/unit/application/agent_spec.rb +1 -0
  60. data/spec/unit/application/device_spec.rb +5 -0
  61. data/spec/unit/application/resource_spec.rb +62 -101
  62. data/spec/unit/configurer/downloader_spec.rb +2 -2
  63. data/spec/unit/configurer/plugin_handler_spec.rb +15 -8
  64. data/spec/unit/configurer_spec.rb +2 -2
  65. data/spec/unit/face/ca_spec.rb +34 -0
  66. data/spec/unit/face/certificate_spec.rb +168 -1
  67. data/spec/unit/file_serving/fileset_spec.rb +1 -1
  68. data/spec/unit/file_serving/indirection_hooks_spec.rb +1 -1
  69. data/spec/unit/file_serving/metadata_spec.rb +151 -107
  70. data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -3
  71. data/spec/unit/indirector/direct_file_server_spec.rb +10 -9
  72. data/spec/unit/indirector/file_metadata/file_spec.rb +6 -4
  73. data/spec/unit/indirector/request_spec.rb +13 -3
  74. data/spec/unit/indirector/resource/active_record_spec.rb +4 -10
  75. data/spec/unit/indirector/resource/ral_spec.rb +6 -4
  76. data/spec/unit/indirector/rest_spec.rb +5 -6
  77. data/spec/unit/network/handler/ca_spec.rb +86 -0
  78. data/spec/unit/parser/collector_spec.rb +7 -7
  79. data/spec/unit/parser/scope_spec.rb +20 -0
  80. data/spec/unit/provider/file/posix_spec.rb +226 -0
  81. data/spec/unit/provider/file/windows_spec.rb +136 -0
  82. data/spec/unit/provider/group/windows_adsi_spec.rb +7 -2
  83. data/spec/unit/provider/user/windows_adsi_spec.rb +36 -3
  84. data/spec/unit/resource/catalog_spec.rb +20 -10
  85. data/spec/unit/resource_spec.rb +55 -8
  86. data/spec/unit/ssl/certificate_authority/interface_spec.rb +97 -54
  87. data/spec/unit/ssl/certificate_authority_spec.rb +133 -23
  88. data/spec/unit/ssl/certificate_factory_spec.rb +90 -70
  89. data/spec/unit/ssl/certificate_request_spec.rb +62 -1
  90. data/spec/unit/ssl/certificate_spec.rb +20 -14
  91. data/spec/unit/ssl/host_spec.rb +52 -6
  92. data/spec/unit/type/file/content_spec.rb +4 -4
  93. data/spec/unit/type/file/group_spec.rb +34 -96
  94. data/spec/unit/type/file/mode_spec.rb +88 -0
  95. data/spec/unit/type/file/owner_spec.rb +32 -123
  96. data/spec/unit/type/file/source_spec.rb +120 -41
  97. data/spec/unit/type/file_spec.rb +1033 -753
  98. data/spec/unit/type_spec.rb +19 -1
  99. data/spec/unit/util/adsi_spec.rb +19 -0
  100. data/spec/unit/util/log/destinations_spec.rb +75 -0
  101. data/spec/unit/util/log_spec.rb +15 -0
  102. data/spec/unit/util/network_device/config_spec.rb +7 -0
  103. data/spec/unit/util/settings_spec.rb +10 -0
  104. data/spec/unit/util_spec.rb +126 -13
  105. data/test/language/functions.rb +0 -1
  106. data/test/language/snippets.rb +0 -9
  107. data/test/lib/puppettest/exetest.rb +1 -1
  108. data/test/lib/puppettest/servertest.rb +0 -1
  109. data/test/rails/rails.rb +0 -1
  110. data/test/ral/type/filesources.rb +0 -60
  111. metadata +13 -33
  112. data/lib/puppet/network/client.rb +0 -174
  113. data/lib/puppet/network/client/ca.rb +0 -56
  114. data/lib/puppet/network/client/file.rb +0 -6
  115. data/lib/puppet/network/client/proxy.rb +0 -27
  116. data/lib/puppet/network/client/report.rb +0 -26
  117. data/lib/puppet/network/client/runner.rb +0 -10
  118. data/lib/puppet/network/client/status.rb +0 -4
  119. data/lib/puppet/network/http_server.rb +0 -3
  120. data/lib/puppet/network/http_server/mongrel.rb +0 -130
  121. data/lib/puppet/network/http_server/webrick.rb +0 -155
  122. data/lib/puppet/network/xmlrpc/client.rb +0 -211
  123. data/lib/puppet/provider/file/win32.rb +0 -72
  124. data/lib/puppet/sslcertificates.rb +0 -146
  125. data/lib/puppet/sslcertificates/ca.rb +0 -375
  126. data/lib/puppet/sslcertificates/certificate.rb +0 -255
  127. data/lib/puppet/sslcertificates/inventory.rb +0 -38
  128. data/lib/puppet/sslcertificates/support.rb +0 -146
  129. data/spec/integration/network/client_spec.rb +0 -18
  130. data/spec/unit/network/xmlrpc/client_spec.rb +0 -172
  131. data/spec/unit/sslcertificates/ca_spec.rb +0 -106
  132. data/test/certmgr/certmgr.rb +0 -308
  133. data/test/certmgr/inventory.rb +0 -69
  134. data/test/certmgr/support.rb +0 -105
  135. data/test/network/client/ca.rb +0 -69
  136. data/test/network/client/dipper.rb +0 -34
  137. data/test/network/handler/ca.rb +0 -273
  138. data/test/network/server/mongrel_test.rb +0 -99
  139. data/test/network/server/webrick.rb +0 -111
  140. data/test/network/xmlrpc/client.rb +0 -45
@@ -43,13 +43,14 @@ shared_examples_for "Puppet::FileServing::Files" do
43
43
  end
44
44
 
45
45
  it "should use the file terminus when the 'file' URI scheme is used" do
46
- uri = "file:///fakemod/my/file"
46
+ uri = Puppet::Util.path_to_uri(File.expand_path('/fakemod/my/other file'))
47
+ uri.scheme.should == 'file'
47
48
  @indirection.terminus(:file).expects(:find)
48
- @indirection.find(uri)
49
+ @indirection.find(uri.to_s)
49
50
  end
50
51
 
51
52
  it "should use the file terminus when a fully qualified path is provided" do
52
- uri = "/fakemod/my/file"
53
+ uri = File.expand_path("/fakemod/my/file")
53
54
  @indirection.terminus(:file).expects(:find)
54
55
  @indirection.find(uri)
55
56
  end
@@ -367,6 +367,7 @@ describe Puppet::Application::Agent do
367
367
  end
368
368
 
369
369
  it "should daemonize if needed" do
370
+ Puppet.features.stubs(:microsoft_windows?).returns false
370
371
  Puppet[:daemonize] = true
371
372
 
372
373
  @daemon.expects(:daemonize)
@@ -338,6 +338,11 @@ describe Puppet::Application::Device do
338
338
  @device.main
339
339
  end
340
340
 
341
+ it "should expire all cached attributes" do
342
+ Puppet::SSL::Host.expects(:reset).twice
343
+
344
+ @device.main
345
+ end
341
346
  end
342
347
  end
343
348
  end
@@ -5,71 +5,38 @@ require 'puppet/application/resource'
5
5
 
6
6
  describe Puppet::Application::Resource do
7
7
  before :each do
8
- @resource = Puppet::Application[:resource]
8
+ @resource_app = Puppet::Application[:resource]
9
9
  Puppet::Util::Log.stubs(:newdestination)
10
10
  Puppet::Resource.indirection.stubs(:terminus_class=)
11
11
  end
12
12
 
13
13
  it "should ask Puppet::Application to not parse Puppet configuration file" do
14
- @resource.should_parse_config?.should be_false
15
- end
16
-
17
- it "should declare a main command" do
18
- @resource.should respond_to(:main)
19
- end
20
-
21
- it "should declare a host option" do
22
- @resource.should respond_to(:handle_host)
23
- end
24
-
25
- it "should declare a types option" do
26
- @resource.should respond_to(:handle_types)
27
- end
28
-
29
- it "should declare a param option" do
30
- @resource.should respond_to(:handle_param)
31
- end
32
-
33
- it "should declare a preinit block" do
34
- @resource.should respond_to(:preinit)
14
+ @resource_app.should_parse_config?.should be_false
35
15
  end
36
16
 
37
17
  describe "in preinit" do
38
- it "should set hosts to nil", :'fails_on_ruby_1.9.2' => true do
39
- @resource.preinit
40
-
41
- @resource.host.should be_nil
42
- end
43
-
44
18
  it "should init extra_params to empty array", :'fails_on_ruby_1.9.2' => true do
45
- @resource.preinit
46
-
47
- @resource.extra_params.should == []
19
+ @resource_app.preinit
20
+ @resource_app.extra_params.should == []
48
21
  end
49
22
 
50
23
  it "should load Facter facts" do
51
24
  Facter.expects(:loadfacts).once
52
- @resource.preinit
25
+ @resource_app.preinit
53
26
  end
54
27
  end
55
28
 
56
29
  describe "when handling options" do
57
-
58
30
  [:debug, :verbose, :edit].each do |option|
59
- it "should declare handle_#{option} method" do
60
- @resource.should respond_to("handle_#{option}".to_sym)
61
- end
62
-
63
31
  it "should store argument value when calling handle_#{option}" do
64
- @resource.options.expects(:[]=).with(option, 'arg')
65
- @resource.send("handle_#{option}".to_sym, 'arg')
32
+ @resource_app.options.expects(:[]=).with(option, 'arg')
33
+ @resource_app.send("handle_#{option}".to_sym, 'arg')
66
34
  end
67
35
  end
68
36
 
69
37
  it "should set options[:host] to given host" do
70
- @resource.handle_host(:whatever)
71
-
72
- @resource.host.should == :whatever
38
+ @resource_app.handle_host(:whatever)
39
+ @resource_app.host.should == :whatever
73
40
  end
74
41
 
75
42
  it "should load an display all types with types option" do
@@ -77,15 +44,15 @@ describe Puppet::Application::Resource do
77
44
  type2 = stub_everything 'type2', :name => :type2
78
45
  Puppet::Type.stubs(:loadall)
79
46
  Puppet::Type.stubs(:eachtype).multiple_yields(type1,type2)
80
- @resource.expects(:puts).with(['type1','type2'])
81
- expect { @resource.handle_types(nil) }.to exit_with 0
47
+ @resource_app.expects(:puts).with(['type1','type2'])
48
+ expect { @resource_app.handle_types(nil) }.to exit_with 0
82
49
  end
83
50
 
84
51
  it "should add param to extra_params list" do
85
- @resource.extra_params = [ :param1 ]
86
- @resource.handle_param("whatever")
52
+ @resource_app.extra_params = [ :param1 ]
53
+ @resource_app.handle_param("whatever")
87
54
 
88
- @resource.extra_params.should == [ :param1, :whatever ]
55
+ @resource_app.extra_params.should == [ :param1, :whatever ]
89
56
  end
90
57
  end
91
58
 
@@ -95,63 +62,65 @@ describe Puppet::Application::Resource do
95
62
  Puppet.stubs(:parse_config)
96
63
  end
97
64
 
98
-
99
65
  it "should set console as the log destination" do
100
66
  Puppet::Log.expects(:newdestination).with(:console)
101
67
 
102
- @resource.setup
68
+ @resource_app.setup
103
69
  end
104
70
 
105
71
  it "should set log level to debug if --debug was passed" do
106
- @resource.options.stubs(:[]).with(:debug).returns(true)
107
- @resource.setup
72
+ @resource_app.options.stubs(:[]).with(:debug).returns(true)
73
+ @resource_app.setup
108
74
  Puppet::Log.level.should == :debug
109
75
  end
110
76
 
111
77
  it "should set log level to info if --verbose was passed" do
112
- @resource.options.stubs(:[]).with(:debug).returns(false)
113
- @resource.options.stubs(:[]).with(:verbose).returns(true)
114
- @resource.setup
78
+ @resource_app.options.stubs(:[]).with(:debug).returns(false)
79
+ @resource_app.options.stubs(:[]).with(:verbose).returns(true)
80
+ @resource_app.setup
115
81
  Puppet::Log.level.should == :info
116
82
  end
117
83
 
118
84
  it "should Parse puppet config" do
119
85
  Puppet.expects(:parse_config)
120
86
 
121
- @resource.setup
87
+ @resource_app.setup
122
88
  end
123
89
  end
124
90
 
125
91
  describe "when running" do
126
-
127
92
  before :each do
128
93
  @type = stub_everything 'type', :properties => []
129
- @resource.command_line.stubs(:args).returns(['type'])
94
+ @resource_app.command_line.stubs(:args).returns(['mytype'])
130
95
  Puppet::Type.stubs(:type).returns(@type)
96
+
97
+ @res = stub_everything "resource"
98
+ @res.stubs(:prune_parameters).returns(@res)
99
+ @report = stub_everything "report"
131
100
  end
132
101
 
133
102
  it "should raise an error if no type is given" do
134
- @resource.command_line.stubs(:args).returns([])
135
- lambda { @resource.main }.should raise_error
103
+ @resource_app.command_line.stubs(:args).returns([])
104
+ lambda { @resource_app.main }.should raise_error(RuntimeError, "You must specify the type to display")
136
105
  end
137
106
 
138
107
  it "should raise an error when editing a remote host" do
139
- @resource.options.stubs(:[]).with(:edit).returns(true)
140
- @resource.host = 'host'
108
+ @resource_app.options.stubs(:[]).with(:edit).returns(true)
109
+ @resource_app.host = 'host'
141
110
 
142
- lambda { @resource.main }.should raise_error
111
+ lambda { @resource_app.main }.should raise_error(RuntimeError, "You cannot edit a remote host")
143
112
  end
144
113
 
145
114
  it "should raise an error if the type is not found" do
146
115
  Puppet::Type.stubs(:type).returns(nil)
147
116
 
148
- lambda { @resource.main }.should raise_error
117
+ lambda { @resource_app.main }.should raise_error(RuntimeError, 'Could not find type mytype')
149
118
  end
150
119
 
151
120
  describe "with a host" do
152
121
  before :each do
153
- @resource.stubs(:puts)
154
- @resource.host = 'host'
122
+ @resource_app.stubs(:puts)
123
+ @resource_app.host = 'host'
155
124
 
156
125
  Puppet::Resource.indirection.stubs(:find ).never
157
126
  Puppet::Resource.indirection.stubs(:search).never
@@ -159,36 +128,33 @@ describe Puppet::Application::Resource do
159
128
  end
160
129
 
161
130
  it "should search for resources" do
162
- @resource.command_line.stubs(:args).returns(['type'])
131
+ @resource_app.command_line.stubs(:args).returns(['type'])
163
132
  Puppet::Resource.indirection.expects(:search).with('https://host:8139/production/resources/type/', {}).returns([])
164
- @resource.main
133
+ @resource_app.main
165
134
  end
166
135
 
167
136
  it "should describe the given resource" do
168
- @resource.command_line.stubs(:args).returns(['type', 'name'])
169
- x = stub_everything 'resource'
170
- Puppet::Resource.indirection.expects(:find).with('https://host:8139/production/resources/type/name').returns(x)
171
- @resource.main
137
+ @resource_app.command_line.stubs(:args).returns(['type', 'name'])
138
+ Puppet::Resource.indirection.expects(:find).with('https://host:8139/production/resources/type/name').returns(@res)
139
+ @resource_app.main
172
140
  end
173
141
 
174
142
  it "should add given parameters to the object" do
175
- @resource.command_line.stubs(:args).returns(['type','name','param=temp'])
143
+ @resource_app.command_line.stubs(:args).returns(['type','name','param=temp'])
176
144
 
177
- res = stub "resource"
178
- Puppet::Resource.indirection.expects(:save).with(res, 'https://host:8139/production/resources/type/name').returns(res)
179
- res.expects(:collect)
180
- res.expects(:to_manifest)
181
- Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(res)
145
+ Puppet::Resource.indirection.expects(:save).
146
+ with(@res, 'https://host:8139/production/resources/type/name').
147
+ returns([@res, @report])
148
+ Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(@res)
182
149
 
183
- @resource.main
150
+ @resource_app.main
184
151
  end
185
-
186
152
  end
187
153
 
188
154
  describe "without a host" do
189
155
  before :each do
190
- @resource.stubs(:puts)
191
- @resource.host = nil
156
+ @resource_app.stubs(:puts)
157
+ @resource_app.host = nil
192
158
 
193
159
  Puppet::Resource.indirection.stubs(:find ).never
194
160
  Puppet::Resource.indirection.stubs(:search).never
@@ -196,42 +162,37 @@ describe Puppet::Application::Resource do
196
162
  end
197
163
 
198
164
  it "should search for resources" do
199
- Puppet::Resource.indirection.expects(:search).with('type/', {}).returns([])
200
- @resource.main
165
+ Puppet::Resource.indirection.expects(:search).with('mytype/', {}).returns([])
166
+ @resource_app.main
201
167
  end
202
168
 
203
169
  it "should describe the given resource" do
204
- @resource.command_line.stubs(:args).returns(['type','name'])
205
- x = stub_everything 'resource'
206
- Puppet::Resource.indirection.expects(:find).with('type/name').returns(x)
207
- @resource.main
170
+ @resource_app.command_line.stubs(:args).returns(['type','name'])
171
+ Puppet::Resource.indirection.expects(:find).with('type/name').returns(@res)
172
+ @resource_app.main
208
173
  end
209
174
 
210
175
  it "should add given parameters to the object" do
211
- @resource.command_line.stubs(:args).returns(['type','name','param=temp'])
176
+ @resource_app.command_line.stubs(:args).returns(['type','name','param=temp'])
212
177
 
213
- res = stub "resource"
214
- Puppet::Resource.indirection.expects(:save).with(res, 'type/name').returns(res)
215
- res.expects(:collect)
216
- res.expects(:to_manifest)
217
- Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(res)
178
+ Puppet::Resource.indirection.expects(:save).with(@res, 'type/name').returns([@res, @report])
179
+ Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(@res)
218
180
 
219
- @resource.main
181
+ @resource_app.main
220
182
  end
221
-
222
183
  end
223
184
  end
224
185
 
225
186
  describe "when handling file type" do
226
187
  before :each do
227
188
  Facter.stubs(:loadfacts)
228
- @resource.preinit
189
+ @resource_app.preinit
229
190
  end
230
191
 
231
192
  it "should raise an exception if no file specified" do
232
- @resource.command_line.stubs(:args).returns(['file'])
193
+ @resource_app.command_line.stubs(:args).returns(['file'])
233
194
 
234
- lambda { @resource.main }.should raise_error(RuntimeError, /Listing all file instances is not supported/)
195
+ lambda { @resource_app.main }.should raise_error(RuntimeError, /Listing all file instances is not supported/)
235
196
  end
236
197
 
237
198
  it "should output a file resource when given a file path" do
@@ -239,12 +200,12 @@ describe Puppet::Application::Resource do
239
200
  res = Puppet::Type.type(:file).new(:path => path).to_resource
240
201
  Puppet::Resource.indirection.expects(:find).returns(res)
241
202
 
242
- @resource.command_line.stubs(:args).returns(['file', path])
243
- @resource.expects(:puts).with do |args|
203
+ @resource_app.command_line.stubs(:args).returns(['file', path])
204
+ @resource_app.expects(:puts).with do |args|
244
205
  args.should =~ /file \{ '#{Regexp.escape(path)}'/m
245
206
  end
246
207
 
247
- @resource.main
208
+ @resource_app.main
248
209
  end
249
210
  end
250
211
  end
@@ -97,8 +97,8 @@ describe Puppet::Configurer::Downloader do
97
97
 
98
98
  describe "when creating the catalog to do the downloading" do
99
99
  before do
100
- @path = make_absolute("/download/path")
101
- @dler = Puppet::Configurer::Downloader.new("foo", @path, "source")
100
+ @path = File.expand_path("/download/path")
101
+ @dler = Puppet::Configurer::Downloader.new("foo", @path, File.expand_path("source"))
102
102
  end
103
103
 
104
104
  it "should create a catalog and add the file to it" do
@@ -75,18 +75,25 @@ describe Puppet::Configurer::PluginHandler do
75
75
  @pluginhandler.download_plugins
76
76
  end
77
77
 
78
- it "should load plugins when asked to do so" do
78
+ it "should load ruby plugins when asked to do so" do
79
79
  FileTest.stubs(:exist?).returns true
80
- @pluginhandler.expects(:load).with("foo")
80
+ @pluginhandler.expects(:load).with("foo.rb")
81
+
82
+ @pluginhandler.load_plugin("foo.rb")
83
+ end
84
+
85
+ it "should skip non-ruby plugins when asked to do so" do
86
+ FileTest.stubs(:exist?).returns true
87
+ @pluginhandler.expects(:load).never
81
88
 
82
89
  @pluginhandler.load_plugin("foo")
83
90
  end
84
91
 
85
92
  it "should not try to load files that don't exist" do
86
- FileTest.expects(:exist?).with("foo").returns false
93
+ FileTest.expects(:exist?).with("foo.rb").returns false
87
94
  @pluginhandler.expects(:load).never
88
95
 
89
- @pluginhandler.load_plugin("foo")
96
+ @pluginhandler.load_plugin("foo.rb")
90
97
  end
91
98
 
92
99
  it "should not try to load directories" do
@@ -99,17 +106,17 @@ describe Puppet::Configurer::PluginHandler do
99
106
 
100
107
  it "should warn but not fail if loading a file raises an exception" do
101
108
  FileTest.stubs(:exist?).returns true
102
- @pluginhandler.expects(:load).with("foo").raises "eh"
109
+ @pluginhandler.expects(:load).with("foo.rb").raises "eh"
103
110
 
104
111
  Puppet.expects(:err)
105
- @pluginhandler.load_plugin("foo")
112
+ @pluginhandler.load_plugin("foo.rb")
106
113
  end
107
114
 
108
115
  it "should warn but not fail if loading a file raises a LoadError" do
109
116
  FileTest.stubs(:exist?).returns true
110
- @pluginhandler.expects(:load).with("foo").raises LoadError.new("eh")
117
+ @pluginhandler.expects(:load).with("foo.rb").raises LoadError.new("eh")
111
118
 
112
119
  Puppet.expects(:err)
113
- @pluginhandler.load_plugin("foo")
120
+ @pluginhandler.load_plugin("foo.rb")
114
121
  end
115
122
  end
@@ -245,7 +245,7 @@ describe Puppet::Configurer do
245
245
  Puppet.settings[:prerun_command] = "/my/command"
246
246
  Puppet::Util.expects(:execute).with(["/my/command"]).raises(Puppet::ExecutionFailure, "Failed")
247
247
 
248
- report.expects(:<<).with { |log| log.message =~ /^Could not run command from prerun_command/ }
248
+ report.expects(:<<).with { |log| log.message.include?("Could not run command from prerun_command") }
249
249
 
250
250
  @agent.run.should be_nil
251
251
  end
@@ -268,7 +268,7 @@ describe Puppet::Configurer do
268
268
  Puppet.settings[:postrun_command] = "/my/command"
269
269
  Puppet::Util.expects(:execute).with(["/my/command"]).raises(Puppet::ExecutionFailure, "Failed")
270
270
 
271
- report.expects(:<<).with { |log| log.message =~ /^Could not run command from postrun_command/ }
271
+ report.expects(:<<).with { |log| log.message.include?("Could not run command from postrun_command") }
272
272
 
273
273
  @agent.run.should be_nil
274
274
  end
@@ -174,6 +174,29 @@ describe Puppet::Face[:ca, '0.1.0'], :unless => Puppet.features.microsoft_window
174
174
  list.length.should == 1
175
175
  list.first.name.should == 'random-host'
176
176
  end
177
+
178
+ describe "when the CSR specifies DNS alt names" do
179
+ let(:host) { Puppet::SSL::Host.new('someone') }
180
+
181
+ before :each do
182
+ host.generate_certificate_request(:dns_alt_names => 'some,alt,names')
183
+ end
184
+
185
+ it "should sign the CSR if DNS alt names are allowed" do
186
+ subject.sign('someone', :allow_dns_alt_names => true)
187
+
188
+ host.certificate.should be_a(Puppet::SSL::Certificate)
189
+ end
190
+
191
+ it "should refuse to sign the CSR if DNS alt names are not allowed" do
192
+ certname = 'someone'
193
+ expect do
194
+ subject.sign(certname)
195
+ end.to raise_error(Puppet::SSL::CertificateAuthority::CertificateSigningError, /CSR '#{certname}' contains subject alternative names \(.*\), which are disallowed. Use `puppet cert --allow-dns-alt-names sign #{certname}` to sign this request./i)
196
+
197
+ host.certificate.should be_nil
198
+ end
199
+ end
177
200
  end
178
201
 
179
202
  context "#generate" do
@@ -202,6 +225,17 @@ describe Puppet::Face[:ca, '0.1.0'], :unless => Puppet.features.microsoft_window
202
225
  subject.generate('random-host').should =~ /already has a certificate/
203
226
  }.should_not raise_error
204
227
  end
228
+
229
+ it "should include the specified DNS alt names" do
230
+ subject.generate('some-host', :dns_alt_names => 'some,alt,names')
231
+
232
+ host = subject.list(:signed => true).first
233
+
234
+ host.name.should == 'some-host'
235
+ host.certificate.subject_alt_names.should =~ %w[DNS:some DNS:alt DNS:names DNS:some-host]
236
+
237
+ subject.list(:pending => true).should be_empty
238
+ end
205
239
  end
206
240
 
207
241
  context "#revoke" do