puppet 5.3.7-universal-darwin → 5.4.0-universal-darwin

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 (454) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +42 -29
  3. data/README.md +8 -6
  4. data/ext/cert_inspector +2 -2
  5. data/ext/envpuppet +1 -1
  6. data/ext/gentoo/init.d/puppetmaster +4 -4
  7. data/ext/ips/puppet-agent +11 -11
  8. data/ext/ips/puppet-master +11 -11
  9. data/ext/puppet-test +1 -2
  10. data/ext/redhat/client.init +2 -2
  11. data/ext/redhat/logrotate +1 -1
  12. data/ext/solaris/smf/puppet +11 -11
  13. data/ext/solaris/smf/svc-puppetd +5 -5
  14. data/ext/solaris/smf/svc-puppetmasterd +5 -5
  15. data/ext/windows/service/daemon.rb +1 -1
  16. data/install.rb +2 -3
  17. data/lib/puppet/agent.rb +1 -1
  18. data/lib/puppet/application/cert.rb +1 -3
  19. data/lib/puppet/application/describe.rb +0 -1
  20. data/lib/puppet/application/device.rb +12 -99
  21. data/lib/puppet/application/filebucket.rb +32 -11
  22. data/lib/puppet/application/lookup.rb +1 -11
  23. data/lib/puppet/application/script.rb +261 -0
  24. data/lib/puppet/configurer.rb +3 -4
  25. data/lib/puppet/configurer/plugin_handler.rb +26 -9
  26. data/lib/puppet/context.rb +1 -1
  27. data/lib/puppet/datatypes.rb +213 -0
  28. data/lib/puppet/datatypes/error.rb +21 -0
  29. data/lib/puppet/datatypes/impl/error.rb +40 -0
  30. data/lib/puppet/defaults.rb +51 -20
  31. data/lib/puppet/environments.rb +17 -0
  32. data/lib/puppet/error.rb +17 -0
  33. data/lib/puppet/etc.rb +2 -2
  34. data/lib/puppet/external/pson/pure/generator.rb +1 -1
  35. data/lib/puppet/external/pson/pure/parser.rb +1 -1
  36. data/lib/puppet/face/config.rb +45 -0
  37. data/lib/puppet/face/epp.rb +3 -3
  38. data/lib/puppet/face/help/action.erb +3 -0
  39. data/lib/puppet/face/module/build.rb +1 -0
  40. data/lib/puppet/face/module/generate.rb +5 -0
  41. data/lib/puppet/face/module/install.rb +1 -0
  42. data/lib/puppet/face/module/search.rb +6 -2
  43. data/lib/puppet/face/module/uninstall.rb +1 -0
  44. data/lib/puppet/face/module/upgrade.rb +1 -0
  45. data/lib/puppet/face/parser.rb +0 -1
  46. data/lib/puppet/face/plugin.rb +1 -3
  47. data/lib/puppet/feature/base.rb +1 -1
  48. data/lib/puppet/feature/bolt.rb +3 -0
  49. data/lib/puppet/file_bucket/dipper.rb +1 -2
  50. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  51. data/lib/puppet/file_system/uniquefile.rb +2 -2
  52. data/lib/puppet/forge.rb +6 -0
  53. data/lib/puppet/functions.rb +70 -88
  54. data/lib/puppet/functions/all.rb +6 -2
  55. data/lib/puppet/functions/annotate.rb +1 -1
  56. data/lib/puppet/functions/any.rb +7 -3
  57. data/lib/puppet/functions/contain.rb +6 -0
  58. data/lib/puppet/functions/convert_to.rb +32 -0
  59. data/lib/puppet/functions/defined.rb +0 -3
  60. data/lib/puppet/functions/each.rb +10 -6
  61. data/lib/puppet/functions/filter.rb +16 -10
  62. data/lib/puppet/functions/find_file.rb +0 -1
  63. data/lib/puppet/functions/include.rb +6 -0
  64. data/lib/puppet/functions/map.rb +12 -9
  65. data/lib/puppet/functions/module_directory.rb +41 -0
  66. data/lib/puppet/functions/new.rb +1 -4
  67. data/lib/puppet/functions/regsubst.rb +1 -1
  68. data/lib/puppet/functions/require.rb +6 -0
  69. data/lib/puppet/generate/type.rb +1 -1
  70. data/lib/puppet/gettext/config.rb +2 -2
  71. data/lib/puppet/gettext/stubs.rb +1 -1
  72. data/lib/puppet/indirector/catalog/compiler.rb +0 -1
  73. data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
  74. data/lib/puppet/indirector/file_server.rb +1 -1
  75. data/lib/puppet/indirector/node/ldap.rb +19 -3
  76. data/lib/puppet/indirector/request.rb +10 -6
  77. data/lib/puppet/indirector/rest.rb +11 -12
  78. data/lib/puppet/info_service/class_information_service.rb +1 -1
  79. data/lib/puppet/interface/action.rb +11 -0
  80. data/lib/puppet/interface/action_builder.rb +8 -0
  81. data/lib/puppet/interface/option_manager.rb +1 -1
  82. data/lib/puppet/loaders.rb +2 -0
  83. data/lib/puppet/module.rb +6 -2
  84. data/lib/puppet/module_tool/applications/builder.rb +4 -0
  85. data/lib/puppet/module_tool/applications/installer.rb +3 -0
  86. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
  87. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  88. data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
  89. data/lib/puppet/module_tool/installed_modules.rb +1 -1
  90. data/lib/puppet/module_tool/metadata.rb +0 -1
  91. data/lib/puppet/network/authstore.rb +1 -1
  92. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  93. data/lib/puppet/network/http/connection.rb +1 -9
  94. data/lib/puppet/network/http/factory.rb +0 -3
  95. data/lib/puppet/network/http/webrick.rb +1 -0
  96. data/lib/puppet/network/rights.rb +1 -1
  97. data/lib/puppet/node.rb +53 -0
  98. data/lib/puppet/node/environment.rb +1 -1
  99. data/lib/puppet/parameter/boolean.rb +1 -1
  100. data/lib/puppet/parser.rb +1 -0
  101. data/lib/puppet/parser/abstract_compiler.rb +36 -0
  102. data/lib/puppet/parser/ast/branch.rb +1 -1
  103. data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
  104. data/lib/puppet/parser/compiler.rb +4 -54
  105. data/lib/puppet/parser/functions.rb +0 -1
  106. data/lib/puppet/parser/functions/create_resources.rb +6 -0
  107. data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
  108. data/lib/puppet/parser/functions/inline_template.rb +6 -0
  109. data/lib/puppet/parser/functions/new.rb +47 -32
  110. data/lib/puppet/parser/functions/realize.rb +6 -0
  111. data/lib/puppet/parser/functions/return.rb +1 -22
  112. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  113. data/lib/puppet/parser/functions/scanf.rb +1 -1
  114. data/lib/puppet/parser/functions/sha256.rb +5 -0
  115. data/lib/puppet/parser/functions/tag.rb +6 -0
  116. data/lib/puppet/parser/functions/tagged.rb +6 -0
  117. data/lib/puppet/parser/functions/template.rb +5 -0
  118. data/lib/puppet/parser/scope.rb +28 -4
  119. data/lib/puppet/parser/script_compiler.rb +118 -0
  120. data/lib/puppet/parser/type_loader.rb +1 -1
  121. data/lib/puppet/pops.rb +1 -1
  122. data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
  123. data/lib/puppet/pops/evaluator/closure.rb +12 -4
  124. data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
  125. data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
  126. data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
  127. data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
  128. data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
  129. data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
  130. data/lib/puppet/pops/functions/dispatch.rb +6 -5
  131. data/lib/puppet/pops/functions/function.rb +2 -2
  132. data/lib/puppet/pops/issues.rb +34 -2
  133. data/lib/puppet/pops/loader/base_loader.rb +10 -0
  134. data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
  135. data/lib/puppet/pops/loader/loader.rb +21 -2
  136. data/lib/puppet/pops/loader/loader_paths.rb +180 -30
  137. data/lib/puppet/pops/loader/module_loaders.rb +202 -33
  138. data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
  139. data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
  140. data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
  141. data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
  142. data/lib/puppet/pops/loader/static_loader.rb +23 -8
  143. data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
  144. data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
  145. data/lib/puppet/pops/loaders.rb +122 -11
  146. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  147. data/lib/puppet/pops/lookup/interpolation.rb +1 -1
  148. data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
  149. data/lib/puppet/pops/model/ast.pp +3 -0
  150. data/lib/puppet/pops/model/ast.rb +34 -1
  151. data/lib/puppet/pops/model/factory.rb +30 -3
  152. data/lib/puppet/pops/model/model_label_provider.rb +1 -0
  153. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
  154. data/lib/puppet/pops/model/tree_dumper.rb +1 -1
  155. data/lib/puppet/pops/parser/code_merger.rb +2 -2
  156. data/lib/puppet/pops/parser/egrammar.ra +44 -15
  157. data/lib/puppet/pops/parser/eparser.rb +1687 -1571
  158. data/lib/puppet/pops/parser/epp_support.rb +1 -3
  159. data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  160. data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
  161. data/lib/puppet/pops/parser/lexer2.rb +4 -4
  162. data/lib/puppet/pops/parser/lexer_support.rb +2 -2
  163. data/lib/puppet/pops/parser/locatable.rb +1 -1
  164. data/lib/puppet/pops/parser/locator.rb +7 -13
  165. data/lib/puppet/pops/parser/parser_support.rb +3 -3
  166. data/lib/puppet/pops/parser/slurp_support.rb +0 -3
  167. data/lib/puppet/pops/pcore.rb +45 -0
  168. data/lib/puppet/pops/resource/param.rb +1 -1
  169. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  170. data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
  171. data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
  172. data/lib/puppet/pops/serialization/extension.rb +1 -0
  173. data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
  174. data/lib/puppet/pops/serialization/json_path.rb +2 -1
  175. data/lib/puppet/pops/serialization/object.rb +3 -4
  176. data/lib/puppet/pops/serialization/serializer.rb +2 -1
  177. data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
  178. data/lib/puppet/pops/time/timespan.rb +1 -1
  179. data/lib/puppet/pops/types/iterable.rb +38 -9
  180. data/lib/puppet/pops/types/p_init_type.rb +1 -1
  181. data/lib/puppet/pops/types/p_meta_type.rb +4 -0
  182. data/lib/puppet/pops/types/p_object_type.rb +146 -14
  183. data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
  184. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
  185. data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
  186. data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
  187. data/lib/puppet/pops/types/p_uri_type.rb +190 -0
  188. data/lib/puppet/pops/types/puppet_object.rb +15 -1
  189. data/lib/puppet/pops/types/ruby_generator.rb +46 -54
  190. data/lib/puppet/pops/types/string_converter.rb +22 -1
  191. data/lib/puppet/pops/types/type_acceptor.rb +1 -1
  192. data/lib/puppet/pops/types/type_calculator.rb +13 -4
  193. data/lib/puppet/pops/types/type_factory.rb +29 -5
  194. data/lib/puppet/pops/types/type_formatter.rb +67 -4
  195. data/lib/puppet/pops/types/type_parser.rb +92 -4
  196. data/lib/puppet/pops/types/type_with_members.rb +43 -0
  197. data/lib/puppet/pops/types/types.rb +212 -80
  198. data/lib/puppet/pops/validation/checker4_0.rb +10 -6
  199. data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
  200. data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
  201. data/lib/puppet/property.rb +1 -1
  202. data/lib/puppet/provider.rb +18 -8
  203. data/lib/puppet/provider/augeas/augeas.rb +3 -4
  204. data/lib/puppet/provider/exec.rb +0 -2
  205. data/lib/puppet/provider/group/groupadd.rb +25 -1
  206. data/lib/puppet/provider/group/windows_adsi.rb +7 -4
  207. data/lib/puppet/provider/mount.rb +25 -8
  208. data/lib/puppet/provider/nameservice.rb +9 -4
  209. data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  210. data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
  211. data/lib/puppet/provider/nameservice/pw.rb +14 -14
  212. data/lib/puppet/provider/package/appdmg.rb +0 -1
  213. data/lib/puppet/provider/package/apple.rb +0 -1
  214. data/lib/puppet/provider/package/gem.rb +2 -2
  215. data/lib/puppet/provider/package/macports.rb +2 -2
  216. data/lib/puppet/provider/package/pkg.rb +3 -0
  217. data/lib/puppet/provider/package/pkgdmg.rb +0 -1
  218. data/lib/puppet/provider/package/portage.rb +0 -1
  219. data/lib/puppet/provider/package/yum.rb +23 -8
  220. data/lib/puppet/provider/package/zypper.rb +2 -2
  221. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  222. data/lib/puppet/provider/service/init.rb +1 -0
  223. data/lib/puppet/provider/service/launchd.rb +6 -7
  224. data/lib/puppet/provider/service/redhat.rb +3 -2
  225. data/lib/puppet/provider/service/systemd.rb +2 -2
  226. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  227. data/lib/puppet/provider/user/aix.rb +3 -2
  228. data/lib/puppet/provider/user/openbsd.rb +1 -1
  229. data/lib/puppet/provider/user/pw.rb +1 -1
  230. data/lib/puppet/provider/user/user_role_add.rb +7 -1
  231. data/lib/puppet/provider/user/useradd.rb +36 -6
  232. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  233. data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
  234. data/lib/puppet/provider/zfs/zfs.rb +23 -3
  235. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  236. data/lib/puppet/reference/configuration.rb +0 -2
  237. data/lib/puppet/reference/type.rb +0 -1
  238. data/lib/puppet/resource.rb +1 -2
  239. data/lib/puppet/resource/catalog.rb +1 -1
  240. data/lib/puppet/resource/status.rb +0 -1
  241. data/lib/puppet/resource/type.rb +4 -4
  242. data/lib/puppet/resource/type_collection.rb +1 -1
  243. data/lib/puppet/settings/base_setting.rb +1 -1
  244. data/lib/puppet/settings/environment_conf.rb +0 -1
  245. data/lib/puppet/settings/ini_file.rb +66 -12
  246. data/lib/puppet/ssl/certificate_authority.rb +1 -1
  247. data/lib/puppet/ssl/certificate_request.rb +2 -2
  248. data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
  249. data/lib/puppet/ssl/certificate_signer.rb +11 -0
  250. data/lib/puppet/ssl/host.rb +2 -2
  251. data/lib/puppet/syntax_checkers/base64.rb +1 -1
  252. data/lib/puppet/transaction.rb +37 -14
  253. data/lib/puppet/transaction/report.rb +3 -1
  254. data/lib/puppet/type.rb +17 -4
  255. data/lib/puppet/type/cron.rb +1 -1
  256. data/lib/puppet/type/exec.rb +5 -4
  257. data/lib/puppet/type/file.rb +3 -3
  258. data/lib/puppet/type/file/checksum.rb +7 -1
  259. data/lib/puppet/type/file/checksum_value.rb +4 -3
  260. data/lib/puppet/type/group.rb +3 -0
  261. data/lib/puppet/type/k5login.rb +101 -0
  262. data/lib/puppet/type/macauthorization.rb +1 -1
  263. data/lib/puppet/type/mount.rb +6 -2
  264. data/lib/puppet/type/tidy.rb +6 -4
  265. data/lib/puppet/type/user.rb +26 -39
  266. data/lib/puppet/type/yumrepo.rb +9 -0
  267. data/lib/puppet/type/zfs.rb +4 -0
  268. data/lib/puppet/util.rb +8 -15
  269. data/lib/puppet/util/character_encoding.rb +2 -2
  270. data/lib/puppet/util/checksums.rb +82 -1
  271. data/lib/puppet/util/errors.rb +0 -2
  272. data/lib/puppet/util/filetype.rb +2 -2
  273. data/lib/puppet/util/json_lockfile.rb +1 -1
  274. data/lib/puppet/util/log.rb +1 -1
  275. data/lib/puppet/util/log/destinations.rb +10 -1
  276. data/lib/puppet/util/monkey_patches.rb +1 -1
  277. data/lib/puppet/util/network_device/cisco/device.rb +5 -5
  278. data/lib/puppet/util/network_device/config.rb +2 -3
  279. data/lib/puppet/util/platform.rb +13 -0
  280. data/lib/puppet/util/plist.rb +4 -4
  281. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
  282. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  283. data/lib/puppet/util/reference.rb +8 -1
  284. data/lib/puppet/util/windows/adsi.rb +18 -15
  285. data/lib/puppet/util/windows/principal.rb +6 -7
  286. data/lib/puppet/util/windows/process.rb +1 -1
  287. data/lib/puppet/util/windows/registry.rb +2 -2
  288. data/lib/puppet/util/windows/sid.rb +7 -62
  289. data/lib/puppet/vendor/deep_merge/README.md +2 -2
  290. data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
  291. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
  292. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
  293. data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
  294. data/lib/puppet/version.rb +1 -1
  295. data/lib/puppet_pal.rb +874 -0
  296. data/locales/ja/puppet.po +140 -163
  297. data/locales/puppet.pot +940 -597
  298. data/man/man5/puppet.conf.5 +16 -91
  299. data/man/man8/puppet-agent.8 +2 -6
  300. data/man/man8/puppet-apply.8 +2 -2
  301. data/man/man8/puppet-ca.8 +1 -1
  302. data/man/man8/puppet-catalog.8 +1 -1
  303. data/man/man8/puppet-cert.8 +1 -1
  304. data/man/man8/puppet-certificate.8 +1 -1
  305. data/man/man8/puppet-certificate_request.8 +1 -1
  306. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  307. data/man/man8/puppet-config.8 +1 -1
  308. data/man/man8/puppet-describe.8 +1 -1
  309. data/man/man8/puppet-device.8 +11 -33
  310. data/man/man8/puppet-doc.8 +1 -1
  311. data/man/man8/puppet-epp.8 +1 -1
  312. data/man/man8/puppet-facts.8 +1 -1
  313. data/man/man8/puppet-filebucket.8 +4 -22
  314. data/man/man8/puppet-generate.8 +1 -1
  315. data/man/man8/puppet-help.8 +1 -1
  316. data/man/man8/puppet-key.8 +1 -1
  317. data/man/man8/puppet-lookup.8 +1 -1
  318. data/man/man8/puppet-man.8 +1 -1
  319. data/man/man8/puppet-master.8 +1 -1
  320. data/man/man8/puppet-module.8 +2 -11
  321. data/man/man8/puppet-node.8 +1 -1
  322. data/man/man8/puppet-parser.8 +1 -1
  323. data/man/man8/puppet-plugin.8 +1 -1
  324. data/man/man8/puppet-report.8 +1 -1
  325. data/man/man8/puppet-resource.8 +1 -1
  326. data/man/man8/puppet-status.8 +1 -1
  327. data/man/man8/puppet.8 +2 -2
  328. data/spec/integration/application/lookup_spec.rb +0 -21
  329. data/spec/integration/parser/compiler_spec.rb +18 -0
  330. data/spec/integration/parser/script_compiler_spec.rb +113 -0
  331. data/spec/integration/provider/mount_spec.rb +2 -0
  332. data/spec/integration/type/file_spec.rb +11 -3
  333. data/spec/integration/util/windows/adsi_spec.rb +1 -86
  334. data/spec/integration/util/windows/principal_spec.rb +1 -10
  335. data/spec/shared_contexts/checksum.rb +4 -1
  336. data/spec/shared_contexts/digests.rb +46 -1
  337. data/spec/shared_contexts/types_setup.rb +8 -3
  338. data/spec/unit/agent_spec.rb +2 -2
  339. data/spec/unit/application/cert_spec.rb +5 -17
  340. data/spec/unit/application/device_spec.rb +2 -96
  341. data/spec/unit/application/filebucket_spec.rb +18 -4
  342. data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
  343. data/spec/unit/configurer_spec.rb +3 -3
  344. data/spec/unit/datatypes_spec.rb +304 -0
  345. data/spec/unit/defaults_spec.rb +41 -20
  346. data/spec/unit/face/config_spec.rb +46 -1
  347. data/spec/unit/face/epp_face_spec.rb +7 -3
  348. data/spec/unit/face/module/search_spec.rb +11 -0
  349. data/spec/unit/face/parser_spec.rb +2 -2
  350. data/spec/unit/file_bucket/dipper_spec.rb +12 -1
  351. data/spec/unit/forge/module_release_spec.rb +70 -0
  352. data/spec/unit/functions/break_spec.rb +34 -2
  353. data/spec/unit/functions/contain_spec.rb +1 -0
  354. data/spec/unit/functions/convert_to_spec.rb +22 -0
  355. data/spec/unit/functions/epp_spec.rb +5 -0
  356. data/spec/unit/functions/include_spec.rb +15 -0
  357. data/spec/unit/functions/module_directory_spec.rb +43 -0
  358. data/spec/unit/functions/new_spec.rb +14 -14
  359. data/spec/unit/functions/require_spec.rb +2 -0
  360. data/spec/unit/functions/shared.rb +12 -0
  361. data/spec/unit/functions/step_spec.rb +1 -1
  362. data/spec/unit/functions4_spec.rb +49 -4
  363. data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
  364. data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
  365. data/spec/unit/indirector/node/ldap_spec.rb +15 -12
  366. data/spec/unit/indirector/rest_spec.rb +0 -43
  367. data/spec/unit/interface/action_spec.rb +33 -0
  368. data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
  369. data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
  370. data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
  371. data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
  372. data/spec/unit/network/http/connection_spec.rb +1 -1
  373. data/spec/unit/network/http/factory_spec.rb +28 -35
  374. data/spec/unit/parser/compiler_spec.rb +0 -8
  375. data/spec/unit/parser/environment_compiler_spec.rb +36 -0
  376. data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
  377. data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
  378. data/spec/unit/parser/functions/realize_spec.rb +9 -0
  379. data/spec/unit/parser/functions/tag_spec.rb +7 -0
  380. data/spec/unit/parser/functions/tagged_spec.rb +25 -0
  381. data/spec/unit/parser/functions/template_spec.rb +8 -0
  382. data/spec/unit/parser/scope_spec.rb +19 -0
  383. data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
  384. data/spec/unit/pops/loaders/loader_spec.rb +516 -0
  385. data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
  386. data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
  387. data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
  388. data/spec/unit/pops/model/model_spec.rb +5 -0
  389. data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
  390. data/spec/unit/pops/parser/locator_spec.rb +20 -0
  391. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
  392. data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
  393. data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
  394. data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
  395. data/spec/unit/pops/serialization/packer_spec.rb +8 -0
  396. data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
  397. data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
  398. data/spec/unit/pops/types/error_spec.rb +207 -0
  399. data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
  400. data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
  401. data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
  402. data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
  403. data/spec/unit/pops/types/task_spec.rb +353 -0
  404. data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
  405. data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
  406. data/spec/unit/pops/types/type_parser_spec.rb +13 -1
  407. data/spec/unit/pops/types/types_spec.rb +60 -0
  408. data/spec/unit/pops/validator/validator_spec.rb +76 -0
  409. data/spec/unit/provider/group/groupadd_spec.rb +77 -1
  410. data/spec/unit/provider/group/pw_spec.rb +4 -4
  411. data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
  412. data/spec/unit/provider/mount_spec.rb +18 -5
  413. data/spec/unit/provider/nameservice_spec.rb +5 -5
  414. data/spec/unit/provider/package/dnf_spec.rb +2 -2
  415. data/spec/unit/provider/package/gem_spec.rb +1 -1
  416. data/spec/unit/provider/package/pkg_spec.rb +3 -0
  417. data/spec/unit/provider/package/yum_spec.rb +40 -0
  418. data/spec/unit/provider/service/launchd_spec.rb +2 -1
  419. data/spec/unit/provider/service/redhat_spec.rb +5 -0
  420. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  421. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  422. data/spec/unit/provider/user/openbsd_spec.rb +2 -2
  423. data/spec/unit/provider/user/pw_spec.rb +14 -14
  424. data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
  425. data/spec/unit/provider/user/useradd_spec.rb +188 -22
  426. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  427. data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
  428. data/spec/unit/provider_spec.rb +48 -0
  429. data/spec/unit/puppet_pal_2pec.rb +1005 -0
  430. data/spec/unit/puppet_pal_spec.rb +11 -0
  431. data/spec/unit/settings/ini_file_spec.rb +313 -2
  432. data/spec/unit/ssl/certificate_request_spec.rb +42 -1
  433. data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
  434. data/spec/unit/transaction/report_spec.rb +1 -0
  435. data/spec/unit/transaction_spec.rb +112 -21
  436. data/spec/unit/type/file/checksum_spec.rb +20 -0
  437. data/spec/unit/type/file_spec.rb +8 -0
  438. data/spec/unit/type/group_spec.rb +8 -0
  439. data/spec/unit/type/k5login_spec.rb +22 -1
  440. data/spec/unit/type/scheduled_task_spec.rb +15 -0
  441. data/spec/unit/type/user_spec.rb +11 -1
  442. data/spec/unit/type/yumrepo_spec.rb +5 -0
  443. data/spec/unit/util/checksums_spec.rb +3 -3
  444. data/spec/unit/util/log/destinations_spec.rb +14 -0
  445. data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
  446. data/spec/unit/util/plist_spec.rb +3 -3
  447. data/spec/unit/util/windows/adsi_spec.rb +27 -31
  448. data/spec/unit/util/windows/sid_spec.rb +15 -86
  449. data/spec/unit/util_spec.rb +17 -3
  450. data/tasks/manpages.rake +1 -1
  451. metadata +218 -180
  452. data/lib/puppet/bindings.rb +0 -148
  453. data/lib/puppet/configurer/downloader_factory.rb +0 -44
  454. data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -0,0 +1,191 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+ require 'puppet_spec/compiler'
4
+
5
+ module Puppet::Pops
6
+ module Types
7
+ describe 'URI type' do
8
+ context 'when used in Puppet expressions' do
9
+ include PuppetSpec::Compiler
10
+ it 'is equal to itself only' do
11
+ expect(eval_and_collect_notices(<<-CODE)).to eq(%w(true true false false))
12
+ $t = URI
13
+ notice(URI =~ Type[URI])
14
+ notice(URI == URI)
15
+ notice(URI < URI)
16
+ notice(URI > URI)
17
+ CODE
18
+ end
19
+
20
+ context "when parameterized" do
21
+ it 'is equal other types with the same parameterization' do
22
+ code = <<-CODE
23
+ notice(URI == URI[{}])
24
+ notice(URI['http://example.com'] == URI[scheme => http, host => 'example.com'])
25
+ notice(URI['urn:a:b:c'] == URI[scheme => urn, opaque => 'a:b:c'])
26
+ CODE
27
+ expect(eval_and_collect_notices(code)).to eq(%w(true true true))
28
+ end
29
+
30
+ it 'is assignable from more qualified types' do
31
+ expect(eval_and_collect_notices(<<-CODE)).to eq(%w(true true true))
32
+ notice(URI > URI['http://example.com'])
33
+ notice(URI['http://example.com'] > URI['http://example.com/path'])
34
+ notice(URI[scheme => Enum[http, https]] > URI['http://example.com'])
35
+ CODE
36
+ end
37
+
38
+ it 'is not assignable unless scheme is assignable' do
39
+ expect(eval_and_collect_notices(<<-CODE)).to eq(%w(false))
40
+ notice(URI[scheme => Enum[http, https]] > URI[scheme => 'ftp'])
41
+ CODE
42
+ end
43
+
44
+ it 'presents parsable string form' do
45
+ code = <<-CODE
46
+ notice(URI['https://user:password@www.example.com:3000/some/path?x=y#frag'])
47
+ CODE
48
+ expect(eval_and_collect_notices(code)).to eq([
49
+ "URI[{'scheme' => 'https', 'userinfo' => 'user:password', 'host' => 'www.example.com', 'port' => '3000', 'path' => '/some/path', 'query' => 'x=y', 'fragment' => 'frag'}]",
50
+ ])
51
+ end
52
+ end
53
+
54
+ context 'a URI instance' do
55
+ it 'can be created from a string' do
56
+ code = <<-CODE
57
+ $o = URI('https://example.com/a/b')
58
+ notice(String($o, '%p'))
59
+ notice(type($o))
60
+ CODE
61
+ expect(eval_and_collect_notices(code)).to eq([
62
+ "URI('https://example.com/a/b')",
63
+ "URI[{'scheme' => 'https', 'host' => 'example.com', 'path' => '/a/b'}]"
64
+ ])
65
+ end
66
+
67
+ it 'which is opaque, can be created from a string' do
68
+ code = <<-CODE
69
+ $o = URI('urn:a:b:c')
70
+ notice(String($o, '%p'))
71
+ notice(type($o))
72
+ CODE
73
+ expect(eval_and_collect_notices(code)).to eq([
74
+ "URI('urn:a:b:c')",
75
+ "URI[{'scheme' => 'urn', 'opaque' => 'a:b:c'}]"
76
+ ])
77
+ end
78
+
79
+ it 'can be created from a hash' do
80
+ code = <<-CODE
81
+ $o = URI(scheme => 'https', host => 'example.com', path => '/a/b')
82
+ notice(String($o, '%p'))
83
+ notice(type($o))
84
+ CODE
85
+ expect(eval_and_collect_notices(code)).to eq([
86
+ "URI('https://example.com/a/b')",
87
+ "URI[{'scheme' => 'https', 'host' => 'example.com', 'path' => '/a/b'}]"
88
+ ])
89
+ end
90
+
91
+ it 'which is opaque, can be created from a hash' do
92
+ code = <<-CODE
93
+ $o = URI(scheme => 'urn', opaque => 'a:b:c')
94
+ notice(String($o, '%p'))
95
+ notice(type($o))
96
+ CODE
97
+ expect(eval_and_collect_notices(code)).to eq([
98
+ "URI('urn:a:b:c')",
99
+ "URI[{'scheme' => 'urn', 'opaque' => 'a:b:c'}]"
100
+ ])
101
+ end
102
+
103
+ it 'is an instance of its type' do
104
+ code = <<-CODE
105
+ $o = URI('https://example.com/a/b')
106
+ notice($o =~ type($o))
107
+ CODE
108
+ expect(eval_and_collect_notices(code)).to eq(['true'])
109
+ end
110
+
111
+ it 'is an instance of matching parameterized URI' do
112
+ code = <<-CODE
113
+ $o = URI('https://example.com/a/b')
114
+ notice($o =~ URI[scheme => https, host => 'example.com'])
115
+ CODE
116
+ expect(eval_and_collect_notices(code)).to eq(['true'])
117
+ end
118
+
119
+ it 'is an instance of matching default URI' do
120
+ code = <<-CODE
121
+ $o = URI('https://example.com/a/b')
122
+ notice($o =~ URI)
123
+ CODE
124
+ expect(eval_and_collect_notices(code)).to eq(['true'])
125
+ end
126
+
127
+ it 'path is not matched by opaque' do
128
+ code = <<-CODE
129
+ $o = URI('urn:a:b:c')
130
+ notice($o =~ URI[path => 'a:b:c'])
131
+ CODE
132
+ expect(eval_and_collect_notices(code)).to eq(['false'])
133
+ end
134
+
135
+ it 'opaque is not matched by path' do
136
+ code = <<-CODE
137
+ $o = URI('https://example.com/a/b')
138
+ notice($o =~ URI[opaque => '/a/b'])
139
+ CODE
140
+ expect(eval_and_collect_notices(code)).to eq(['false'])
141
+ end
142
+
143
+ it 'is not an instance unless parameters matches' do
144
+ code = <<-CODE
145
+ $o = URI('https://example.com/a/b')
146
+ notice($o =~ URI[scheme => http])
147
+ CODE
148
+ expect(eval_and_collect_notices(code)).to eq(['false'])
149
+ end
150
+
151
+ it 'individual parts of URI can be accessed using accessor methods' do
152
+ code = <<-CODE
153
+ $o = URI('https://bob:pw@example.com:8080/a/b?a=b#frag')
154
+ notice($o.scheme)
155
+ notice($o.userinfo)
156
+ notice($o.host)
157
+ notice($o.port)
158
+ notice($o.path)
159
+ notice($o.query)
160
+ notice($o.fragment)
161
+ CODE
162
+ expect(eval_and_collect_notices(code)).to eq(['https', 'bob:pw', 'example.com', '8080', '/a/b', 'a=b', 'frag'])
163
+ end
164
+
165
+ it 'individual parts of opaque URI can be accessed using accessor methods' do
166
+ code = <<-CODE
167
+ $o = URI('urn:a:b:c')
168
+ notice($o.scheme)
169
+ notice($o.opaque)
170
+ CODE
171
+ expect(eval_and_collect_notices(code)).to eq(['urn', 'a:b:c'])
172
+ end
173
+
174
+ it 'An URI can be merged with a String using the + operator' do
175
+ code = <<-CODE
176
+ notice(String(URI('https://example.com') + '/a/b', '%p'))
177
+ CODE
178
+ expect(eval_and_collect_notices(code)).to eq(["URI('https://example.com/a/b')"])
179
+ end
180
+
181
+ it 'An URI can be merged with another URI using the + operator' do
182
+ code = <<-CODE
183
+ notice(String(URI('https://example.com') + URI('/a/b'), '%p'))
184
+ CODE
185
+ expect(eval_and_collect_notices(code)).to eq(["URI('https://example.com/a/b')"])
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
@@ -208,53 +208,72 @@ describe 'Puppet Ruby Generator' do
208
208
  end
209
209
 
210
210
  context 'when generating from Object types' do
211
- def source
212
- <<-CODE
213
- type MyModule::FirstGenerated = Object[{
214
- attributes => {
215
- name => String,
216
- age => { type => Integer, value => 30 },
217
- what => { type => String, value => 'what is this', kind => constant },
218
- uc_name => {
219
- type => String,
220
- kind => derived,
221
- annotations => {
222
- RubyMethod => { body => '@name.upcase' }
211
+ let (:type_decls) { <<-CODE.unindent }
212
+ type MyModule::FirstGenerated = Object[{
213
+ attributes => {
214
+ name => String,
215
+ age => { type => Integer, value => 30 },
216
+ what => { type => String, value => 'what is this', kind => constant },
217
+ uc_name => {
218
+ type => String,
219
+ kind => derived,
220
+ annotations => {
221
+ RubyMethod => { body => '@name.upcase' }
222
+ }
223
+ },
224
+ other_name => {
225
+ type => String,
226
+ kind => derived
227
+ },
228
+ },
229
+ functions => {
230
+ some_other => {
231
+ type => Callable[1,1]
232
+ },
233
+ name_and_age => {
234
+ type => Callable[1,1],
235
+ annotations => {
236
+ RubyMethod => {
237
+ parameters => 'joiner',
238
+ body => '"\#{@name}\#{joiner}\#{@age}"'
223
239
  }
224
- },
225
- other_name => {
226
- type => String,
227
- kind => derived
228
240
  }
229
241
  },
230
- functions => {
231
- some_other => {
232
- type => Callable[1,1]
233
- },
234
- name_and_age => {
235
- type => Callable[1,1],
236
- annotations => {
237
- RubyMethod => {
238
- parameters => 'joiner',
239
- body => '"\#{@name}\#{joiner}\#{@age}"'
240
- }
242
+ '[]' => {
243
+ type => Callable[1,1],
244
+ annotations => {
245
+ RubyMethod => {
246
+ parameters => 'key',
247
+ body => @(EOF)
248
+ case key
249
+ when 'name'
250
+ name
251
+ when 'age'
252
+ age
253
+ else
254
+ nil
255
+ end
256
+ |-EOF
241
257
  }
242
- },
243
- }
244
- }]
245
- type MyModule::SecondGenerated = Object[{
246
- parent => MyModule::FirstGenerated,
247
- attributes => {
248
- address => String,
249
- zipcode => String,
250
- email => String,
251
- another => { type => Optional[MyModule::FirstGenerated], value => undef },
252
- number => Integer,
253
- aref => { type => Optional[MyModule::FirstGenerated], value => undef, kind => reference }
258
+ }
254
259
  }
255
- }]
260
+ }
261
+ }]
262
+ type MyModule::SecondGenerated = Object[{
263
+ parent => MyModule::FirstGenerated,
264
+ attributes => {
265
+ address => String,
266
+ zipcode => String,
267
+ email => String,
268
+ another => { type => Optional[MyModule::FirstGenerated], value => undef },
269
+ number => Integer,
270
+ aref => { type => Optional[MyModule::FirstGenerated], value => undef, kind => reference }
271
+ }
272
+ }]
256
273
  CODE
257
- end
274
+
275
+ let(:type_usage) { '' }
276
+ let(:source) { type_decls + type_usage }
258
277
 
259
278
  context 'when generating anonymous classes' do
260
279
 
@@ -264,11 +283,12 @@ describe 'Puppet Ruby Generator' do
264
283
  let(:second_type) { parser.parse('MyModule::SecondGenerated', loader) }
265
284
  let(:first) { generator.create_class(first_type) }
266
285
  let(:second) { generator.create_class(second_type) }
286
+ let(:notices) { [] }
267
287
 
268
288
  before(:each) do
269
- eval_and_collect_notices(source) do |topscope|
289
+ notices.concat(eval_and_collect_notices(source) do |topscope|
270
290
  loader = topscope.compiler.loaders.find_loader(nil)
271
- end
291
+ end)
272
292
  end
273
293
 
274
294
  after(:each) { typeset = nil }
@@ -296,6 +316,12 @@ describe 'Puppet Ruby Generator' do
296
316
  expect(inst.age).to eq(52)
297
317
  end
298
318
 
319
+ it 'created instance has a [] method' do
320
+ inst = first.create('Bob Builder', 52)
321
+ expect(inst['name']).to eq('Bob Builder')
322
+ expect(inst['age']).to eq(52)
323
+ end
324
+
299
325
  it 'will perform type assertion of the arguments' do
300
326
  expect { first.create('Bob Builder', '52') }.to(
301
327
  raise_error(TypeAssertionError,
@@ -379,6 +405,18 @@ describe 'Puppet Ruby Generator' do
379
405
  expect(results).to eq([inst])
380
406
  end
381
407
  end
408
+
409
+ context 'when used from Puppet' do
410
+ let(:type_usage) { <<-PUPPET.unindent }
411
+ $i = MyModule::FirstGenerated('Bob Builder', 52)
412
+ notice($i['name'])
413
+ notice($i['age'])
414
+ PUPPET
415
+
416
+ it 'The [] method is present on a created instance' do
417
+ expect(notices).to eql(['Bob Builder', '52'])
418
+ end
419
+ end
382
420
  end
383
421
 
384
422
  context 'when generating static code' do
@@ -576,7 +614,7 @@ describe 'Puppet Ruby Generator' do
576
614
  "MyFloat => Float, "+
577
615
  "ThirdGenerated => Object[{attributes => {'first' => My::FirstGenerated}}], "+
578
616
  "FourthGenerated => Object[{parent => My::SecondGenerated, attributes => {"+
579
- "'complex' => {type => Optional[ThirdGenerated], value => ?}, "+
617
+ "'complex' => {type => Optional[ThirdGenerated], value => undef}, "+
580
618
  "'n1' => My::MyInteger, "+
581
619
  "'n2' => MyFloat"+
582
620
  "}}]}, references => {My => {'name' => 'MyModule', 'version_range' => '1.x'}}}]")
@@ -0,0 +1,353 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+ require 'puppet_spec/compiler'
4
+ require 'puppet/parser/script_compiler'
5
+
6
+ module Puppet::Pops
7
+ module Types
8
+ describe 'The Task Type' do
9
+ include PuppetSpec::Compiler
10
+ include PuppetSpec::Files
11
+
12
+ context 'when loading' do
13
+ let(:testing_env) do
14
+ {
15
+ 'testing' => {
16
+ 'modules' => modules,
17
+ 'manifests' => manifests
18
+ }
19
+ }
20
+ end
21
+
22
+ let(:manifests) { {} }
23
+ let(:environments_dir) { Puppet[:environmentpath] }
24
+
25
+ let(:testing_env_dir) do
26
+ dir_contained_in(environments_dir, testing_env)
27
+ env_dir = File.join(environments_dir, 'testing')
28
+ PuppetSpec::Files.record_tmp(env_dir)
29
+ env_dir
30
+ end
31
+
32
+ let(:modules_dir) { File.join(testing_env_dir, 'modules') }
33
+ let(:env) { Puppet::Node::Environment.create(:testing, [modules_dir]) }
34
+ let(:node) { Puppet::Node.new('test', :environment => env) }
35
+ let(:logs) { [] }
36
+ let(:warnings) { logs.select { |log| log.level == :warning }.map { |log| log.message } }
37
+ let(:notices) { logs.select { |log| log.level == :notice }.map { |log| log.message } }
38
+ let(:task_t) { TypeFactory.task }
39
+ before(:each) { Puppet[:tasks] = true }
40
+
41
+ context 'tasks' do
42
+ let(:compiler) { Puppet::Parser::ScriptCompiler.new(env, node.name) }
43
+
44
+ let(:modules) do
45
+ { 'testmodule' => testmodule }
46
+ end
47
+
48
+ def compile(code = nil)
49
+ Puppet[:code] = code
50
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
51
+ compiler.compile do |catalog|
52
+ yield if block_given?
53
+ catalog
54
+ end
55
+ end
56
+ end
57
+
58
+ context 'without metadata' do
59
+ let(:testmodule) {
60
+ {
61
+ 'tasks' => {
62
+ 'hello' => <<-RUBY
63
+ require 'json'
64
+ args = JSON.parse(STDIN.read)
65
+ puts({message: args['message']}.to_json)
66
+ exit 0
67
+ RUBY
68
+ }
69
+ }
70
+ }
71
+
72
+ it 'loads task without metadata as a generic Task' do
73
+ compile do
74
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
75
+ task = module_loader.load(:task, 'testmodule::hello')
76
+ expect(task_t.instance?(task)).to be_truthy
77
+ expect(task.name).to eq('testmodule::hello')
78
+ expect(task._pcore_type).to eq(task_t)
79
+ end
80
+ end
81
+
82
+ context 'without --tasks' do
83
+ before(:each) { Puppet[:tasks] = false }
84
+
85
+ it 'evaluator does not recognize generic tasks' do
86
+ compile do
87
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
88
+ expect(module_loader.load(:task, 'testmodule::hello')).to be_nil
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ context 'with metadata' do
95
+ let(:testmodule) {
96
+ {
97
+ 'tasks' => {
98
+ 'hello.rb' => <<-RUBY,
99
+ require 'json'
100
+ args = JSON.parse(STDIN.read)
101
+ puts({message: args['message']}.to_json)
102
+ exit 0
103
+ RUBY
104
+ 'hello.json' => <<-JSON,
105
+ {
106
+ "puppet_task_version": 1,
107
+ "supports_noop": true,
108
+ "parameters": {
109
+ "message": {
110
+ "type": "String",
111
+ "description": "the message",
112
+ "sensitive": false
113
+ },
114
+ "font": {
115
+ "type": "Optional[String]"
116
+ }
117
+ }}
118
+ JSON
119
+ 'non_data.rb' => <<-RUBY,
120
+ require 'json'
121
+ args = JSON.parse(STDIN.read)
122
+ puts({message: args['message']}.to_json)
123
+ exit 0
124
+ RUBY
125
+ 'non_data.json' => <<-JSON
126
+ {
127
+ "puppet_task_version": 1,
128
+ "supports_noop": true,
129
+ "parameters": {
130
+ "arg": {
131
+ "type": "Hash",
132
+ "description": "the non data param"
133
+ }
134
+ }}
135
+ JSON
136
+ }
137
+ }
138
+ }
139
+
140
+ it 'loads a task with parameters' do
141
+ compile do
142
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
143
+ task = module_loader.load(:task, 'testmodule::hello')
144
+ expect(task_t.instance?(task)).to be_truthy
145
+ expect(task.name).to eq('testmodule::hello')
146
+ expect(task._pcore_type).to eq(task_t)
147
+ expect(task.supports_noop).to eql(true)
148
+ expect(task.puppet_task_version).to eql(1)
149
+ expect(task.executable).to eql("#{modules_dir}/testmodule/tasks/hello.rb")
150
+
151
+ tp = task.parameters
152
+ expect(tp['message']['description']).to eql('the message')
153
+ expect(tp['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
154
+ end
155
+ end
156
+
157
+ it 'loads a task with non-Data parameter' do
158
+ compile do
159
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
160
+ task = module_loader.load(:task, 'testmodule::non_data')
161
+ expect(task_t.instance?(task)).to be_truthy
162
+ tp = task.parameters
163
+ expect(tp['arg']['type']).to be_a(Puppet::Pops::Types::PHashType)
164
+ end
165
+ end
166
+
167
+ context 'with adjacent directory for init task' do
168
+ let(:testmodule) {
169
+ {
170
+ 'tasks' => {
171
+ 'init' => {
172
+ 'foo.sh' => 'echo hello'
173
+ },
174
+ 'init.sh' => 'echo hello',
175
+ 'init.json' => <<-JSON
176
+ {
177
+ "supports_noop": true,
178
+ "parameters": {
179
+ "message": { "type": "String" }
180
+ }
181
+ }
182
+ JSON
183
+ }
184
+ }
185
+ }
186
+
187
+ it 'loads the init task with parameters and executable' do
188
+ compile do
189
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
190
+ task = module_loader.load(:task, 'testmodule')
191
+ expect(task_t.instance?(task)).to be_truthy
192
+ expect(task.executable).to eql("#{modules_dir}/testmodule/tasks/init.sh")
193
+ expect(task.parameters).to be_a(Hash)
194
+ expect(task.parameters['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
195
+ end
196
+ end
197
+ end
198
+
199
+ context 'with adjacent directory for named task' do
200
+ let(:testmodule) {
201
+ {
202
+ 'tasks' => {
203
+ 'hello' => {
204
+ 'foo.sh' => 'echo hello'
205
+ },
206
+ 'hello.sh' => 'echo hello',
207
+ 'hello.json' => <<-JSON
208
+ {
209
+ "supports_noop": true,
210
+ "parameters": {
211
+ "message": { "type": "String" }
212
+ }
213
+ }
214
+ JSON
215
+ }
216
+ }
217
+ }
218
+
219
+ it 'loads a named task with parameters and executable' do
220
+ compile do
221
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
222
+ task = module_loader.load(:task, 'testmodule::hello')
223
+ expect(task_t.instance?(task)).to be_truthy
224
+ expect(task.executable).to eql("#{modules_dir}/testmodule/tasks/hello.sh")
225
+ expect(task.parameters).to be_a(Hash)
226
+ expect(task.parameters['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
227
+ end
228
+ end
229
+ end
230
+
231
+ context 'using more than two segments in the name' do
232
+ let(:testmodule) {
233
+ {
234
+ 'tasks' => {
235
+ 'hello' => {
236
+ 'foo.sh' => 'echo hello'
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ it 'task is not found' do
243
+ compile do
244
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
245
+ expect(module_loader.load(:task, 'testmodule::hello::foo')).to be_nil
246
+ end
247
+ end
248
+ end
249
+
250
+ context 'that has a malformed top-level entry' do
251
+ let(:testmodule) {
252
+ {
253
+ 'tasks' => {
254
+ 'hello' => 'echo hello',
255
+ 'hello.json' => <<-JSON
256
+ {
257
+ "supports_nop": true,
258
+ "parameters": {
259
+ "message": { "type": "String" }
260
+ }
261
+ }
262
+ JSON
263
+ }
264
+ }
265
+ }
266
+
267
+ it 'fails with unrecognized key error' do
268
+ compile do
269
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
270
+ expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
271
+ /Failed to load metadata for task testmodule::hello:.*unrecognized key 'supports_nop'/)
272
+ end
273
+ end
274
+ end
275
+
276
+ context 'that has no parameters' do
277
+ let(:testmodule) {
278
+ {
279
+ 'tasks' => {
280
+ 'hello' => 'echo hello',
281
+ 'hello.json' => '{ "supports_noop": false }' }
282
+ }
283
+ }
284
+
285
+ it 'loads the task with parameters set to undef' do
286
+ compile do
287
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
288
+ task = module_loader.load(:task, 'testmodule::hello')
289
+ expect(task_t.instance?(task)).to be_truthy
290
+ expect(task.parameters).to be_nil
291
+ end
292
+ end
293
+ end
294
+
295
+ context 'that has a malformed parameter name' do
296
+ let(:testmodule) {
297
+ {
298
+ 'tasks' => {
299
+ 'hello' => 'echo hello',
300
+ 'hello.json' => <<-JSON
301
+ {
302
+ "supports_noop": true,
303
+ "parameters": {
304
+ "Message": { "type": "String" }
305
+ }
306
+ }
307
+ JSON
308
+ }
309
+ }
310
+ }
311
+
312
+ it 'fails with pattern mismatch error' do
313
+ compile do
314
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
315
+ expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
316
+ /entry 'parameters' key of entry 'Message' expects a match for Pattern\[\/\\A\[a-z\]\[a-z0-9_\]\*\\z\/\], got 'Message'/)
317
+ end
318
+ end
319
+ end
320
+
321
+ context 'that has a puppet_task_version that is a string' do
322
+ let(:testmodule) {
323
+ {
324
+ 'tasks' => {
325
+ 'hello' => 'echo hello',
326
+ 'hello.json' => <<-JSON
327
+ {
328
+ "puppet_task_version": "1",
329
+ "supports_noop": true,
330
+ "parameters": {
331
+ "message": { "type": "String" }
332
+ }
333
+ }
334
+ JSON
335
+ }
336
+ }
337
+ }
338
+
339
+ it 'fails with type mismatch error' do
340
+ compile do
341
+ module_loader = Puppet.lookup(:loaders).find_loader('testmodule')
342
+ expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
343
+ /entry 'puppet_task_version' expects an Integer value, got String/)
344
+ end
345
+ end
346
+ end
347
+ end
348
+ end
349
+ end
350
+ end
351
+ end
352
+ end
353
+