puppet 2.7.6 → 2.7.8

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 (206) hide show
  1. data/CHANGELOG +168 -0
  2. data/conf/auth.conf +5 -4
  3. data/conf/redhat/puppet.spec +16 -1
  4. data/conf/solaris/pkginfo +2 -2
  5. data/conf/suse/puppet.spec +9 -3
  6. data/ext/upload_facts.rb +120 -0
  7. data/install.rb +11 -16
  8. data/lib/puppet.rb +1 -1
  9. data/lib/puppet/application/agent.rb +0 -3
  10. data/lib/puppet/application/apply.rb +0 -3
  11. data/lib/puppet/application/queue.rb +21 -1
  12. data/lib/puppet/defaults.rb +6 -4
  13. data/lib/puppet/face/file/store.rb +1 -1
  14. data/lib/puppet/feature/base.rb +2 -1
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_serving/content.rb +1 -1
  17. data/lib/puppet/file_serving/metadata.rb +5 -2
  18. data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
  19. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  20. data/lib/puppet/indirector/report/processor.rb +1 -1
  21. data/lib/puppet/network/handler/filebucket.rb +2 -0
  22. data/lib/puppet/network/handler/fileserver.rb +1 -1
  23. data/lib/puppet/network/handler/master.rb +1 -0
  24. data/lib/puppet/network/handler/report.rb +2 -0
  25. data/lib/puppet/network/handler/runner.rb +1 -0
  26. data/lib/puppet/network/handler/status.rb +2 -0
  27. data/lib/puppet/network/http/mongrel/rest.rb +8 -1
  28. data/lib/puppet/network/http_server.rb +3 -0
  29. data/lib/puppet/network/http_server/mongrel.rb +129 -0
  30. data/lib/puppet/network/rest_authconfig.rb +12 -4
  31. data/lib/puppet/parameter.rb +18 -0
  32. data/lib/puppet/parser/compiler.rb +1 -1
  33. data/lib/puppet/parser/grammar.ra +1 -1
  34. data/lib/puppet/parser/parser.rb +360 -350
  35. data/lib/puppet/property.rb +3 -3
  36. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  37. data/lib/puppet/provider/exec/windows.rb +6 -7
  38. data/lib/puppet/provider/file/windows.rb +9 -2
  39. data/lib/puppet/provider/group/aix.rb +8 -8
  40. data/lib/puppet/provider/group/groupadd.rb +1 -3
  41. data/lib/puppet/provider/group/ldap.rb +8 -10
  42. data/lib/puppet/provider/group/windows_adsi.rb +8 -2
  43. data/lib/puppet/provider/package/aix.rb +1 -1
  44. data/lib/puppet/provider/package/macports.rb +3 -3
  45. data/lib/puppet/provider/package/msi.rb +12 -5
  46. data/lib/puppet/provider/package/nim.rb +1 -1
  47. data/lib/puppet/provider/package/pkgdmg.rb +3 -3
  48. data/lib/puppet/provider/package/ports.rb +1 -1
  49. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +560 -0
  50. data/lib/puppet/provider/service/base.rb +2 -2
  51. data/lib/puppet/provider/service/bsd.rb +4 -3
  52. data/lib/puppet/provider/service/daemontools.rb +25 -25
  53. data/lib/puppet/provider/service/debian.rb +6 -4
  54. data/lib/puppet/provider/service/freebsd.rb +1 -1
  55. data/lib/puppet/provider/service/gentoo.rb +4 -3
  56. data/lib/puppet/provider/service/init.rb +3 -8
  57. data/lib/puppet/provider/service/launchd.rb +129 -96
  58. data/lib/puppet/provider/service/redhat.rb +2 -3
  59. data/lib/puppet/provider/service/runit.rb +20 -20
  60. data/lib/puppet/provider/service/smf.rb +8 -7
  61. data/lib/puppet/provider/service/src.rb +5 -6
  62. data/lib/puppet/provider/service/systemd.rb +1 -1
  63. data/lib/puppet/provider/service/upstart.rb +3 -5
  64. data/lib/puppet/provider/service/windows.rb +7 -7
  65. data/lib/puppet/provider/sshkey/parsed.rb +2 -3
  66. data/lib/puppet/provider/user/aix.rb +21 -21
  67. data/lib/puppet/provider/user/hpux.rb +3 -1
  68. data/lib/puppet/provider/user/ldap.rb +7 -7
  69. data/lib/puppet/provider/user/user_role_add.rb +10 -6
  70. data/lib/puppet/provider/user/useradd.rb +3 -1
  71. data/lib/puppet/provider/user/windows_adsi.rb +4 -3
  72. data/lib/puppet/rb_tree_map.rb +388 -0
  73. data/lib/puppet/reference/configuration.rb +7 -7
  74. data/lib/puppet/reference/indirection.rb +5 -6
  75. data/lib/puppet/reference/metaparameter.rb +3 -1
  76. data/lib/puppet/reference/network.rb +8 -8
  77. data/lib/puppet/reference/providers.rb +17 -21
  78. data/lib/puppet/reference/type.rb +12 -9
  79. data/lib/puppet/resource.rb +2 -5
  80. data/lib/puppet/resource/catalog.rb +1 -1
  81. data/lib/puppet/ssl/certificate_request.rb +70 -0
  82. data/lib/puppet/ssl/host.rb +6 -0
  83. data/lib/puppet/transaction.rb +158 -55
  84. data/lib/puppet/transaction/event_manager.rb +1 -1
  85. data/lib/puppet/type.rb +60 -30
  86. data/lib/puppet/type/augeas.rb +83 -49
  87. data/lib/puppet/type/computer.rb +1 -1
  88. data/lib/puppet/type/cron.rb +11 -11
  89. data/lib/puppet/type/exec.rb +28 -21
  90. data/lib/puppet/type/file.rb +17 -7
  91. data/lib/puppet/type/file/content.rb +2 -2
  92. data/lib/puppet/type/file/ensure.rb +15 -12
  93. data/lib/puppet/type/file/mode.rb +30 -5
  94. data/lib/puppet/type/file/source.rb +11 -10
  95. data/lib/puppet/type/file/target.rb +2 -2
  96. data/lib/puppet/type/filebucket.rb +1 -1
  97. data/lib/puppet/type/group.rb +4 -5
  98. data/lib/puppet/type/host.rb +1 -1
  99. data/lib/puppet/type/interface.rb +13 -10
  100. data/lib/puppet/type/k5login.rb +6 -6
  101. data/lib/puppet/type/macauthorization.rb +37 -36
  102. data/lib/puppet/type/maillist.rb +2 -2
  103. data/lib/puppet/type/mcx.rb +6 -6
  104. data/lib/puppet/type/mount.rb +3 -2
  105. data/lib/puppet/type/notify.rb +1 -1
  106. data/lib/puppet/type/package.rb +24 -23
  107. data/lib/puppet/type/router.rb +4 -1
  108. data/lib/puppet/type/schedule.rb +52 -44
  109. data/lib/puppet/type/scheduled_task.rb +222 -0
  110. data/lib/puppet/type/selmodule.rb +10 -6
  111. data/lib/puppet/type/service.rb +11 -11
  112. data/lib/puppet/type/ssh_authorized_key.rb +2 -5
  113. data/lib/puppet/type/sshkey.rb +1 -1
  114. data/lib/puppet/type/stage.rb +1 -1
  115. data/lib/puppet/type/tidy.rb +10 -8
  116. data/lib/puppet/type/user.rb +61 -53
  117. data/lib/puppet/type/vlan.rb +4 -4
  118. data/lib/puppet/type/whit.rb +6 -2
  119. data/lib/puppet/type/yumrepo.rb +33 -31
  120. data/lib/puppet/type/zfs.rb +34 -32
  121. data/lib/puppet/type/zone.rb +21 -19
  122. data/lib/puppet/type/zpool.rb +3 -3
  123. data/lib/puppet/util.rb +24 -6
  124. data/lib/puppet/util/adsi.rb +12 -7
  125. data/lib/puppet/util/checksums.rb +1 -1
  126. data/lib/puppet/util/diff.rb +1 -1
  127. data/lib/puppet/util/nagios_maker.rb +2 -2
  128. data/lib/puppet/util/reference.rb +16 -17
  129. data/lib/puppet/util/settings/file_setting.rb +14 -2
  130. data/lib/puppet/util/windows/security.rb +96 -32
  131. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  132. data/spec/integration/indirector/direct_file_server_spec.rb +9 -15
  133. data/spec/integration/indirector/file_content/file_server_spec.rb +1 -1
  134. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -1
  135. data/spec/integration/provider/package_spec.rb +4 -0
  136. data/spec/integration/provider/service/init_spec.rb +8 -2
  137. data/spec/integration/reference/providers_spec.rb +1 -1
  138. data/spec/integration/ssl/certificate_request_spec.rb +1 -2
  139. data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -2
  140. data/spec/integration/ssl/host_spec.rb +1 -2
  141. data/spec/integration/transaction_spec.rb +25 -17
  142. data/spec/integration/type/exec_spec.rb +77 -0
  143. data/spec/integration/type/file_spec.rb +322 -2
  144. data/spec/integration/util/windows/security_spec.rb +393 -230
  145. data/spec/integration/util_spec.rb +16 -0
  146. data/spec/lib/puppet_spec/files.rb +3 -7
  147. data/spec/unit/application/apply_spec.rb +0 -9
  148. data/spec/unit/application/inspect_spec.rb +1 -0
  149. data/spec/unit/configurer/downloader_spec.rb +3 -3
  150. data/spec/unit/face/certificate_spec.rb +6 -2
  151. data/spec/unit/file_bucket/dipper_spec.rb +67 -10
  152. data/spec/unit/file_bucket/file_spec.rb +22 -28
  153. data/spec/unit/file_serving/content_spec.rb +1 -1
  154. data/spec/unit/file_serving/metadata_spec.rb +30 -3
  155. data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
  156. data/spec/unit/indirector/file_bucket_file/file_spec.rb +21 -24
  157. data/spec/unit/indirector/node/store_configs_spec.rb +1 -0
  158. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  159. data/spec/unit/indirector/resource_type/parser_spec.rb +2 -2
  160. data/spec/unit/indirector/rest_spec.rb +1 -1
  161. data/spec/unit/network/handler/ca_spec.rb +1 -1
  162. data/spec/unit/network/http/mongrel/rest_spec.rb +54 -25
  163. data/spec/unit/parameter_spec.rb +36 -0
  164. data/spec/unit/parser/parser_spec.rb +4 -0
  165. data/spec/unit/property_spec.rb +2 -2
  166. data/spec/unit/provider/exec/windows_spec.rb +2 -8
  167. data/spec/unit/provider/file/posix_spec.rb +6 -0
  168. data/spec/unit/provider/file/windows_spec.rb +18 -0
  169. data/spec/unit/provider/group/windows_adsi_spec.rb +22 -6
  170. data/spec/unit/provider/mount/parsed_spec.rb +1 -1
  171. data/spec/unit/provider/package/msi_spec.rb +2 -2
  172. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1571 -0
  173. data/spec/unit/provider/service/launchd_spec.rb +143 -130
  174. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -0
  175. data/spec/unit/provider/user/user_role_add_spec.rb +39 -9
  176. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  177. data/spec/unit/provider/user/windows_adsi_spec.rb +8 -1
  178. data/spec/unit/rb_tree_map_spec.rb +572 -0
  179. data/spec/unit/resource/catalog_spec.rb +1 -1
  180. data/spec/unit/simple_graph_spec.rb +9 -9
  181. data/spec/unit/ssl/host_spec.rb +60 -12
  182. data/spec/unit/transaction/report_spec.rb +3 -3
  183. data/spec/unit/transaction_spec.rb +394 -11
  184. data/spec/unit/type/exec_spec.rb +35 -15
  185. data/spec/unit/type/file/content_spec.rb +11 -10
  186. data/spec/unit/type/file/mode_spec.rb +73 -19
  187. data/spec/unit/type/file/source_spec.rb +1 -1
  188. data/spec/unit/type/file_spec.rb +15 -0
  189. data/spec/unit/type/group_spec.rb +1 -1
  190. data/spec/unit/type/mount_spec.rb +5 -5
  191. data/spec/unit/type/resources_spec.rb +3 -3
  192. data/spec/unit/type/scheduled_task_spec.rb +102 -0
  193. data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
  194. data/spec/unit/type/user_spec.rb +2 -1
  195. data/spec/unit/type_spec.rb +48 -4
  196. data/spec/unit/util/adsi_spec.rb +18 -7
  197. data/spec/unit/util/checksums_spec.rb +20 -2
  198. data/spec/unit/util/execution_stub_spec.rb +10 -5
  199. data/spec/unit/util/logging_spec.rb +6 -6
  200. data/spec/unit/util/rdoc/parser_spec.rb +1 -1
  201. data/spec/unit/util/reference_spec.rb +29 -0
  202. data/spec/unit/util/settings/file_setting_spec.rb +8 -2
  203. data/spec/unit/util_spec.rb +115 -0
  204. data/test/other/transactions.rb +5 -11
  205. data/test/ral/type/exec.rb +1 -1
  206. metadata +24 -11
@@ -186,18 +186,38 @@ describe Puppet::Type.type(:exec) do
186
186
  end
187
187
  end
188
188
 
189
- describe "when setting user", :fails_on_windows => true do
190
- it "should fail if we are not root" do
191
- Puppet.features.stubs(:root?).returns(false)
192
- expect { Puppet::Type.type(:exec).new(:name => @command, :user => 'input') }.
193
- should raise_error Puppet::Error, /Parameter user failed/
189
+ describe "when setting user" do
190
+ describe "on POSIX systems" do
191
+ before :each do
192
+ Puppet.features.stubs(:posix?).returns(true)
193
+ Puppet.features.stubs(:microsoft_windows?).returns(false)
194
+ end
195
+
196
+ it "should fail if we are not root" do
197
+ Puppet.features.stubs(:root?).returns(false)
198
+ expect { Puppet::Type.type(:exec).new(:name => '/bin/true whatever', :user => 'input') }.
199
+ should raise_error Puppet::Error, /Parameter user failed/
200
+ end
201
+
202
+ ['one', 2, 'root', 4294967295, 4294967296].each do |value|
203
+ it "should accept '#{value}' as user if we are root" do
204
+ Puppet.features.stubs(:root?).returns(true)
205
+ type = Puppet::Type.type(:exec).new(:name => '/bin/true whatever', :user => value)
206
+ type[:user].should == value
207
+ end
208
+ end
194
209
  end
195
210
 
196
- ['one', 2, 'root', 4294967295, 4294967296].each do |value|
197
- it "should accept '#{value}' as user if we are root" do
211
+ describe "on Windows systems" do
212
+ before :each do
213
+ Puppet.features.stubs(:posix?).returns(false)
214
+ Puppet.features.stubs(:microsoft_windows?).returns(true)
198
215
  Puppet.features.stubs(:root?).returns(true)
199
- type = Puppet::Type.type(:exec).new(:name => @command, :user => value)
200
- type[:user].should == value
216
+ end
217
+
218
+ it "should reject user parameter" do
219
+ expect { Puppet::Type.type(:exec).new(:name => 'c:\windows\notepad.exe', :user => 'input') }.
220
+ should raise_error Puppet::Error, /Unable to execute commands as other users on Windows/
201
221
  end
202
222
  end
203
223
  end
@@ -205,7 +225,7 @@ describe Puppet::Type.type(:exec) do
205
225
  describe "when setting group" do
206
226
  shared_examples_for "exec[:group]" do
207
227
  ['one', 2, 'wheel', 4294967295, 4294967296].each do |value|
208
- it "should accept '#{value}' without error or judgement", :fails_on_windows => true do
228
+ it "should accept '#{value}' without error or judgement" do
209
229
  type = Puppet::Type.type(:exec).new(:name => @command, :group => value)
210
230
  type[:group].should == value
211
231
  end
@@ -352,16 +372,16 @@ describe Puppet::Type.type(:exec) do
352
372
  end
353
373
  end
354
374
 
355
- it "should fail if timeout is exceeded", :fails_on_windows => true do
375
+ it "should fail if timeout is exceeded" do
356
376
  Puppet::Util.stubs(:execute).with do |cmd,args|
357
377
  sleep 1
358
378
  true
359
379
  end
360
380
  FileTest.stubs(:file?).returns(false)
361
- FileTest.stubs(:file?).with('/bin/sleep').returns(true)
381
+ FileTest.stubs(:file?).with(File.expand_path('/bin/sleep')).returns(true)
362
382
  FileTest.stubs(:executable?).returns(false)
363
- FileTest.stubs(:executable?).with('/bin/sleep').returns(true)
364
- sleep_exec = Puppet::Type.type(:exec).new(:name => 'sleep 1', :path => ['/bin'], :timeout => '0.2')
383
+ FileTest.stubs(:executable?).with(File.expand_path('/bin/sleep')).returns(true)
384
+ sleep_exec = Puppet::Type.type(:exec).new(:name => 'sleep 1', :path => [File.expand_path('/bin')], :timeout => '0.2')
365
385
 
366
386
  lambda { sleep_exec.refresh }.should raise_error Puppet::Error, "Command exceeded timeout"
367
387
  end
@@ -616,7 +636,7 @@ describe Puppet::Type.type(:exec) do
616
636
  end
617
637
  end
618
638
 
619
- describe "#retrieve", :fails_on_windows => true do
639
+ describe "#retrieve" do
620
640
  before :each do
621
641
  @exec_resource = Puppet::Type.type(:exec).new(:name => @bogus_cmd)
622
642
  end
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
+ require 'puppet/network/http_pool'
3
4
 
4
5
  content = Puppet::Type.type(:file).attrclass(:content)
5
6
  describe content do
@@ -178,7 +179,7 @@ describe content do
178
179
  it "should display a diff if the current contents are different from the desired content" do
179
180
  @content.should = "some content"
180
181
  @content.expects(:diff).returns("my diff").once
181
- @content.expects(:print).with("my diff").once
182
+ @content.expects(:notice).with("\nmy diff").once
182
183
 
183
184
  @content.safe_insync?("other content")
184
185
  end
@@ -250,7 +251,7 @@ describe content do
250
251
  end
251
252
 
252
253
  it "should attempt to read from the filebucket if no actual content nor source exists" do
253
- @fh = File.open(@filename, 'w')
254
+ @fh = File.open(@filename, 'wb')
254
255
  @content.should = "{md5}foo"
255
256
  @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo"
256
257
  @content.write(@fh)
@@ -299,13 +300,13 @@ describe content do
299
300
  end
300
301
  end
301
302
 
302
- describe "from local source", :fails_on_windows => true do
303
+ describe "from local source" do
303
304
  before(:each) do
304
305
  @sourcename = tmpfile('source')
305
306
  @resource = Puppet::Type.type(:file).new :path => @filename, :backup => false, :source => @sourcename
306
307
 
307
- @source_content = "source file content"*10000
308
- @sourcefile = File.open(@sourcename, 'w') {|f| f.write @source_content}
308
+ @source_content = "source file content\r\n"*10000
309
+ @sourcefile = File.open(@sourcename, 'wb') {|f| f.write @source_content}
309
310
 
310
311
  @content = @resource.newattr(:content)
311
312
  @source = @resource.parameter :source #newattr(:source)
@@ -313,11 +314,11 @@ describe content do
313
314
 
314
315
  it "should copy content from the source to the file" do
315
316
  @resource.write(@source)
316
- File.read(@filename).should == @source_content
317
+ Puppet::Util.binread(@filename).should == @source_content
317
318
  end
318
319
 
319
320
  it "should return the checksum computed" do
320
- File.open(@filename, 'w') do |file|
321
+ File.open(@filename, 'wb') do |file|
321
322
  @content.write(file).should == "{md5}#{Digest::MD5.hexdigest(@source_content)}"
322
323
  end
323
324
  end
@@ -327,8 +328,8 @@ describe content do
327
328
  before(:each) do
328
329
  @resource = Puppet::Type.type(:file).new :path => @filename, :backup => false
329
330
  @response = stub_everything 'response', :code => "200"
330
- @source_content = "source file content"*10000
331
- @response.stubs(:read_body).multiple_yields(*(["source file content"]*10000))
331
+ @source_content = "source file content\n"*10000
332
+ @response.stubs(:read_body).multiple_yields(*(["source file content\n"]*10000))
332
333
 
333
334
  @conn = stub_everything 'connection'
334
335
  @conn.stubs(:request_get).yields(@response)
@@ -342,7 +343,7 @@ describe content do
342
343
 
343
344
  it "should write the contents to the file" do
344
345
  @resource.write(@source)
345
- File.read(@filename).should == @source_content
346
+ Puppet::Util.binread(@filename).should == @source_content
346
347
  end
347
348
 
348
349
  it "should not write anything if source is not found" do
@@ -26,43 +26,36 @@ describe Puppet::Type.type(:file).attrclass(:mode) do
26
26
  end
27
27
 
28
28
  describe "#munge" do
29
- it "should dirmask the value when munging" do
30
- Dir.mkdir(path)
31
- mode.value = 0644
32
-
33
- mode.value.must == '755'
34
- end
35
- end
36
-
37
- describe "#dirmask" do
38
- before :each do
39
- Dir.mkdir(path)
40
- end
41
-
42
29
  # This is sort of a redundant test, but its spec is important.
43
30
  it "should return the value as a string" do
44
- mode.dirmask('0644').should be_a(String)
31
+ mode.munge('0644').should be_a(String)
45
32
  end
46
33
 
47
34
  it "should accept strings as arguments" do
48
- mode.dirmask('0644').should == '755'
35
+ mode.munge('0644').should == '644'
49
36
  end
50
37
 
51
38
  it "should accept integers are arguments" do
52
- mode.dirmask(0644).should == '755'
39
+ mode.munge(0644).should == '644'
40
+ end
41
+ end
42
+
43
+ describe "#dirmask" do
44
+ before :each do
45
+ Dir.mkdir(path)
53
46
  end
54
47
 
55
48
  it "should add execute bits corresponding to read bits for directories" do
56
- mode.dirmask(0644).should == '755'
49
+ mode.dirmask('0644').should == '755'
57
50
  end
58
51
 
59
52
  it "should not add an execute bit when there is no read bit" do
60
- mode.dirmask(0600).should == '700'
53
+ mode.dirmask('0600').should == '700'
61
54
  end
62
55
 
63
56
  it "should not add execute bits for files that aren't directories" do
64
57
  resource[:path] = tmpfile('other_file')
65
- mode.dirmask(0644).should == '644'
58
+ mode.dirmask('0644').should == '0644'
66
59
  end
67
60
  end
68
61
 
@@ -85,4 +78,65 @@ describe Puppet::Type.type(:file).attrclass(:mode) do
85
78
  mode.must be_insync('644')
86
79
  end
87
80
  end
81
+
82
+ describe "#retrieve" do
83
+ it "should return absent if the resource doesn't exist" do
84
+ resource[:path] = File.expand_path("/does/not/exist")
85
+ mode.retrieve.should == :absent
86
+ end
87
+
88
+ it "should retrieve the directory mode from the provider" do
89
+ Dir.mkdir(path)
90
+
91
+ mode.expects(:dirmask).with('644').returns '755'
92
+ resource.provider.expects(:mode).returns '755'
93
+
94
+ mode.retrieve.should == '755'
95
+ end
96
+
97
+ it "should retrieve the file mode from the provider" do
98
+ FileUtils.touch(path)
99
+
100
+ mode.expects(:dirmask).with('644').returns '644'
101
+ resource.provider.expects(:mode).returns '644'
102
+
103
+ mode.retrieve.should == '644'
104
+ end
105
+ end
106
+
107
+ describe '#should_to_s' do
108
+ describe 'with a 3-digit mode' do
109
+ it 'returns a 4-digit mode with a leading zero' do
110
+ mode.should_to_s('755').should == '0755'
111
+ end
112
+ end
113
+
114
+ describe 'with a 4-digit mode' do
115
+ it 'returns the 4-digit mode when the first digit is a zero' do
116
+ mode.should_to_s('0755').should == '0755'
117
+ end
118
+
119
+ it 'returns the 4-digit mode when the first digit is not a zero' do
120
+ mode.should_to_s('1755').should == '1755'
121
+ end
122
+ end
123
+ end
124
+
125
+ describe '#is_to_s' do
126
+ describe 'with a 3-digit mode' do
127
+ it 'returns a 4-digit mode with a leading zero' do
128
+ mode.is_to_s('755').should == '0755'
129
+ end
130
+ end
131
+
132
+ describe 'with a 4-digit mode' do
133
+ it 'returns the 4-digit mode when the first digit is a zero' do
134
+ mode.is_to_s('0755').should == '0755'
135
+ end
136
+
137
+ it 'returns the 4-digit mode when the first digit is not a zero' do
138
+ mode.is_to_s('1755').should == '1755'
139
+ end
140
+ end
141
+ end
88
142
  end
@@ -89,7 +89,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
89
89
  end
90
90
  end
91
91
 
92
- describe "when returning the metadata", :fails_on_windows => true do
92
+ describe "when returning the metadata" do
93
93
  before do
94
94
  @metadata = stub 'metadata', :source= => nil
95
95
  end
@@ -385,6 +385,21 @@ describe Puppet::Type.type(:file) do
385
385
  end
386
386
  end
387
387
 
388
+ describe "#ancestors" do
389
+ it "should return the ancestors of the file, in ascending order" do
390
+ file = described_class.new(:path => make_absolute("/tmp/foo/bar/baz/qux"))
391
+
392
+ pieces = %W[#{make_absolute('/')} tmp foo bar baz]
393
+
394
+ ancestors = file.ancestors
395
+
396
+ ancestors.should_not be_empty
397
+ ancestors.reverse.each_with_index do |path,i|
398
+ path.should == File.join(*pieces[0..i])
399
+ end
400
+ end
401
+ end
402
+
388
403
  describe "#flush" do
389
404
  it "should flush all properties that respond to :flush" do
390
405
  file[:source] = File.expand_path(__FILE__)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type.type(:group), :fails_on_windows => true do
4
+ describe Puppet::Type.type(:group) do
5
5
  before do
6
6
  ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
7
7
  @class = Puppet::Type.type(:group)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type.type(:mount), :fails_on_windows => true do
4
+ describe Puppet::Type.type(:mount), :unless => Puppet.features.microsoft_windows? do
5
5
  it "should have a :refreshable feature that requires the :remount method" do
6
6
  Puppet::Type.type(:mount).provider_feature(:refreshable).methods.should == [:remount]
7
7
  end
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:mount), :fails_on_windows => true do
16
16
  end
17
17
  end
18
18
 
19
- describe Puppet::Type.type(:mount), "when validating attributes", :fails_on_windows => true do
19
+ describe Puppet::Type.type(:mount), "when validating attributes" do
20
20
  [:name, :remounts, :provider].each do |param|
21
21
  it "should have a #{param} parameter" do
22
22
  Puppet::Type.type(:mount).attrtype(param).should == :param
@@ -30,7 +30,7 @@ describe Puppet::Type.type(:mount), "when validating attributes", :fails_on_wind
30
30
  end
31
31
  end
32
32
 
33
- describe Puppet::Type.type(:mount)::Ensure, "when validating values", :fails_on_windows => true do
33
+ describe Puppet::Type.type(:mount)::Ensure, "when validating values", :unless => Puppet.features.microsoft_windows? do
34
34
  before do
35
35
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil
36
36
  Puppet::Type.type(:mount).defaultprovider.expects(:new).returns(@provider)
@@ -62,7 +62,7 @@ describe Puppet::Type.type(:mount)::Ensure, "when validating values", :fails_on_
62
62
  end
63
63
  end
64
64
 
65
- describe Puppet::Type.type(:mount)::Ensure, :fails_on_windows => true do
65
+ describe Puppet::Type.type(:mount)::Ensure, :unless => Puppet.features.microsoft_windows? do
66
66
  before :each do
67
67
  provider_properties = {}
68
68
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :property_hash => provider_properties
@@ -279,7 +279,7 @@ describe Puppet::Type.type(:mount)::Ensure, :fails_on_windows => true do
279
279
  end
280
280
  end
281
281
 
282
- describe Puppet::Type.type(:mount), "when modifying an existing mount entry", :fails_on_windows => true do
282
+ describe Puppet::Type.type(:mount), "when modifying an existing mount entry", :unless => Puppet.features.microsoft_windows? do
283
283
  before do
284
284
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil
285
285
  Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
@@ -51,7 +51,7 @@ describe resources do
51
51
  @resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
52
52
  end
53
53
 
54
- it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do
54
+ it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true do
55
55
  res = Puppet::Type.type(:resources).new :name => :user, :purge => true
56
56
  res.catalog = Puppet::Resource::Catalog.new
57
57
 
@@ -72,9 +72,9 @@ describe resources do
72
72
  end
73
73
  end
74
74
 
75
- describe "when the instance's do not have an ensure property", :fails_on_windows => true do
75
+ describe "when the instance's do not have an ensure property" do
76
76
  it "should not be included in the generated resources" do
77
- @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
77
+ @no_ensure_resource = Puppet::Type.type(:exec).new(:name => "#{File.expand_path('/usr/bin/env')} echo")
78
78
  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
79
79
  @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
80
80
  end
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Type.type(:scheduled_task), :if => Puppet.features.microsoft_windows? do
5
+
6
+ it 'should use name as the namevar' do
7
+ described_class.new(
8
+ :title => 'Foo',
9
+ :command => 'C:\Windows\System32\notepad.exe'
10
+ ).name.must == 'Foo'
11
+ end
12
+
13
+ describe 'when setting the command' do
14
+ it 'should accept an absolute path to the command' do
15
+ described_class.new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe')[:command].should == 'C:\Windows\System32\notepad.exe'
16
+ end
17
+
18
+ it 'should fail if the path to the command is not absolute' do
19
+ expect {
20
+ described_class.new(:name => 'Test Task', :command => 'notepad.exe')
21
+ }.to raise_error(
22
+ Puppet::Error,
23
+ /Parameter command failed: Must be specified using an absolute path\./
24
+ )
25
+ end
26
+ end
27
+
28
+ describe 'when setting the command arguments' do
29
+ it 'should fail if provided an array' do
30
+ expect {
31
+ described_class.new(
32
+ :name => 'Test Task',
33
+ :command => 'C:\Windows\System32\notepad.exe',
34
+ :arguments => ['/a', '/b', '/c']
35
+ )
36
+ }.to raise_error(
37
+ Puppet::Error,
38
+ /Parameter arguments failed: Must be specified as a single string/
39
+ )
40
+ end
41
+
42
+ it 'should accept a string' do
43
+ described_class.new(
44
+ :name => 'Test Task',
45
+ :command => 'C:\Windows\System32\notepad.exe',
46
+ :arguments => '/a /b /c'
47
+ )[:arguments].should == ['/a /b /c']
48
+ end
49
+
50
+ it 'should allow not specifying any command arguments' do
51
+ described_class.new(
52
+ :name => 'Test Task',
53
+ :command => 'C:\Windows\System32\notepad.exe'
54
+ )[:arguments].should_not be
55
+ end
56
+ end
57
+
58
+ describe 'when setting whether the task is enabled or not' do
59
+ end
60
+
61
+ describe 'when setting the working directory' do
62
+ it 'should accept an absolute path to the working directory' do
63
+ described_class.new(
64
+ :name => 'Test Task',
65
+ :command => 'C:\Windows\System32\notepad.exe',
66
+ :working_dir => 'C:\Windows\System32'
67
+ )[:working_dir].should == 'C:\Windows\System32'
68
+ end
69
+
70
+ it 'should fail if the path to the working directory is not absolute' do
71
+ expect {
72
+ described_class.new(
73
+ :name => 'Test Task',
74
+ :command => 'C:\Windows\System32\notepad.exe',
75
+ :working_dir => 'Windows\System32'
76
+ )
77
+ }.to raise_error(
78
+ Puppet::Error,
79
+ /Parameter working_dir failed: Must be specified using an absolute path/
80
+ )
81
+ end
82
+
83
+ it 'should allow not specifying any working directory' do
84
+ described_class.new(
85
+ :name => 'Test Task',
86
+ :command => 'C:\Windows\System32\notepad.exe'
87
+ )[:working_dir].should_not be
88
+ end
89
+ end
90
+
91
+ describe 'when setting the trigger' do
92
+ it 'should delegate to the provider to validate the trigger' do
93
+ described_class.defaultprovider.any_instance.expects(:validate_trigger).returns(true)
94
+
95
+ described_class.new(
96
+ :name => 'Test Task',
97
+ :command => 'C:\Windows\System32\notepad.exe',
98
+ :trigger => {'schedule' => 'once', 'start_date' => '2011-09-16', 'start_time' => '13:20'}
99
+ )
100
+ end
101
+ end
102
+ end