puppet 4.5.3-x86-mingw32 → 4.6.1-x86-mingw32

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 (422) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -1
  3. data/ext/debian/control +2 -4
  4. data/ext/project_data.yaml +4 -4
  5. data/install.rb +6 -2
  6. data/lib/puppet.rb +3 -1
  7. data/lib/puppet/agent/locker.rb +1 -1
  8. data/lib/puppet/application.rb +6 -4
  9. data/lib/puppet/application/agent.rb +2 -1
  10. data/lib/puppet/application/cert.rb +35 -2
  11. data/lib/puppet/application/device.rb +1 -1
  12. data/lib/puppet/application/generate.rb +5 -0
  13. data/lib/puppet/application/lookup.rb +3 -3
  14. data/lib/puppet/application_support.rb +1 -1
  15. data/lib/puppet/compilable_resource_type.rb +15 -0
  16. data/lib/puppet/configurer.rb +67 -10
  17. data/lib/puppet/configurer/plugin_handler.rb +2 -4
  18. data/lib/puppet/data_providers/hiera_config.rb +1 -1
  19. data/lib/puppet/defaults.rb +34 -7
  20. data/lib/puppet/environments.rb +4 -2
  21. data/lib/puppet/error.rb +1 -1
  22. data/lib/puppet/external/dot.rb +1 -1
  23. data/lib/puppet/face/ca.rb +4 -1
  24. data/lib/puppet/face/certificate.rb +7 -1
  25. data/lib/puppet/face/epp.rb +5 -5
  26. data/lib/puppet/face/generate.rb +64 -0
  27. data/lib/puppet/face/help.rb +19 -13
  28. data/lib/puppet/face/man.rb +1 -1
  29. data/lib/puppet/feature/external_facts.rb +1 -1
  30. data/lib/puppet/file_system.rb +16 -0
  31. data/lib/puppet/file_system/file_impl.rb +5 -0
  32. data/lib/puppet/file_system/memory_impl.rb +4 -0
  33. data/lib/puppet/file_system/path_pattern.rb +1 -0
  34. data/lib/puppet/file_system/windows.rb +19 -0
  35. data/lib/puppet/functions.rb +3 -5
  36. data/lib/puppet/functions/assert_type.rb +1 -1
  37. data/lib/puppet/functions/defined.rb +7 -5
  38. data/lib/puppet/functions/dig.rb +2 -18
  39. data/lib/puppet/functions/hiera.rb +1 -1
  40. data/lib/puppet/functions/lest.rb +1 -37
  41. data/lib/puppet/functions/new.rb +2 -473
  42. data/lib/puppet/functions/reverse_each.rb +2 -59
  43. data/lib/puppet/functions/scanf.rb +4 -4
  44. data/lib/puppet/functions/step.rb +1 -63
  45. data/lib/puppet/functions/then.rb +1 -61
  46. data/lib/puppet/functions/type.rb +1 -40
  47. data/lib/puppet/functions/unwrap.rb +40 -0
  48. data/lib/puppet/generate/models/type/property.rb +70 -0
  49. data/lib/puppet/generate/models/type/type.rb +57 -0
  50. data/lib/puppet/generate/templates/type/pcore.erb +41 -0
  51. data/lib/puppet/generate/type.rb +239 -0
  52. data/lib/puppet/graph/simple_graph.rb +2 -6
  53. data/lib/puppet/indirector/catalog/static_compiler.rb +5 -2
  54. data/lib/puppet/indirector/facts/facter.rb +1 -1
  55. data/lib/puppet/indirector/key/ca.rb +2 -2
  56. data/lib/puppet/indirector/request.rb +25 -4
  57. data/lib/puppet/indirector/rest.rb +73 -3
  58. data/lib/puppet/info_service/class_information_service.rb +1 -2
  59. data/lib/puppet/interface/documentation.rb +1 -1
  60. data/lib/puppet/loaders.rb +2 -0
  61. data/lib/puppet/metatype/manager.rb +6 -6
  62. data/lib/puppet/module.rb +8 -1
  63. data/lib/puppet/module_tool.rb +2 -2
  64. data/lib/puppet/module_tool/checksums.rb +1 -1
  65. data/lib/puppet/module_tool/errors/installer.rb +2 -2
  66. data/lib/puppet/module_tool/metadata.rb +1 -1
  67. data/lib/puppet/network/http/api/indirected_routes.rb +23 -32
  68. data/lib/puppet/network/http/rack/rest.rb +15 -1
  69. data/lib/puppet/network/rights.rb +1 -11
  70. data/lib/puppet/node/environment.rb +7 -3
  71. data/lib/puppet/node/facts.rb +1 -1
  72. data/lib/puppet/parameter.rb +23 -3
  73. data/lib/puppet/parameter/boolean.rb +1 -1
  74. data/lib/puppet/parameter/value.rb +1 -1
  75. data/lib/puppet/parser.rb +0 -1
  76. data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
  77. data/lib/puppet/parser/ast/resource.rb +5 -0
  78. data/lib/puppet/parser/ast/resource_instance.rb +5 -1
  79. data/lib/puppet/parser/ast/resourceparam.rb +5 -0
  80. data/lib/puppet/parser/compiler.rb +14 -17
  81. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +1 -1
  82. data/lib/puppet/parser/environment_compiler.rb +10 -0
  83. data/lib/puppet/parser/functions/create_resources.rb +39 -24
  84. data/lib/puppet/parser/functions/defined.rb +2 -26
  85. data/lib/puppet/parser/functions/dig.rb +29 -0
  86. data/lib/puppet/parser/functions/lest.rb +49 -0
  87. data/lib/puppet/parser/functions/new.rb +530 -0
  88. data/lib/puppet/parser/functions/require.rb +1 -1
  89. data/lib/puppet/parser/functions/reverse_each.rb +83 -0
  90. data/lib/puppet/parser/functions/scanf.rb +4 -4
  91. data/lib/puppet/parser/functions/step.rb +84 -0
  92. data/lib/puppet/parser/functions/then.rb +73 -0
  93. data/lib/puppet/parser/functions/type.rb +53 -0
  94. data/lib/puppet/parser/resource.rb +16 -7
  95. data/lib/puppet/parser/scope.rb +36 -28
  96. data/lib/puppet/parser/type_loader.rb +1 -1
  97. data/lib/puppet/plugins/data_providers/data_provider.rb +1 -1
  98. data/lib/puppet/pops.rb +13 -0
  99. data/lib/puppet/pops/adapters.rb +49 -49
  100. data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
  101. data/lib/puppet/pops/evaluator/access_operator.rb +39 -2
  102. data/lib/puppet/pops/evaluator/closure.rb +39 -13
  103. data/lib/puppet/pops/evaluator/collector_transformer.rb +10 -1
  104. data/lib/puppet/pops/evaluator/evaluator_impl.rb +16 -11
  105. data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  106. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +0 -1
  107. data/lib/puppet/pops/evaluator/literal_evaluator.rb +0 -1
  108. data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -2
  109. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
  110. data/lib/puppet/pops/evaluator/runtime3_support.rb +19 -45
  111. data/lib/puppet/pops/functions/function.rb +5 -0
  112. data/lib/puppet/pops/issues.rb +1 -1
  113. data/lib/puppet/pops/label_provider.rb +2 -2
  114. data/lib/puppet/pops/loader/base_loader.rb +12 -15
  115. data/lib/puppet/pops/loader/loader.rb +15 -50
  116. data/lib/puppet/pops/loader/loader_paths.rb +28 -2
  117. data/lib/puppet/pops/loader/module_loaders.rb +16 -1
  118. data/lib/puppet/pops/loader/null_loader.rb +17 -1
  119. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +12 -11
  120. data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
  121. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +2 -3
  122. data/lib/puppet/pops/loader/runtime3_type_loader.rb +52 -13
  123. data/lib/puppet/pops/loader/static_loader.rb +55 -0
  124. data/lib/puppet/pops/loader/type_definition_instantiator.rb +30 -14
  125. data/lib/puppet/pops/loader/typed_name.rb +50 -0
  126. data/lib/puppet/pops/loaders.rb +64 -19
  127. data/lib/puppet/pops/merge_strategy.rb +7 -7
  128. data/lib/puppet/pops/migration/migration_checker.rb +4 -0
  129. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  130. data/lib/puppet/pops/parser/egrammar.ra +8 -5
  131. data/lib/puppet/pops/parser/eparser.rb +1550 -1498
  132. data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  133. data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
  134. data/lib/puppet/pops/parser/lexer2.rb +14 -1
  135. data/lib/puppet/pops/parser/locator.rb +30 -1
  136. data/lib/puppet/pops/parser/parser_support.rb +0 -3
  137. data/lib/puppet/pops/parser/slurp_support.rb +3 -3
  138. data/lib/puppet/pops/patterns.rb +9 -1
  139. data/lib/puppet/pops/pcore.rb +67 -11
  140. data/lib/puppet/pops/puppet_stack.rb +43 -0
  141. data/lib/puppet/pops/resource/param.rb +51 -0
  142. data/lib/puppet/pops/resource/resource_type_impl.rb +301 -0
  143. data/lib/puppet/pops/resource/resource_type_set.pcore +21 -0
  144. data/lib/puppet/pops/serialization.rb +17 -0
  145. data/lib/puppet/pops/serialization/abstract_reader.rb +149 -0
  146. data/lib/puppet/pops/serialization/abstract_writer.rb +179 -0
  147. data/lib/puppet/pops/serialization/deserializer.rb +60 -0
  148. data/lib/puppet/pops/serialization/extension.rb +126 -0
  149. data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
  150. data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
  151. data/lib/puppet/pops/serialization/json.rb +247 -0
  152. data/lib/puppet/pops/serialization/object.rb +63 -0
  153. data/lib/puppet/pops/serialization/rgen.rb +151 -0
  154. data/lib/puppet/pops/serialization/serializer.rb +91 -0
  155. data/lib/puppet/pops/serialization/time_factory.rb +66 -0
  156. data/lib/puppet/pops/types/annotatable.rb +36 -0
  157. data/lib/puppet/pops/types/implementation_registry.rb +3 -8
  158. data/lib/puppet/pops/types/p_meta_type.rb +83 -0
  159. data/lib/puppet/pops/types/p_object_type.rb +110 -117
  160. data/lib/puppet/pops/types/p_runtime_type.rb +13 -0
  161. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +23 -0
  162. data/lib/puppet/pops/types/p_sem_ver_type.rb +30 -2
  163. data/lib/puppet/pops/types/p_sensitive_type.rb +69 -0
  164. data/lib/puppet/pops/types/p_type_set_type.rb +361 -0
  165. data/lib/puppet/pops/types/puppet_object.rb +0 -5
  166. data/lib/puppet/pops/types/ruby_generator.rb +9 -2
  167. data/lib/puppet/pops/types/type_calculator.rb +6 -1
  168. data/lib/puppet/pops/types/type_factory.rb +14 -12
  169. data/lib/puppet/pops/types/type_formatter.rb +78 -33
  170. data/lib/puppet/pops/types/type_mismatch_describer.rb +0 -2
  171. data/lib/puppet/pops/types/type_parser.rb +27 -2
  172. data/lib/puppet/pops/types/type_set_reference.rb +59 -0
  173. data/lib/puppet/pops/types/types.rb +366 -13
  174. data/lib/puppet/pops/validation.rb +4 -4
  175. data/lib/puppet/pops/validation/checker4_0.rb +5 -2
  176. data/lib/puppet/pops/visitor.rb +2 -2
  177. data/lib/puppet/property.rb +64 -5
  178. data/lib/puppet/provider.rb +1 -1
  179. data/lib/puppet/provider/aixobject.rb +3 -3
  180. data/lib/puppet/provider/group/aix.rb +4 -4
  181. data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
  182. data/lib/puppet/provider/mailalias/aliases.rb +1 -1
  183. data/lib/puppet/provider/mcx/mcxcontent.rb +2 -2
  184. data/lib/puppet/provider/mount/parsed.rb +1 -1
  185. data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
  186. data/lib/puppet/provider/package/appdmg.rb +3 -3
  187. data/lib/puppet/provider/package/apple.rb +1 -1
  188. data/lib/puppet/provider/package/dnf.rb +5 -0
  189. data/lib/puppet/provider/package/nim.rb +1 -1
  190. data/lib/puppet/provider/package/pacman.rb +2 -2
  191. data/lib/puppet/provider/package/pip.rb +5 -3
  192. data/lib/puppet/provider/package/pip3.rb +1 -1
  193. data/lib/puppet/provider/package/pkg.rb +5 -5
  194. data/lib/puppet/provider/package/pkgdmg.rb +4 -4
  195. data/lib/puppet/provider/package/pkgin.rb +1 -1
  196. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  197. data/lib/puppet/provider/package/portage.rb +48 -8
  198. data/lib/puppet/provider/package/sun.rb +1 -1
  199. data/lib/puppet/provider/package/tdnf.rb +28 -0
  200. data/lib/puppet/provider/package/yum.rb +22 -4
  201. data/lib/puppet/provider/parsedfile.rb +2 -2
  202. data/lib/puppet/provider/service/base.rb +1 -1
  203. data/lib/puppet/provider/service/bsd.rb +1 -1
  204. data/lib/puppet/provider/service/daemontools.rb +2 -2
  205. data/lib/puppet/provider/service/debian.rb +3 -3
  206. data/lib/puppet/provider/service/init.rb +5 -3
  207. data/lib/puppet/provider/service/launchd.rb +16 -2
  208. data/lib/puppet/provider/service/runit.rb +1 -1
  209. data/lib/puppet/provider/service/smf.rb +8 -1
  210. data/lib/puppet/provider/service/systemd.rb +39 -6
  211. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  212. data/lib/puppet/provider/user/aix.rb +3 -2
  213. data/lib/puppet/provider/user/directoryservice.rb +4 -3
  214. data/lib/puppet/provider/user/hpux.rb +1 -1
  215. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  216. data/lib/puppet/provider/user/windows_adsi.rb +3 -0
  217. data/lib/puppet/provider/zfs/zfs.rb +1 -1
  218. data/lib/puppet/reference/type.rb +1 -1
  219. data/lib/puppet/resource.rb +33 -7
  220. data/lib/puppet/resource/capability_finder.rb +74 -54
  221. data/lib/puppet/resource/status.rb +11 -2
  222. data/lib/puppet/settings.rb +17 -6
  223. data/lib/puppet/settings/environment_conf.rb +1 -1
  224. data/lib/puppet/settings/server_list_setting.rb +20 -0
  225. data/lib/puppet/ssl/certificate_authority.rb +32 -9
  226. data/lib/puppet/ssl/certificate_authority/interface.rb +164 -24
  227. data/lib/puppet/ssl/host.rb +3 -3
  228. data/lib/puppet/ssl/oids.rb +10 -0
  229. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  230. data/lib/puppet/test/test_helper.rb +2 -2
  231. data/lib/puppet/transaction.rb +12 -0
  232. data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
  233. data/lib/puppet/transaction/event.rb +29 -2
  234. data/lib/puppet/transaction/event_manager.rb +1 -1
  235. data/lib/puppet/transaction/persistence.rb +84 -0
  236. data/lib/puppet/transaction/report.rb +49 -2
  237. data/lib/puppet/transaction/resource_harness.rb +98 -18
  238. data/lib/puppet/type.rb +63 -21
  239. data/lib/puppet/type/augeas.rb +3 -3
  240. data/lib/puppet/type/cron.rb +1 -1
  241. data/lib/puppet/type/file.rb +39 -2
  242. data/lib/puppet/type/file/data_sync.rb +13 -5
  243. data/lib/puppet/type/host.rb +1 -1
  244. data/lib/puppet/type/mount.rb +2 -6
  245. data/lib/puppet/type/notify.rb +1 -1
  246. data/lib/puppet/type/package.rb +1 -1
  247. data/lib/puppet/type/resources.rb +1 -1
  248. data/lib/puppet/type/scheduled_task.rb +1 -1
  249. data/lib/puppet/type/ssh_authorized_key.rb +2 -2
  250. data/lib/puppet/type/tidy.rb +1 -1
  251. data/lib/puppet/type/yumrepo.rb +3 -3
  252. data/lib/puppet/type/zone.rb +1 -1
  253. data/lib/puppet/util.rb +2 -2
  254. data/lib/puppet/util/classgen.rb +1 -1
  255. data/lib/puppet/util/command_line.rb +6 -2
  256. data/lib/puppet/util/command_line/trollop.rb +1 -1
  257. data/lib/puppet/util/execution.rb +2 -2
  258. data/lib/puppet/util/http_proxy.rb +1 -1
  259. data/lib/puppet/util/inifile.rb +1 -1
  260. data/lib/puppet/util/instance_loader.rb +1 -1
  261. data/lib/puppet/util/logging.rb +1 -1
  262. data/lib/puppet/util/multi_match.rb +1 -1
  263. data/lib/puppet/util/plist.rb +15 -5
  264. data/lib/puppet/util/profiler.rb +1 -1
  265. data/lib/puppet/util/profiler/around_profiler.rb +1 -1
  266. data/lib/puppet/util/psych_support.rb +1 -1
  267. data/lib/puppet/util/rdoc.rb +2 -2
  268. data/lib/puppet/util/rubygems.rb +1 -1
  269. data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
  270. data/lib/puppet/util/windows/access_control_entry.rb +1 -1
  271. data/lib/puppet/util/windows/adsi.rb +30 -8
  272. data/lib/puppet/util/windows/api_types.rb +1 -1
  273. data/lib/puppet/util/windows/file.rb +59 -0
  274. data/lib/puppet/util/windows/process.rb +10 -0
  275. data/lib/puppet/util/windows/security.rb +1 -1
  276. data/lib/puppet/util/windows/user.rb +22 -4
  277. data/lib/puppet/util/yaml.rb +15 -3
  278. data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
  279. data/lib/puppet/vendor/rgen_patch.rb +1 -1
  280. data/lib/puppet/version.rb +2 -2
  281. data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
  282. data/spec/integration/agent/logging_spec.rb +15 -14
  283. data/spec/integration/application/apply_spec.rb +1 -0
  284. data/spec/integration/directory_environments_spec.rb +16 -0
  285. data/spec/integration/environments/settings_spec.rb +32 -4
  286. data/spec/integration/faces/documentation_spec.rb +1 -1
  287. data/spec/integration/network/http/api/indirected_routes_spec.rb +33 -0
  288. data/spec/integration/node/environment_spec.rb +21 -0
  289. data/spec/integration/parser/collection_spec.rb +10 -0
  290. data/spec/integration/parser/compiler_spec.rb +76 -840
  291. data/spec/integration/parser/functions/require_spec.rb +3 -3
  292. data/spec/integration/parser/parameter_defaults_spec.rb +6 -2
  293. data/spec/integration/parser/pcore_resource_spec.rb +208 -0
  294. data/spec/integration/parser/resource_expressions_spec.rb +4 -2
  295. data/spec/integration/provider/yumrepo_spec.rb +4 -1
  296. data/spec/integration/transaction/report_spec.rb +666 -0
  297. data/spec/integration/type/file_spec.rb +11 -12
  298. data/spec/integration/util/windows/adsi_spec.rb +99 -0
  299. data/spec/integration/util/windows/principal_spec.rb +109 -60
  300. data/spec/integration/util/windows/process_spec.rb +4 -2
  301. data/spec/integration/util/windows/security_spec.rb +34 -8
  302. data/spec/integration/util/windows/user_spec.rb +26 -4
  303. data/spec/lib/puppet_spec/files.rb +2 -2
  304. data/spec/lib/puppet_spec/network.rb +12 -8
  305. data/spec/shared_examples/rhel_package_provider.rb +341 -0
  306. data/spec/spec_helper.rb +8 -2
  307. data/spec/unit/application/cert_spec.rb +20 -0
  308. data/spec/unit/configurer/plugin_handler_spec.rb +0 -26
  309. data/spec/unit/configurer_spec.rb +46 -0
  310. data/spec/unit/defaults_spec.rb +14 -0
  311. data/spec/unit/face/generate_spec.rb +230 -0
  312. data/spec/unit/face/help_spec.rb +53 -0
  313. data/spec/unit/face/parser_spec.rb +6 -0
  314. data/spec/unit/face/plugin_spec.rb +0 -4
  315. data/spec/unit/file_system_spec.rb +85 -0
  316. data/spec/unit/functions/lookup_spec.rb +4 -4
  317. data/spec/unit/functions/match_spec.rb +2 -2
  318. data/spec/unit/functions/regsubst_spec.rb +1 -1
  319. data/spec/unit/functions/split_spec.rb +1 -1
  320. data/spec/unit/functions/unwrap_spec.rb +29 -0
  321. data/spec/unit/functions/versioncmp_spec.rb +1 -1
  322. data/spec/unit/functions4_spec.rb +8 -8
  323. data/spec/unit/indirector/facts/facter_spec.rb +1 -9
  324. data/spec/unit/indirector/rest_spec.rb +95 -9
  325. data/spec/unit/module_spec.rb +43 -7
  326. data/spec/unit/module_tool/applications/installer_spec.rb +10 -1
  327. data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
  328. data/spec/unit/module_tool/applications/upgrader_spec.rb +8 -0
  329. data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
  330. data/spec/unit/network/http/api/indirected_routes_spec.rb +49 -58
  331. data/spec/unit/network/http/api/master/v3_spec.rb +7 -4
  332. data/spec/unit/network/rights_spec.rb +1 -1
  333. data/spec/unit/parameter_spec.rb +11 -0
  334. data/spec/unit/parser/compiler_spec.rb +19 -33
  335. data/spec/unit/{appmgmt_spec.rb → parser/environment_compiler_spec.rb} +12 -1
  336. data/spec/unit/parser/functions/create_resources_spec.rb +76 -4
  337. data/spec/unit/parser/functions/require_spec.rb +2 -2
  338. data/spec/unit/parser/resource_spec.rb +21 -11
  339. data/spec/unit/parser/scope_spec.rb +1 -5
  340. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
  341. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  342. data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
  343. data/spec/unit/pops/loaders/loaders_spec.rb +63 -5
  344. data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
  345. data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
  346. data/spec/unit/pops/parser/lexer2_spec.rb +27 -3
  347. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +8 -0
  348. data/spec/unit/pops/parser/parse_calls_spec.rb +9 -0
  349. data/spec/unit/pops/puppet_stack_spec.rb +79 -0
  350. data/spec/unit/pops/resource/resource_type_impl_spec.rb +37 -0
  351. data/spec/unit/pops/serialization/packer_spec.rb +153 -0
  352. data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
  353. data/spec/unit/pops/serialization/serialization_spec.rb +228 -0
  354. data/spec/unit/pops/types/p_object_type_spec.rb +44 -2
  355. data/spec/unit/pops/types/p_sem_ver_type_spec.rb +42 -0
  356. data/spec/unit/pops/types/p_sensitive_type_spec.rb +139 -0
  357. data/spec/unit/pops/types/p_type_set_type_spec.rb +424 -0
  358. data/spec/unit/pops/types/ruby_generator_spec.rb +497 -181
  359. data/spec/unit/pops/types/type_calculator_spec.rb +10 -4
  360. data/spec/unit/pops/types/type_formatter_spec.rb +1 -1
  361. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
  362. data/spec/unit/pops/types/type_parser_spec.rb +1 -1
  363. data/spec/unit/pops/types/types_spec.rb +1 -1
  364. data/spec/unit/pops/validator/validator_spec.rb +18 -1
  365. data/spec/unit/property_spec.rb +48 -11
  366. data/spec/unit/provider/group/windows_adsi_spec.rb +11 -1
  367. data/spec/unit/provider/package/dnf_spec.rb +1 -99
  368. data/spec/unit/provider/package/pacman_spec.rb +4 -4
  369. data/spec/unit/provider/package/pip_spec.rb +14 -0
  370. data/spec/unit/provider/package/pkg_spec.rb +6 -0
  371. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -3
  372. data/spec/unit/provider/package/portage_spec.rb +64 -8
  373. data/spec/unit/provider/package/tdnf_spec.rb +18 -0
  374. data/spec/unit/provider/package/windows/package_spec.rb +4 -1
  375. data/spec/unit/provider/package/windows_spec.rb +8 -2
  376. data/spec/unit/provider/package/yum_spec.rb +6 -377
  377. data/spec/unit/provider/service/base_spec.rb +6 -0
  378. data/spec/unit/provider/service/debian_spec.rb +16 -7
  379. data/spec/unit/provider/service/gentoo_spec.rb +6 -0
  380. data/spec/unit/provider/service/init_spec.rb +7 -0
  381. data/spec/unit/provider/service/launchd_spec.rb +35 -4
  382. data/spec/unit/provider/service/openrc_spec.rb +6 -0
  383. data/spec/unit/provider/service/smf_spec.rb +31 -6
  384. data/spec/unit/provider/service/src_spec.rb +6 -0
  385. data/spec/unit/provider/service/systemd_spec.rb +70 -20
  386. data/spec/unit/provider/service/upstart_spec.rb +6 -0
  387. data/spec/unit/provider/user/aix_spec.rb +7 -0
  388. data/spec/unit/provider/user/directoryservice_spec.rb +30 -1
  389. data/spec/unit/provider/user/windows_adsi_spec.rb +19 -0
  390. data/spec/unit/resource/capability_finder_spec.rb +51 -3
  391. data/spec/unit/resource/catalog_spec.rb +5 -0
  392. data/spec/unit/resource/type_spec.rb +2 -2
  393. data/spec/unit/resource_spec.rb +19 -0
  394. data/spec/unit/settings_spec.rb +13 -0
  395. data/spec/unit/ssl/certificate_authority/interface_spec.rb +176 -10
  396. data/spec/unit/ssl/certificate_authority_spec.rb +63 -22
  397. data/spec/unit/ssl/host_spec.rb +1 -1
  398. data/spec/unit/ssl/oids_spec.rb +24 -21
  399. data/spec/unit/transaction/event_spec.rb +3 -1
  400. data/spec/unit/transaction/persistence_spec.rb +173 -0
  401. data/spec/unit/transaction/report_spec.rb +64 -1
  402. data/spec/unit/transaction/resource_harness_spec.rb +91 -0
  403. data/spec/unit/type/file/content_spec.rb +47 -15
  404. data/spec/unit/type/file_spec.rb +28 -0
  405. data/spec/unit/type/mount_spec.rb +5 -12
  406. data/spec/unit/type/yumrepo_spec.rb +1 -5
  407. data/spec/unit/type_spec.rb +32 -0
  408. data/spec/unit/util/command_line_spec.rb +11 -0
  409. data/spec/unit/util/execution_spec.rb +1 -1
  410. data/spec/unit/util/plist_spec.rb +16 -3
  411. data/spec/unit/util/storage_spec.rb +4 -1
  412. data/spec/unit/util/windows/adsi_spec.rb +23 -2
  413. data/spec/unit/util/windows/file_spec.rb +56 -1
  414. data/spec/unit/util/windows/sid_spec.rb +31 -7
  415. data/spec/unit/util/yaml_spec.rb +12 -0
  416. data/spec/unit/util_spec.rb +87 -20
  417. metadata +91 -48
  418. data/ext/puppetlisten/puppetlisten.rb +0 -77
  419. data/ext/puppetlisten/puppetrun.rb +0 -38
  420. data/lib/puppet/resource/type_collection_helper.rb +0 -7
  421. data/spec/unit/parser/functions/defined_spec.rb +0 -120
  422. data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
@@ -15,7 +15,7 @@ describe "The require function" do
15
15
  end
16
16
 
17
17
  it "should add a dependency between the 'required' class and our class" do
18
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")
18
+ @compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")
19
19
 
20
20
  @scope.function_require(["requiredclass"])
21
21
  expect(@scope.resource["require"]).not_to be_nil
@@ -25,8 +25,8 @@ describe "The require function" do
25
25
  end
26
26
 
27
27
  it "should queue relationships between the 'required' class and our classes" do
28
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
29
- @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")
28
+ @compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
29
+ @compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")
30
30
 
31
31
  @scope.function_require(["requiredclass1"])
32
32
  @scope.function_require(["requiredclass2"])
@@ -26,12 +26,16 @@ require 'puppet_spec/language'
26
26
 
27
27
  let (:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new('specification')) }
28
28
 
29
+ let (:topscope) { compiler.topscope }
30
+
29
31
  def collect_notices(code)
30
32
  logs = []
31
33
  Puppet[:code] = code
32
34
  Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
33
- compiler.compile
34
- yield
35
+ compiler.compile do |catalog|
36
+ yield
37
+ catalog
38
+ end
35
39
  end
36
40
  logs.select { |log| log.level == :notice }.map { |log| log.message }
37
41
  end
@@ -0,0 +1,208 @@
1
+ require 'spec_helper'
2
+ require 'puppet_spec/files'
3
+ require 'puppet_spec/compiler'
4
+
5
+ require 'puppet/face'
6
+
7
+ describe 'when pcore described resources types are in use' do
8
+ include PuppetSpec::Files
9
+ include PuppetSpec::Compiler
10
+
11
+ let(:genface) { Puppet::Face[:generate, :current] }
12
+
13
+ context "in an environment with two modules" do
14
+ let(:dir) do
15
+ dir_containing('environments', { 'production' => {
16
+ 'environment.conf' => "modulepath = modules",
17
+ 'manifests' => { 'site.pp' => "" },
18
+ 'modules' => {
19
+ 'm1' => {
20
+ 'lib' => { 'puppet' => { 'type' => {
21
+ 'test1.rb' => <<-EOF
22
+ module Puppet
23
+ Type.newtype(:test1) do
24
+ @doc = "Docs for resource"
25
+ newproperty(:message) do
26
+ desc "Docs for 'message' property"
27
+ end
28
+ newparam(:name) do
29
+ desc "Docs for 'name' parameter"
30
+ isnamevar
31
+ end
32
+ newparam(:whatever) do
33
+ desc "Docs for 'whatever' parameter"
34
+ end
35
+ end; end
36
+ EOF
37
+ } }
38
+ },
39
+ },
40
+ 'm2' => {
41
+ 'lib' => { 'puppet' => { 'type' => {
42
+ 'test2.rb' => <<-EOF
43
+ module Puppet
44
+ Type.newtype(:test2) do
45
+ @doc = "Docs for resource"
46
+ @isomorphic = false
47
+ newproperty(:message) do
48
+ desc "Docs for 'message' property"
49
+ end
50
+ newparam(:name) do
51
+ desc "Docs for 'name' parameter"
52
+ isnamevar
53
+ end
54
+ newparam(:color) do
55
+ desc "Docs for 'color' parameter"
56
+ newvalues(:red, :green, :blue, /#[0-9A-Z]{6}/)
57
+ end
58
+ end;end
59
+ EOF
60
+ } } },
61
+ }
62
+ }}})
63
+ end
64
+
65
+ let(:modulepath) do
66
+ File.join(dir, 'production', 'modules')
67
+ end
68
+
69
+ let(:m1) do
70
+ File.join(modulepath, 'm1')
71
+ end
72
+
73
+ let(:m2) do
74
+ File.join(modulepath, 'm2')
75
+ end
76
+
77
+ let(:outputdir) do
78
+ File.join(dir, 'production', '.resource_types')
79
+ end
80
+
81
+ around(:each) do |example|
82
+ Puppet.settings.initialize_global_settings
83
+ Puppet[:manifest] = ''
84
+ loader = Puppet::Environments::Directories.new(dir, [])
85
+ Puppet.override(:environments => loader) do
86
+ Puppet.override(:current_environment => loader.get('production')) do
87
+ example.run
88
+ end
89
+ end
90
+ end
91
+
92
+ it 'can use generated types to compile a catalog' do
93
+ genface.types
94
+ catalog = compile_to_catalog(<<-MANIFEST)
95
+ test1 { 'a':
96
+ message => 'a works'
97
+ }
98
+ # Several instances of the type can be created - implicit test
99
+ test1 { 'another a':
100
+ message => 'another a works'
101
+ }
102
+ test2 { 'b':
103
+ message => 'b works'
104
+ }
105
+ MANIFEST
106
+ expect(catalog.resource(:test1, "a")['message']).to eq('a works')
107
+ expect(catalog.resource(:test2, "b")['message']).to eq('b works')
108
+ end
109
+
110
+ it 'the validity of attribute names are checked' do
111
+ genface.types
112
+ expect do
113
+ compile_to_catalog(<<-MANIFEST)
114
+ test1 { 'a':
115
+ mezzage => 'a works'
116
+ }
117
+ MANIFEST
118
+ end.to raise_error(/no parameter named 'mezzage'/)
119
+ end
120
+
121
+ it 'meta-parameters such as noop can be used' do
122
+ genface.types
123
+ catalog = compile_to_catalog(<<-MANIFEST)
124
+ test1 { 'a':
125
+ message => 'noop works',
126
+ noop => true
127
+ }
128
+ MANIFEST
129
+ expect(catalog.resource(:test1, "a")['noop']).to eq(true)
130
+ end
131
+
132
+ it 'a generated type describes if it is isomorphic' do
133
+ generate_and_in_a_compilers_context do |compiler|
134
+ t1 = find_resource_type(compiler.topscope, 'test1')
135
+ expect(t1.isomorphic?).to be(true)
136
+ t2 = find_resource_type(compiler.topscope, 'test2')
137
+ expect(t2.isomorphic?).to be(false)
138
+ end
139
+ end
140
+
141
+ it 'a generated type returns parameters defined in pcore' do
142
+ generate_and_in_a_compilers_context do |compiler|
143
+ t1 = find_resource_type(compiler.topscope, 'test1')
144
+ expect(t1.parameters.size).to be(2)
145
+ expect(t1.parameters[0].name).to eql('name')
146
+ expect(t1.parameters[1].name).to eql('whatever')
147
+ end
148
+ end
149
+
150
+ it 'a generated type picks up and returns if a parameter is a namevar' do
151
+ generate_and_in_a_compilers_context do |compiler|
152
+ t1 = find_resource_type(compiler.topscope, 'test1')
153
+ expect(t1.parameters[0].name_var).to be(true)
154
+ expect(t1.parameters[1].name_var).to be(false)
155
+ end
156
+ end
157
+
158
+ it 'a generated type returns properties defined in pcore' do
159
+ generate_and_in_a_compilers_context do |compiler|
160
+ t1 = find_resource_type(compiler.topscope, 'test1')
161
+ expect(t1.properties.size).to be(1)
162
+ expect(t1.properties[0].name).to eql('message')
163
+ end
164
+ end
165
+
166
+ it 'a generated type returns [[/(.*)/m, <first attr>]] as default title_pattern when there is a namevar but no pattern specified' do
167
+ generate_and_in_a_compilers_context do |compiler|
168
+ t1 = find_resource_type(compiler.topscope, 'test1')
169
+ expect(t1.title_patterns.size).to be(1)
170
+ expect(t1.title_patterns[0][0]).to eql(/(.*)/m)
171
+ end
172
+ end
173
+
174
+ it "the compiler asserts the type of parameters" do
175
+ pending "assertion of parameter types not yet implemented"
176
+ genface.types
177
+ expect {
178
+ catalog = compile_to_catalog(<<-MANIFEST)
179
+ test2 { 'b':
180
+ color => 'white is not a color'
181
+ }
182
+ MANIFEST
183
+ }.to raise_error(/an error indicating that color cannot have that value/) # ERROR TBD.
184
+ end
185
+ end
186
+
187
+ def find_resource_type(scope, name)
188
+ t1 = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, name)
189
+ end
190
+
191
+ def generate_and_in_a_compilers_context(&block)
192
+ genface.types
193
+ # Since an instance of a compiler is needed and it starts an initial import that evaluates
194
+ # code, and that code will be loaded from manifests with a glob (go figure)
195
+ # the only way to stop that is to set 'code' to something as that overrides "importing" files.
196
+ Puppet[:code] = "undef"
197
+ node = Puppet::Node.new('test')
198
+ # All loading must be done in a context configured as the compiler does it.
199
+ # (Therefore: use the context a compiler creates as this test logic must otherwise
200
+ # know how to do this).
201
+ #
202
+ compiler = Puppet::Parser::Compiler.new(node)
203
+ Puppet::override(compiler.context_overrides) do
204
+ block.call(compiler)
205
+ end
206
+ end
207
+
208
+ end
@@ -164,8 +164,10 @@ describe "Puppet resource expressions" do
164
164
  path => '/somewhere',
165
165
  * => $y }" => "File[$t][mode] == '0666' and File[$t][owner] == 'the_x' and File[$t][path] == '/somewhere'")
166
166
 
167
- produces("notify{title:}; Notify[title] { * => { message => set}}" => "Notify[title][message] == 'set'")
168
- produces("Notify { * => { message => set}}; notify{title:}" => "Notify[title][message] == 'set'")
167
+ produces("notify{title:}; Notify[title] { * => { message => set}}" => "Notify[title][message] == 'set'")
168
+ produces("Notify { * => { message => set}}; notify{title:}" => "Notify[title][message] == 'set'")
169
+ produces('define foo($x) { notify { "title": message =>"aaa${x}bbb"} } foo{ test: x => undef }' => "Notify[title][message] == 'aaabbb'")
170
+ produces('define foo($x="xx") { notify { "title": message =>"aaa${x}bbb"} } foo{ test: x => undef }' => "Notify[title][message] == 'aaaxxbbb'")
169
171
 
170
172
  fails("notify { title: unknown => value }" => /no parameter named 'unknown'/)
171
173
 
@@ -87,7 +87,7 @@ describe Puppet::Type.type(:yumrepo).provider(:inifile), '(integration)',
87
87
  properties = {"bandwidth" => "42M",
88
88
  "baseurl" => "http://er0ck",
89
89
  "cost" => "42",
90
- "enabled" => "Yes",
90
+ "enabled" => "yes",
91
91
  "exclude" => "er0ckSet2.0",
92
92
  "failovermethod" => "roundrobin",
93
93
  "include" => "https://er0ck",
@@ -107,6 +107,9 @@ describe Puppet::Type.type(:yumrepo).provider(:inifile), '(integration)',
107
107
  apply_with_error_check(manifest)
108
108
  file_lines = File.read(File.join(@yumrepo_dir, super_creative + '.repo'))
109
109
  properties.each do |property_key, property_value|
110
+ if property_value =~ /^(true|false|no|yes)$/
111
+ property_value = property_value.capitalize
112
+ end
110
113
  expect(file_lines).to match(/^#{property_key}=#{Regexp.escape(property_value)}$/)
111
114
  end
112
115
  end
@@ -1,5 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
  require 'spec_helper'
3
+ require 'puppet_spec/files'
3
4
 
4
5
  describe Puppet::Transaction::Report do
5
6
  describe "when using the indirector" do
@@ -37,4 +38,669 @@ describe Puppet::Transaction::Report do
37
38
  expect(YAML.dump(report)).to_not match('Puppet::Util::TagSet')
38
39
  end
39
40
  end
41
+
42
+ describe "inference checking" do
43
+ include PuppetSpec::Files
44
+ require 'puppet/configurer'
45
+
46
+ def run_catalogs(resources1, resources2, noop1 = false, noop2 = false, &block)
47
+ last_run_report = nil
48
+ Puppet::Transaction::Report.indirection.expects(:save).twice.with do |report, x|
49
+ last_run_report = report
50
+ true
51
+ end
52
+
53
+ Puppet[:report] = true
54
+ Puppet[:noop] = noop1
55
+
56
+ configurer = Puppet::Configurer.new
57
+ configurer.run :catalog => new_catalog(resources1)
58
+
59
+ yield block if block
60
+ last_report = last_run_report
61
+
62
+ Puppet[:noop] = noop2
63
+
64
+ configurer = Puppet::Configurer.new
65
+ configurer.run :catalog => new_catalog(resources2)
66
+
67
+ expect(last_report).not_to eq(last_run_report)
68
+
69
+ return last_run_report
70
+ end
71
+
72
+ def new_blank_catalog
73
+ Puppet::Resource::Catalog.new("testing", Puppet.lookup(:environments).get(Puppet[:environment]))
74
+ end
75
+
76
+ def new_catalog(resources = [])
77
+ new_cat = new_blank_catalog
78
+ [resources].flatten.each do |resource|
79
+ new_cat.add_resource(resource)
80
+ end
81
+ new_cat
82
+ end
83
+
84
+ def get_cc_count(report)
85
+ cc = report.metrics["resources"].values.each do |v|
86
+ if v[0] == "corrective_change"
87
+ return v[2]
88
+ end
89
+ end
90
+ return nil
91
+ end
92
+
93
+ describe "for agent runs that contain" do
94
+ it "notifies with catalog change" do
95
+ report = run_catalogs(Puppet::Type.type(:notify).new(:title => "testing",
96
+ :message => "foo"),
97
+ Puppet::Type.type(:notify).new(:title => "testing",
98
+ :message => "foobar"))
99
+
100
+ expect(report.status).to eq("changed")
101
+
102
+ rs = report.resource_statuses["Notify[testing]"]
103
+ expect(rs.events.size).to eq(1)
104
+ expect(rs.events[0].corrective_change).to eq(false)
105
+ expect(rs.corrective_change).to eq(false)
106
+
107
+ expect(report.corrective_change).to eq(false)
108
+ expect(get_cc_count(report)).to eq(0)
109
+ end
110
+
111
+ it "notifies with no catalog change" do
112
+ report = run_catalogs(Puppet::Type.type(:notify).new(:title => "testing",
113
+ :message => "foo"),
114
+ Puppet::Type.type(:notify).new(:title => "testing",
115
+ :message => "foo"))
116
+
117
+ expect(report.status).to eq("changed")
118
+
119
+ rs = report.resource_statuses["Notify[testing]"]
120
+ expect(rs.events.size).to eq(1)
121
+ expect(rs.events[0].corrective_change).to eq(false)
122
+ expect(rs.corrective_change).to eq(false)
123
+
124
+ expect(report.corrective_change).to eq(false)
125
+ expect(get_cc_count(report)).to eq(0)
126
+ end
127
+
128
+ it "new file resource" do
129
+ file = tmpfile("test_file")
130
+ report = run_catalogs([],
131
+ Puppet::Type.type(:file).new(:title => file,
132
+ :content => "mystuff"))
133
+
134
+ expect(report.status).to eq("changed")
135
+
136
+ rs = report.resource_statuses["File[#{file}]"]
137
+ expect(rs.events.size).to eq(1)
138
+ expect(rs.events[0].corrective_change).to eq(false)
139
+ expect(rs.corrective_change).to eq(false)
140
+
141
+ expect(report.corrective_change).to eq(false)
142
+ expect(get_cc_count(report)).to eq(0)
143
+ end
144
+
145
+ it "removal of a file resource" do
146
+ file = tmpfile("test_file")
147
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
148
+ :content => "mystuff"),
149
+ [])
150
+
151
+ expect(report.status).to eq("unchanged")
152
+ expect(report.resource_statuses["File[#{file}]"]).to eq(nil)
153
+ expect(report.corrective_change).to eq(false)
154
+ expect(get_cc_count(report)).to eq(0)
155
+ end
156
+
157
+ it "file with a title change" do
158
+ file1 = tmpfile("test_file")
159
+ file2 = tmpfile("test_file")
160
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file1,
161
+ :content => "mystuff"),
162
+ Puppet::Type.type(:file).new(:title => file2,
163
+ :content => "mystuff"))
164
+
165
+ expect(report.status).to eq("changed")
166
+
167
+ expect(report.resource_statuses["File[#{file1}]"]).to eq(nil)
168
+
169
+ rs = report.resource_statuses["File[#{file2}]"]
170
+ expect(rs.events.size).to eq(1)
171
+ expect(rs.events[0].corrective_change).to eq(false)
172
+ expect(rs.corrective_change).to eq(false)
173
+
174
+ expect(report.corrective_change).to eq(false)
175
+ expect(get_cc_count(report)).to eq(0)
176
+ end
177
+
178
+ it "file with no catalog change" do
179
+ file = tmpfile("test_file")
180
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
181
+ :content => "mystuff"),
182
+ Puppet::Type.type(:file).new(:title => file,
183
+ :content => "mystuff"))
184
+
185
+ expect(report.status).to eq("unchanged")
186
+
187
+ rs = report.resource_statuses["File[#{file}]"]
188
+ expect(rs.events.size).to eq(0)
189
+ expect(rs.corrective_change).to eq(false)
190
+
191
+ expect(report.corrective_change).to eq(false)
192
+ expect(get_cc_count(report)).to eq(0)
193
+ end
194
+
195
+ it "file with a new parameter" do
196
+ file = tmpfile("test_file")
197
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
198
+ :content => "mystuff"),
199
+ Puppet::Type.type(:file).new(:title => file,
200
+ :content => "mystuff",
201
+ :loglevel => :debug))
202
+
203
+ expect(report.status).to eq("unchanged")
204
+
205
+ rs = report.resource_statuses["File[#{file}]"]
206
+ expect(rs.events.size).to eq(0)
207
+ expect(rs.corrective_change).to eq(false)
208
+
209
+ expect(report.corrective_change).to eq(false)
210
+ expect(get_cc_count(report)).to eq(0)
211
+ end
212
+
213
+ it "file with a removed parameter" do
214
+ file = tmpfile("test_file")
215
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
216
+ :content => "mystuff",
217
+ :loglevel => :debug),
218
+ Puppet::Type.type(:file).new(:title => file,
219
+ :content => "mystuff"))
220
+
221
+ expect(report.status).to eq("unchanged")
222
+
223
+ rs = report.resource_statuses["File[#{file}]"]
224
+ expect(rs.events.size).to eq(0)
225
+ expect(rs.corrective_change).to eq(false)
226
+
227
+ expect(report.corrective_change).to eq(false)
228
+ expect(get_cc_count(report)).to eq(0)
229
+ end
230
+
231
+ it "file with a property no longer managed" do
232
+ file = tmpfile("test_file")
233
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
234
+ :content => "mystuff"),
235
+ Puppet::Type.type(:file).new(:title => file))
236
+
237
+ expect(report.status).to eq("unchanged")
238
+
239
+ rs = report.resource_statuses["File[#{file}]"]
240
+ expect(rs.events.size).to eq(0)
241
+ expect(rs.corrective_change).to eq(false)
242
+
243
+ expect(report.corrective_change).to eq(false)
244
+ expect(get_cc_count(report)).to eq(0)
245
+ end
246
+
247
+ it "file with no catalog change, but file changed between runs" do
248
+ file = tmpfile("test_file")
249
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
250
+ :content => "mystuff"),
251
+ Puppet::Type.type(:file).new(:title => file,
252
+ :content => "mystuff")) do
253
+ File.open(file, 'w') do |f|
254
+ f.puts "some content"
255
+ end
256
+ end
257
+
258
+ expect(report.status).to eq("changed")
259
+
260
+ rs = report.resource_statuses["File[#{file}]"]
261
+ expect(rs.events.size).to eq(1)
262
+ expect(rs.events[0].corrective_change).to eq(true)
263
+ expect(rs.corrective_change).to eq(true)
264
+
265
+ expect(report.corrective_change).to eq(true)
266
+ expect(get_cc_count(report)).to eq(1)
267
+ end
268
+
269
+ it "file with catalog change, but file changed between runs that matched catalog change" do
270
+ file = tmpfile("test_file")
271
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
272
+ :content => "mystuff"),
273
+ Puppet::Type.type(:file).new(:title => file,
274
+ :content => "some content")) do
275
+ File.open(file, 'w') do |f|
276
+ f.write "some content"
277
+ end
278
+ end
279
+
280
+ expect(report.status).to eq("unchanged")
281
+
282
+ rs = report.resource_statuses["File[#{file}]"]
283
+ expect(rs.events.size).to eq(0)
284
+ expect(rs.corrective_change).to eq(false)
285
+
286
+ expect(report.corrective_change).to eq(false)
287
+ expect(get_cc_count(report)).to eq(0)
288
+ end
289
+
290
+ it "file with catalog change, but file changed between runs that did not match catalog change" do
291
+ file = tmpfile("test_file")
292
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
293
+ :content => "mystuff1"),
294
+ Puppet::Type.type(:file).new(:title => file,
295
+ :content => "mystuff2")) do
296
+ File.open(file, 'w') do |file|
297
+ file.write "some content"
298
+ end
299
+ end
300
+
301
+ expect(report.status).to eq("changed")
302
+
303
+ rs = report.resource_statuses["File[#{file}]"]
304
+ expect(rs.events.size).to eq(1)
305
+ expect(rs.events[0].corrective_change).to eq(true)
306
+ expect(rs.corrective_change).to eq(true)
307
+
308
+ expect(report.corrective_change).to eq(true)
309
+ expect(get_cc_count(report)).to eq(1)
310
+ end
311
+
312
+ it "file with catalog change" do
313
+ file = tmpfile("test_file")
314
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
315
+ :content => "mystuff1"),
316
+ Puppet::Type.type(:file).new(:title => file,
317
+ :content => "mystuff2"))
318
+
319
+ expect(report.status).to eq("changed")
320
+
321
+ rs = report.resource_statuses["File[#{file}]"]
322
+ expect(rs.events.size).to eq(1)
323
+ expect(rs.events[0].corrective_change).to eq(false)
324
+ expect(rs.corrective_change).to eq(false)
325
+
326
+ expect(report.corrective_change).to eq(false)
327
+ expect(get_cc_count(report)).to eq(0)
328
+ end
329
+
330
+ it "file with ensure property set to present" do
331
+ file = tmpfile("test_file")
332
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
333
+ :ensure => :present),
334
+ Puppet::Type.type(:file).new(:title => file,
335
+ :ensure => :present))
336
+
337
+ expect(report.status).to eq("unchanged")
338
+
339
+ rs = report.resource_statuses["File[#{file}]"]
340
+ expect(rs.events.size).to eq(0)
341
+ expect(rs.corrective_change).to eq(false)
342
+
343
+ expect(report.corrective_change).to eq(false)
344
+ expect(get_cc_count(report)).to eq(0)
345
+ end
346
+
347
+ it "file with ensure property change file => absent" do
348
+ file = tmpfile("test_file")
349
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
350
+ :ensure => :file),
351
+ Puppet::Type.type(:file).new(:title => file,
352
+ :ensure => :absent))
353
+
354
+ expect(report.status).to eq("changed")
355
+
356
+ rs = report.resource_statuses["File[#{file}]"]
357
+ expect(rs.events.size).to eq(1)
358
+ expect(rs.events[0].corrective_change).to eq(false)
359
+ expect(rs.corrective_change).to eq(false)
360
+
361
+ expect(report.corrective_change).to eq(false)
362
+ expect(get_cc_count(report)).to eq(0)
363
+ end
364
+
365
+ it "file with ensure property change present => absent" do
366
+ file = tmpfile("test_file")
367
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
368
+ :ensure => :present),
369
+ Puppet::Type.type(:file).new(:title => file,
370
+ :ensure => :absent))
371
+
372
+ expect(report.status).to eq("changed")
373
+
374
+ rs = report.resource_statuses["File[#{file}]"]
375
+ expect(rs.events.size).to eq(1)
376
+ expect(rs.events[0].corrective_change).to eq(false)
377
+ expect(rs.corrective_change).to eq(false)
378
+
379
+ expect(report.corrective_change).to eq(false)
380
+ expect(get_cc_count(report)).to eq(0)
381
+ end
382
+
383
+ it "link with ensure property change present => absent", :unless => Puppet.features.microsoft_windows? do
384
+ file = tmpfile("test_file")
385
+ FileUtils.symlink(file, tmpfile("test_link"))
386
+
387
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
388
+ :ensure => :present),
389
+ Puppet::Type.type(:file).new(:title => file,
390
+ :ensure => :absent))
391
+
392
+ expect(report.status).to eq("changed")
393
+
394
+ rs = report.resource_statuses["File[#{file}]"]
395
+ expect(rs.events.size).to eq(1)
396
+ expect(rs.events[0].corrective_change).to eq(false)
397
+ expect(rs.corrective_change).to eq(false)
398
+
399
+ expect(report.corrective_change).to eq(false)
400
+ expect(get_cc_count(report)).to eq(0)
401
+ end
402
+
403
+ it "file with ensure property change absent => present" do
404
+ file = tmpfile("test_file")
405
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
406
+ :ensure => :absent),
407
+ Puppet::Type.type(:file).new(:title => file,
408
+ :ensure => :present))
409
+
410
+ expect(report.status).to eq("changed")
411
+
412
+ rs = report.resource_statuses["File[#{file}]"]
413
+ expect(rs.events.size).to eq(1)
414
+ expect(rs.events[0].corrective_change).to eq(false)
415
+ expect(rs.corrective_change).to eq(false)
416
+
417
+ expect(report.corrective_change).to eq(false)
418
+ expect(get_cc_count(report)).to eq(0)
419
+ end
420
+
421
+ it "new resource in catalog" do
422
+ file = tmpfile("test_file")
423
+ report = run_catalogs([],
424
+ Puppet::Type.type(:file).new(:title => file,
425
+ :content => "mystuff asdf"))
426
+
427
+ expect(report.status).to eq("changed")
428
+
429
+ rs = report.resource_statuses["File[#{file}]"]
430
+ expect(rs.events.size).to eq(1)
431
+ expect(rs.events[0].corrective_change).to eq(false)
432
+ expect(rs.corrective_change).to eq(false)
433
+
434
+ expect(report.corrective_change).to eq(false)
435
+ expect(get_cc_count(report)).to eq(0)
436
+ end
437
+
438
+ it "exec with idempotence issue", :unless => Puppet.features.microsoft_windows? do
439
+ report = run_catalogs(Puppet::Type.type(:exec).new(:title => "exec1",
440
+ :command => "/bin/echo foo"),
441
+ Puppet::Type.type(:exec).new(:title => "exec1",
442
+ :command => "/bin/echo foo"))
443
+
444
+ expect(report.status).to eq("changed")
445
+
446
+ # Of note here, is that the main idempotence issues lives in 'returns'
447
+ rs = report.resource_statuses["Exec[exec1]"]
448
+ expect(rs.events.size).to eq(1)
449
+ expect(rs.events[0].corrective_change).to eq(true)
450
+ expect(rs.corrective_change).to eq(true)
451
+
452
+ expect(report.corrective_change).to eq(true)
453
+ expect(get_cc_count(report)).to eq(1)
454
+ end
455
+
456
+ it "exec with no idempotence issue", :unless => Puppet.features.microsoft_windows? do
457
+ report = run_catalogs(Puppet::Type.type(:exec).new(:title => "exec1",
458
+ :command => "echo foo",
459
+ :path => "/bin",
460
+ :unless => "ls"),
461
+ Puppet::Type.type(:exec).new(:title => "exec1",
462
+ :command => "echo foo",
463
+ :path => "/bin",
464
+ :unless => "ls"))
465
+
466
+ expect(report.status).to eq("unchanged")
467
+
468
+ # Of note here, is that the main idempotence issues lives in 'returns'
469
+ rs = report.resource_statuses["Exec[exec1]"]
470
+ expect(rs.events.size).to eq(0)
471
+ expect(rs.corrective_change).to eq(false)
472
+
473
+ expect(report.corrective_change).to eq(false)
474
+ expect(get_cc_count(report)).to eq(0)
475
+ end
476
+
477
+ it "noop on second run, file with no catalog change, but file changed between runs" do
478
+ file = tmpfile("test_file")
479
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
480
+ :content => "mystuff"),
481
+ Puppet::Type.type(:file).new(:title => file,
482
+ :content => "mystuff"),
483
+ false, true) do
484
+ File.open(file, 'w') do |f|
485
+ f.puts "some content"
486
+ end
487
+ end
488
+
489
+ expect(report.status).to eq("unchanged")
490
+
491
+ rs = report.resource_statuses["File[#{file}]"]
492
+ expect(rs.events[0].corrective_change).to eq(true)
493
+ expect(rs.events.size).to eq(1)
494
+ expect(rs.corrective_change).to eq(true)
495
+
496
+ expect(report.corrective_change).to eq(true)
497
+ expect(get_cc_count(report)).to eq(1)
498
+ end
499
+
500
+ it "noop on all subsequent runs, file with no catalog change, but file changed between run 1 and 2" do
501
+ file = tmpfile("test_file")
502
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
503
+ :content => "mystuff"),
504
+ Puppet::Type.type(:file).new(:title => file,
505
+ :content => "mystuff"),
506
+ false, true) do
507
+ File.open(file, 'w') do |f|
508
+ f.puts "some content"
509
+ end
510
+ end
511
+
512
+ expect(report.status).to eq("unchanged")
513
+
514
+ rs = report.resource_statuses["File[#{file}]"]
515
+ expect(rs.events[0].corrective_change).to eq(true)
516
+ expect(rs.events.size).to eq(1)
517
+ expect(rs.corrective_change).to eq(true)
518
+
519
+ expect(report.corrective_change).to eq(true)
520
+ expect(get_cc_count(report)).to eq(1)
521
+
522
+ # Simply run the catalog twice again, but this time both runs are noop to
523
+ # test if the corrective field is still set.
524
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
525
+ :content => "mystuff"),
526
+ Puppet::Type.type(:file).new(:title => file,
527
+ :content => "mystuff"),
528
+ true, true)
529
+
530
+ expect(report.status).to eq("unchanged")
531
+
532
+ rs = report.resource_statuses["File[#{file}]"]
533
+ expect(rs.events[0].corrective_change).to eq(true)
534
+ expect(rs.events.size).to eq(1)
535
+ expect(rs.corrective_change).to eq(true)
536
+
537
+ expect(report.corrective_change).to eq(true)
538
+ expect(get_cc_count(report)).to eq(1)
539
+ end
540
+
541
+ it "noop on first run, file with no catalog change, but file changed between runs" do
542
+ file = tmpfile("test_file")
543
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
544
+ :content => "mystuff"),
545
+ Puppet::Type.type(:file).new(:title => file,
546
+ :content => "mystuff"),
547
+ true, false) do
548
+ File.open(file, 'w') do |f|
549
+ f.puts "some content"
550
+ end
551
+ end
552
+
553
+ expect(report.status).to eq("changed")
554
+
555
+ rs = report.resource_statuses["File[#{file}]"]
556
+ expect(rs.events[0].corrective_change).to eq(true)
557
+ expect(rs.events.size).to eq(1)
558
+ expect(rs.corrective_change).to eq(true)
559
+
560
+ expect(report.corrective_change).to eq(true)
561
+ expect(get_cc_count(report)).to eq(1)
562
+ end
563
+
564
+ it "noop on both runs, file with no catalog change, but file changed between runs" do
565
+ file = tmpfile("test_file")
566
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
567
+ :content => "mystuff"),
568
+ Puppet::Type.type(:file).new(:title => file,
569
+ :content => "mystuff"),
570
+ true, true) do
571
+ File.open(file, 'w') do |f|
572
+ f.puts "some content"
573
+ end
574
+ end
575
+
576
+ expect(report.status).to eq("unchanged")
577
+
578
+ rs = report.resource_statuses["File[#{file}]"]
579
+ expect(rs.events.size).to eq(1)
580
+ expect(rs.events[0].corrective_change).to eq(true)
581
+ expect(rs.corrective_change).to eq(true)
582
+
583
+ expect(report.corrective_change).to eq(true)
584
+ expect(get_cc_count(report)).to eq(1)
585
+ end
586
+
587
+ it "noop on 4 runs, file with no catalog change, but file changed between runs 1 and 2" do
588
+ file = tmpfile("test_file")
589
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
590
+ :content => "mystuff"),
591
+ Puppet::Type.type(:file).new(:title => file,
592
+ :content => "mystuff"),
593
+ true, true) do
594
+ File.open(file, 'w') do |f|
595
+ f.puts "some content"
596
+ end
597
+ end
598
+
599
+ expect(report.status).to eq("unchanged")
600
+
601
+ rs = report.resource_statuses["File[#{file}]"]
602
+ expect(rs.events.size).to eq(1)
603
+ expect(rs.events[0].corrective_change).to eq(true)
604
+ expect(rs.corrective_change).to eq(true)
605
+
606
+ expect(report.corrective_change).to eq(true)
607
+ expect(get_cc_count(report)).to eq(1)
608
+
609
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
610
+ :content => "mystuff"),
611
+ Puppet::Type.type(:file).new(:title => file,
612
+ :content => "mystuff"),
613
+ true, true)
614
+
615
+ expect(report.status).to eq("unchanged")
616
+
617
+ rs = report.resource_statuses["File[#{file}]"]
618
+ expect(rs.events.size).to eq(1)
619
+ expect(rs.events[0].corrective_change).to eq(true)
620
+ expect(rs.corrective_change).to eq(true)
621
+
622
+ expect(report.corrective_change).to eq(true)
623
+ expect(get_cc_count(report)).to eq(1)
624
+ end
625
+
626
+ it "noop on both runs, file already exists but with catalog change each time" do
627
+ file = tmpfile("test_file")
628
+
629
+ File.open(file, 'w') do |f|
630
+ f.puts "some content"
631
+ end
632
+
633
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
634
+ :content => "a"),
635
+ Puppet::Type.type(:file).new(:title => file,
636
+ :content => "b"),
637
+ true, true)
638
+
639
+ expect(report.status).to eq("unchanged")
640
+
641
+ rs = report.resource_statuses["File[#{file}]"]
642
+ expect(rs.events.size).to eq(1)
643
+ expect(rs.events[0].corrective_change).to eq(false)
644
+ expect(rs.corrective_change).to eq(false)
645
+
646
+ expect(report.corrective_change).to eq(false)
647
+ expect(get_cc_count(report)).to eq(0)
648
+ end
649
+
650
+ it "file failure should not return corrective_change" do
651
+ # Making the path a child path (with no parent) forces a failure
652
+ file = tmpfile("test_file") + "/foo"
653
+ report = run_catalogs(Puppet::Type.type(:file).new(:title => file,
654
+ :content => "a"),
655
+ Puppet::Type.type(:file).new(:title => file,
656
+ :content => "b"),
657
+ false, false)
658
+
659
+ expect(report.status).to eq("failed")
660
+
661
+ rs = report.resource_statuses["File[#{file}]"]
662
+ expect(rs.events.size).to eq(1)
663
+ expect(rs.events[0].corrective_change).to eq(false)
664
+ expect(rs.corrective_change).to eq(false)
665
+
666
+ expect(report.corrective_change).to eq(false)
667
+ expect(get_cc_count(report)).to eq(0)
668
+ end
669
+
670
+ it "file skipped with file change between runs will not show corrective_change" do
671
+ # Making the path a child path (with no parent) forces a failure
672
+ file = tmpfile("test_file") + "/foo"
673
+
674
+ resources1 = [
675
+ Puppet::Type.type(:file).new(:title => file,
676
+ :content => "a",
677
+ :notify => "Notify['foo']"),
678
+ Puppet::Type.type(:notify).new(:title => "foo")
679
+ ]
680
+ resources2 = [
681
+ Puppet::Type.type(:file).new(:title => file,
682
+ :content => "a",
683
+ :notify => "Notify[foo]"),
684
+ Puppet::Type.type(:notify).new(:title => "foo",
685
+ :message => "foo")
686
+ ]
687
+
688
+ report = run_catalogs(resources1, resources2, false, false)
689
+
690
+ expect(report.status).to eq("failed")
691
+
692
+ rs = report.resource_statuses["File[#{file}]"]
693
+ expect(rs.events.size).to eq(1)
694
+ expect(rs.events[0].corrective_change).to eq(false)
695
+ expect(rs.corrective_change).to eq(false)
696
+
697
+ rs = report.resource_statuses["Notify[foo]"]
698
+ expect(rs.events.size).to eq(0)
699
+ expect(rs.corrective_change).to eq(false)
700
+
701
+ expect(report.corrective_change).to eq(false)
702
+ expect(get_cc_count(report)).to eq(0)
703
+ end
704
+ end
705
+ end
40
706
  end