puppet 4.0.0 → 4.1.0

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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
@@ -143,12 +143,40 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
143
143
  })
144
144
 
145
145
  expect(resource.provider.trigger).to eq([{
146
- 'start_date' => '2011-9-12',
147
- 'start_time' => '13:20',
148
- 'schedule' => 'daily',
149
- 'every' => '2',
150
- 'enabled' => true,
151
- 'index' => 0,
146
+ 'start_date' => '2011-9-12',
147
+ 'start_time' => '13:20',
148
+ 'schedule' => 'daily',
149
+ 'every' => '2',
150
+ 'minutes_interval' => 0,
151
+ 'minutes_duration' => 0,
152
+ 'enabled' => true,
153
+ 'index' => 0,
154
+ }])
155
+ end
156
+
157
+ it 'should handle a single daily with repeat trigger' do
158
+ @mock_task.expects(:trigger).with(0).returns({
159
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_DAILY,
160
+ 'start_year' => 2011,
161
+ 'start_month' => 9,
162
+ 'start_day' => 12,
163
+ 'start_hour' => 13,
164
+ 'start_minute' => 20,
165
+ 'minutes_interval' => 60,
166
+ 'minutes_duration' => 180,
167
+ 'flags' => 0,
168
+ 'type' => { 'days_interval' => 2 },
169
+ })
170
+
171
+ expect(resource.provider.trigger).to eq([{
172
+ 'start_date' => '2011-9-12',
173
+ 'start_time' => '13:20',
174
+ 'schedule' => 'daily',
175
+ 'every' => '2',
176
+ 'minutes_interval' => 60,
177
+ 'minutes_duration' => 180,
178
+ 'enabled' => true,
179
+ 'index' => 0,
152
180
  }])
153
181
  end
154
182
 
@@ -172,13 +200,15 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
172
200
  })
173
201
 
174
202
  expect(resource.provider.trigger).to eq([{
175
- 'start_date' => '2011-9-12',
176
- 'start_time' => '13:20',
177
- 'schedule' => 'weekly',
178
- 'every' => '2',
179
- 'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
180
- 'enabled' => true,
181
- 'index' => 0,
203
+ 'start_date' => '2011-9-12',
204
+ 'start_time' => '13:20',
205
+ 'schedule' => 'weekly',
206
+ 'every' => '2',
207
+ 'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
208
+ 'minutes_interval' => 0,
209
+ 'minutes_duration' => 0,
210
+ 'enabled' => true,
211
+ 'index' => 0,
182
212
  }])
183
213
  end
184
214
 
@@ -205,13 +235,15 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
205
235
  })
206
236
 
207
237
  expect(resource.provider.trigger).to eq([{
208
- 'start_date' => '2011-9-12',
209
- 'start_time' => '13:20',
210
- 'schedule' => 'monthly',
211
- 'months' => [1, 2, 8, 9, 12],
212
- 'on' => [1, 3, 5, 15, 'last'],
213
- 'enabled' => true,
214
- 'index' => 0,
238
+ 'start_date' => '2011-9-12',
239
+ 'start_time' => '13:20',
240
+ 'schedule' => 'monthly',
241
+ 'months' => [1, 2, 8, 9, 12],
242
+ 'on' => [1, 3, 5, 15, 'last'],
243
+ 'minutes_interval' => 0,
244
+ 'minutes_duration' => 0,
245
+ 'enabled' => true,
246
+ 'index' => 0,
215
247
  }])
216
248
  end
217
249
 
@@ -247,6 +279,8 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
247
279
  'months' => [1, 2, 8, 9, 12],
248
280
  'which_occurrence' => 'first',
249
281
  'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
282
+ 'minutes_interval' => 0,
283
+ 'minutes_duration' => 0,
250
284
  'enabled' => true,
251
285
  'index' => 0,
252
286
  }])
@@ -264,11 +298,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
264
298
  })
265
299
 
266
300
  expect(resource.provider.trigger).to eq([{
267
- 'start_date' => '2011-9-12',
268
- 'start_time' => '13:20',
269
- 'schedule' => 'once',
270
- 'enabled' => true,
271
- 'index' => 0,
301
+ 'start_date' => '2011-9-12',
302
+ 'start_time' => '13:20',
303
+ 'schedule' => 'once',
304
+ 'minutes_interval' => 0,
305
+ 'minutes_duration' => 0,
306
+ 'enabled' => true,
307
+ 'index' => 0,
272
308
  }])
273
309
  end
274
310
  end
@@ -305,25 +341,98 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
305
341
 
306
342
  expect(resource.provider.trigger).to match_array([
307
343
  {
308
- 'start_date' => '2011-10-13',
309
- 'start_time' => '14:21',
310
- 'schedule' => 'once',
311
- 'enabled' => true,
312
- 'index' => 0,
344
+ 'start_date' => '2011-10-13',
345
+ 'start_time' => '14:21',
346
+ 'schedule' => 'once',
347
+ 'minutes_interval' => 0,
348
+ 'minutes_duration' => 0,
349
+ 'enabled' => true,
350
+ 'index' => 0,
351
+ },
352
+ {
353
+ 'start_date' => '2012-11-14',
354
+ 'start_time' => '15:22',
355
+ 'schedule' => 'once',
356
+ 'minutes_interval' => 0,
357
+ 'minutes_duration' => 0,
358
+ 'enabled' => true,
359
+ 'index' => 1,
360
+ },
361
+ {
362
+ 'start_date' => '2013-12-15',
363
+ 'start_time' => '16:23',
364
+ 'schedule' => 'once',
365
+ 'minutes_interval' => 0,
366
+ 'minutes_duration' => 0,
367
+ 'enabled' => true,
368
+ 'index' => 2,
369
+ }
370
+ ])
371
+ end
372
+
373
+ it 'should handle multiple triggers with repeat triggers' do
374
+ @mock_task.expects(:trigger_count).returns(3)
375
+ @mock_task.expects(:trigger).with(0).returns({
376
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
377
+ 'start_year' => 2011,
378
+ 'start_month' => 10,
379
+ 'start_day' => 13,
380
+ 'start_hour' => 14,
381
+ 'start_minute' => 21,
382
+ 'minutes_interval' => 15,
383
+ 'minutes_duration' => 60,
384
+ 'flags' => 0,
385
+ })
386
+ @mock_task.expects(:trigger).with(1).returns({
387
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
388
+ 'start_year' => 2012,
389
+ 'start_month' => 11,
390
+ 'start_day' => 14,
391
+ 'start_hour' => 15,
392
+ 'start_minute' => 22,
393
+ 'minutes_interval' => 30,
394
+ 'minutes_duration' => 120,
395
+ 'flags' => 0,
396
+ })
397
+ @mock_task.expects(:trigger).with(2).returns({
398
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
399
+ 'start_year' => 2013,
400
+ 'start_month' => 12,
401
+ 'start_day' => 15,
402
+ 'start_hour' => 16,
403
+ 'start_minute' => 23,
404
+ 'minutes_interval' => 60,
405
+ 'minutes_duration' => 240,
406
+ 'flags' => 0,
407
+ })
408
+
409
+ expect(resource.provider.trigger).to match_array([
410
+ {
411
+ 'start_date' => '2011-10-13',
412
+ 'start_time' => '14:21',
413
+ 'schedule' => 'once',
414
+ 'minutes_interval' => 15,
415
+ 'minutes_duration' => 60,
416
+ 'enabled' => true,
417
+ 'index' => 0,
313
418
  },
314
419
  {
315
- 'start_date' => '2012-11-14',
316
- 'start_time' => '15:22',
317
- 'schedule' => 'once',
318
- 'enabled' => true,
319
- 'index' => 1,
420
+ 'start_date' => '2012-11-14',
421
+ 'start_time' => '15:22',
422
+ 'schedule' => 'once',
423
+ 'minutes_interval' => 30,
424
+ 'minutes_duration' => 120,
425
+ 'enabled' => true,
426
+ 'index' => 1,
320
427
  },
321
428
  {
322
- 'start_date' => '2013-12-15',
323
- 'start_time' => '16:23',
324
- 'schedule' => 'once',
325
- 'enabled' => true,
326
- 'index' => 2,
429
+ 'start_date' => '2013-12-15',
430
+ 'start_time' => '16:23',
431
+ 'schedule' => 'once',
432
+ 'minutes_interval' => 60,
433
+ 'minutes_duration' => 240,
434
+ 'enabled' => true,
435
+ 'index' => 2,
327
436
  }
328
437
  ])
329
438
  end
@@ -354,18 +463,22 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
354
463
 
355
464
  expect(resource.provider.trigger).to match_array([
356
465
  {
357
- 'start_date' => '2011-10-13',
358
- 'start_time' => '14:21',
359
- 'schedule' => 'once',
360
- 'enabled' => true,
361
- 'index' => 0,
466
+ 'start_date' => '2011-10-13',
467
+ 'start_time' => '14:21',
468
+ 'schedule' => 'once',
469
+ 'minutes_interval' => 0,
470
+ 'minutes_duration' => 0,
471
+ 'enabled' => true,
472
+ 'index' => 0,
362
473
  },
363
474
  {
364
- 'start_date' => '2013-12-15',
365
- 'start_time' => '16:23',
366
- 'schedule' => 'once',
367
- 'enabled' => true,
368
- 'index' => 2,
475
+ 'start_date' => '2013-12-15',
476
+ 'start_time' => '16:23',
477
+ 'schedule' => 'once',
478
+ 'minutes_interval' => 0,
479
+ 'minutes_duration' => 0,
480
+ 'enabled' => true,
481
+ 'index' => 2,
369
482
  }
370
483
  ])
371
484
  end
@@ -396,18 +509,22 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
396
509
 
397
510
  expect(resource.provider.trigger).to match_array([
398
511
  {
399
- 'start_date' => '2011-10-13',
400
- 'start_time' => '14:21',
401
- 'schedule' => 'once',
402
- 'enabled' => true,
403
- 'index' => 0,
512
+ 'start_date' => '2011-10-13',
513
+ 'start_time' => '14:21',
514
+ 'schedule' => 'once',
515
+ 'minutes_interval' => 0,
516
+ 'minutes_duration' => 0,
517
+ 'enabled' => true,
518
+ 'index' => 0,
404
519
  },
405
520
  {
406
- 'start_date' => '2013-12-15',
407
- 'start_time' => '16:23',
408
- 'schedule' => 'once',
409
- 'enabled' => true,
410
- 'index' => 2,
521
+ 'start_date' => '2013-12-15',
522
+ 'start_time' => '16:23',
523
+ 'schedule' => 'once',
524
+ 'minutes_interval' => 0,
525
+ 'minutes_duration' => 0,
526
+ 'enabled' => true,
527
+ 'index' => 2,
411
528
  }
412
529
  ])
413
530
  end
@@ -529,11 +646,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
529
646
  })
530
647
 
531
648
  mock_task_trigger = {
532
- 'start_date' => '2011-10-13',
533
- 'start_time' => '14:21',
534
- 'schedule' => 'once',
535
- 'enabled' => true,
536
- 'index' => 0,
649
+ 'start_date' => '2011-10-13',
650
+ 'start_time' => '14:21',
651
+ 'schedule' => 'once',
652
+ 'minutes_interval' => 0,
653
+ 'minutes_duration' => 0,
654
+ 'enabled' => true,
655
+ 'index' => 0,
537
656
  }
538
657
 
539
658
  expect(resource.provider.trigger).to eq([mock_task_trigger])
@@ -542,11 +661,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
542
661
  resource.provider.clear_task
543
662
 
544
663
  expect(resource.provider.trigger).to eq([{
545
- 'start_date' => '2012-11-14',
546
- 'start_time' => '15:22',
547
- 'schedule' => 'once',
548
- 'enabled' => true,
549
- 'index' => 0,
664
+ 'start_date' => '2012-11-14',
665
+ 'start_time' => '15:22',
666
+ 'schedule' => 'once',
667
+ 'minutes_interval' => 0,
668
+ 'minutes_duration' => 0,
669
+ 'enabled' => true,
670
+ 'index' => 0,
550
671
  }])
551
672
  end
552
673
  end
@@ -1045,6 +1166,127 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
1045
1166
  let(:provider) { described_class.new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe') }
1046
1167
  let(:trigger) { provider.translate_hash_to_trigger(@puppet_trigger) }
1047
1168
 
1169
+ context "working with repeat every x triggers" do
1170
+ before :each do
1171
+ @puppet_trigger['schedule'] = 'once'
1172
+ end
1173
+
1174
+ it 'should succeed if minutes_interval is equal to 0' do
1175
+ @puppet_trigger['minutes_interval'] = '0'
1176
+
1177
+ expect(trigger['minutes_interval']).to eq(0)
1178
+ end
1179
+
1180
+ it 'should default minutes_duration to a full day when minutes_interval is greater than 0 without setting minutes_duration' do
1181
+ @puppet_trigger['minutes_interval'] = '1'
1182
+
1183
+ expect(trigger['minutes_duration']).to eq(1440)
1184
+ end
1185
+
1186
+ it 'should succeed if minutes_interval is greater than 0 and minutes_duration is also set' do
1187
+ @puppet_trigger['minutes_interval'] = '1'
1188
+ @puppet_trigger['minutes_duration'] = '2'
1189
+
1190
+ expect(trigger['minutes_interval']).to eq(1)
1191
+ end
1192
+
1193
+ it 'should fail if minutes_interval is less than 0' do
1194
+ @puppet_trigger['minutes_interval'] = '-1'
1195
+
1196
+ expect { trigger }.to raise_error(
1197
+ Puppet::Error,
1198
+ 'minutes_interval must be an integer greater or equal to 0'
1199
+ )
1200
+ end
1201
+
1202
+ it 'should fail if minutes_interval is not an integer' do
1203
+ @puppet_trigger['minutes_interval'] = 'abc'
1204
+ expect { trigger }.to raise_error(ArgumentError)
1205
+ end
1206
+
1207
+ it 'should succeed if minutes_duration is equal to 0' do
1208
+ @puppet_trigger['minutes_duration'] = '0'
1209
+ expect(trigger['minutes_duration']).to eq(0)
1210
+ end
1211
+
1212
+ it 'should succeed if minutes_duration is greater than 0' do
1213
+ @puppet_trigger['minutes_duration'] = '1'
1214
+ expect(trigger['minutes_duration']).to eq(1)
1215
+ end
1216
+
1217
+ it 'should fail if minutes_duration is less than 0' do
1218
+ @puppet_trigger['minutes_duration'] = '-1'
1219
+
1220
+ expect { trigger }.to raise_error(
1221
+ Puppet::Error,
1222
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1223
+ )
1224
+ end
1225
+
1226
+ it 'should fail if minutes_duration is not an integer' do
1227
+ @puppet_trigger['minutes_duration'] = 'abc'
1228
+ expect { trigger }.to raise_error(ArgumentError)
1229
+ end
1230
+
1231
+ it 'should succeed if minutes_duration is equal to a full day' do
1232
+ @puppet_trigger['minutes_duration'] = '1440'
1233
+ expect(trigger['minutes_duration']).to eq(1440)
1234
+ end
1235
+
1236
+ it 'should succeed if minutes_duration is equal to three days' do
1237
+ @puppet_trigger['minutes_duration'] = '4320'
1238
+ expect(trigger['minutes_duration']).to eq(4320)
1239
+ end
1240
+
1241
+ it 'should succeed if minutes_duration is greater than minutes_duration' do
1242
+ @puppet_trigger['minutes_interval'] = '10'
1243
+ @puppet_trigger['minutes_duration'] = '11'
1244
+
1245
+ expect(trigger['minutes_interval']).to eq(10)
1246
+ expect(trigger['minutes_duration']).to eq(11)
1247
+ end
1248
+
1249
+ it 'should fail if minutes_duration is equal to minutes_interval' do
1250
+ # On Windows 2003, the duration must be greater than the interval
1251
+ # on other platforms the values can be equal.
1252
+ @puppet_trigger['minutes_interval'] = '10'
1253
+ @puppet_trigger['minutes_duration'] = '10'
1254
+
1255
+ expect { trigger }.to raise_error(
1256
+ Puppet::Error,
1257
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1258
+ )
1259
+ end
1260
+
1261
+ it 'should succeed if minutes_duration and minutes_interval are both set to 0' do
1262
+ @puppet_trigger['minutes_interval'] = '0'
1263
+ @puppet_trigger['minutes_duration'] = '0'
1264
+
1265
+ expect(trigger['minutes_interval']).to eq(0)
1266
+ expect(trigger['minutes_duration']).to eq(0)
1267
+ end
1268
+
1269
+ it 'should fail if minutes_duration is less than minutes_interval' do
1270
+ @puppet_trigger['minutes_interval'] = '10'
1271
+ @puppet_trigger['minutes_duration'] = '9'
1272
+
1273
+ expect { trigger }.to raise_error(
1274
+ Puppet::Error,
1275
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1276
+ )
1277
+ end
1278
+
1279
+ it 'should fail if minutes_duration is less than minutes_interval and set to 0' do
1280
+ @puppet_trigger['minutes_interval'] = '10'
1281
+ @puppet_trigger['minutes_duration'] = '0'
1282
+
1283
+ expect { trigger }.to raise_error(
1284
+ Puppet::Error,
1285
+ 'minutes_interval cannot be set without minutes_duration also being set to a number greater than 0'
1286
+ )
1287
+ end
1288
+ end
1289
+
1048
1290
  describe 'when given a one-time trigger' do
1049
1291
  before :each do
1050
1292
  @puppet_trigger['schedule'] = 'once'