puppet 5.3.7-x64-mingw32 → 5.4.0-x64-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 (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 +220 -182
  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
@@ -60,18 +60,53 @@ describe "Defaults" do
60
60
  end
61
61
  end
62
62
 
63
- describe 'supported_checksum_types' do
64
- it 'should default to md5,sha256' do
65
- expect(Puppet.settings[:supported_checksum_types]).to eq(['md5', 'sha256'])
63
+ describe '.default_digest_algorithm' do
64
+ it 'defaults to md5 when FIPS is not enabled' do
65
+ Puppet::Util::Platform.stubs(:fips_enabled?).returns false
66
+ expect(Puppet.default_digest_algorithm).to eq('md5')
67
+ end
68
+
69
+ it 'defaults to sha256 when FIPS is enabled' do
70
+ Puppet::Util::Platform.stubs(:fips_enabled?).returns true
71
+ expect(Puppet.default_digest_algorithm).to eq('sha256')
72
+ end
73
+ end
74
+
75
+ describe '.supported_checksum_types' do
76
+ it 'defaults to md5, sha256, sha384, sha512, sha224 when FIPS is not enabled' do
77
+ Puppet::Util::Platform.stubs(:fips_enabled?).returns false
78
+ expect(Puppet.default_file_checksum_types).to eq(%w[md5 sha256 sha384 sha512 sha224])
79
+ end
80
+
81
+ it 'defaults to sha256, sha384, sha512, sha224 when FIPS is enabled' do
82
+ Puppet::Util::Platform.stubs(:fips_enabled?).returns true
83
+ expect(Puppet.default_file_checksum_types).to eq(%w[sha256 sha384 sha512 sha224])
84
+ end
85
+ end
86
+
87
+ describe 'Puppet[:supported_checksum_types]' do
88
+ it 'defaults to md5, sha256, sha512, sha384, sha224' do
89
+ expect(Puppet.settings[:supported_checksum_types]).to eq(%w[md5 sha256 sha384 sha512 sha224])
66
90
  end
67
91
 
68
92
  it 'should raise an error on an unsupported checksum type' do
69
- expect { Puppet.settings[:supported_checksum_types] = ['md5', 'foo'] }.to raise_exception ArgumentError, 'Unrecognized checksum types ["foo"] are not supported. Valid values are ["md5", "md5lite", "sha256", "sha256lite", "sha1", "sha1lite", "mtime", "ctime"].'
93
+ expect {
94
+ Puppet.settings[:supported_checksum_types] = %w[md5 foo]
95
+ }.to raise_exception ArgumentError,
96
+ /Invalid value 'foo' for parameter supported_checksum_types. Allowed values are/
70
97
  end
71
98
 
72
99
  it 'should not raise an error on setting a valid list of checksum types' do
73
- Puppet.settings[:supported_checksum_types] = ['sha256', 'md5lite', 'mtime']
74
- expect(Puppet.settings[:supported_checksum_types]).to eq(['sha256', 'md5lite', 'mtime'])
100
+ Puppet.settings[:supported_checksum_types] = %w[sha256 md5lite mtime]
101
+ expect(Puppet.settings[:supported_checksum_types]).to eq(%w[sha256 md5lite mtime])
102
+ end
103
+
104
+ it 'raises when setting md5 in FIPS mode' do
105
+ Puppet::Util::Platform.stubs(:fips_enabled?).returns true
106
+ expect {
107
+ Puppet.settings[:supported_checksum_types] = %w[md5]
108
+ }.to raise_error(ArgumentError,
109
+ /Invalid value 'md5' for parameter supported_checksum_types. Allowed values are 'sha256'/)
75
110
  end
76
111
  end
77
112
 
@@ -88,18 +123,4 @@ describe "Defaults" do
88
123
  Puppet.settings.handlearg("--server", "test_server")
89
124
  end
90
125
  end
91
-
92
- describe 'basemodulepath' do
93
- it 'includes the global and system modules on non-windows', :unless => Puppet::Util::Platform.windows? do
94
- expect(
95
- Puppet[:basemodulepath]
96
- ).to match(%r{.*/code/modules:/opt/puppetlabs/puppet/modules})
97
- end
98
-
99
- it 'includes global modules on windows', :if => Puppet::Util::Platform.windows? do
100
- expect(
101
- Puppet[:basemodulepath]
102
- ).to match(%r{.*/code/modules})
103
- end
104
- end
105
126
  end
@@ -82,7 +82,6 @@ trace = true
82
82
 
83
83
  manipulator.expects(:set).with("baz", "foo", "bar")
84
84
  subject.set('foo', 'bar', {:section => "baz"})
85
-
86
85
  end
87
86
 
88
87
  it "opens the file with UTF-8 encoding" do
@@ -91,6 +90,52 @@ trace = true
91
90
  end
92
91
  end
93
92
 
93
+ context 'when the puppet.conf file does not exist' do
94
+ let(:config_file) { '/foo/puppet.conf' }
95
+ let(:path) { Pathname.new(config_file).expand_path }
96
+ before(:each) do
97
+ Puppet[:config] = config_file
98
+ Puppet::FileSystem.stubs(:pathname).with(path.to_s).returns(path)
99
+ end
100
+
101
+ it 'prints a message when the puppet.conf file does not exist' do
102
+ Puppet::FileSystem.stubs(:exist?).with(path).returns(false)
103
+ Puppet.expects(:warning).with("The puppet.conf file does not exist #{path.to_s}")
104
+ subject.delete('setting', {:section => 'main'})
105
+ end
106
+ end
107
+
108
+ context 'when deleting config values' do
109
+ let(:config_file) { '/foo/puppet.conf' }
110
+ let(:path) { Pathname.new(config_file).expand_path }
111
+ before(:each) do
112
+ Puppet[:config] = config_file
113
+ Puppet::FileSystem.stubs(:pathname).with(path.to_s).returns(path)
114
+ Puppet::FileSystem.stubs(:exist?).with(path).returns(true)
115
+ end
116
+
117
+ it 'prints a message about what was deleted' do
118
+ Puppet::FileSystem.stubs(:open).with(path, anything, anything).yields(StringIO.new)
119
+ config = Puppet::Settings::IniFile.new([Puppet::Settings::IniFile::DefaultSection.new])
120
+ manipulator = Puppet::Settings::IniFile::Manipulator.new(config)
121
+ Puppet::Settings::IniFile::Manipulator.stubs(:new).returns(manipulator)
122
+
123
+ manipulator.expects(:delete).with('main', 'setting').returns(' setting=value')
124
+ expect { subject.delete('setting', {:section => 'main'}) }.to have_printed("Deleted setting from 'main': 'setting=value'")
125
+ end
126
+
127
+ it 'prints a warning when a setting is not found to delete' do
128
+ Puppet::FileSystem.stubs(:open).with(path, anything, anything).yields(StringIO.new)
129
+ config = Puppet::Settings::IniFile.new([Puppet::Settings::IniFile::DefaultSection.new])
130
+ manipulator = Puppet::Settings::IniFile::Manipulator.new(config)
131
+ Puppet::Settings::IniFile::Manipulator.stubs(:new).returns(manipulator)
132
+
133
+ manipulator.expects(:delete).with('main', 'setting').returns(nil)
134
+ Puppet.expects(:warning).with("No setting found in configuration file for section 'main' setting name 'setting'")
135
+ subject.delete('setting', {:section => 'main'})
136
+ end
137
+ end
138
+
94
139
  shared_examples_for :config_printing_a_section do |section|
95
140
 
96
141
  def add_section_option(args, section)
@@ -201,8 +201,12 @@ describe Puppet::Face[:epp, :current] do
201
201
  expect(eppface.render(:e => 'hello <%= $x %>', :values => '{x => "mr X"}')).to eq("hello mr X")
202
202
  end
203
203
 
204
- it "adds values given in a puppet hash given on command line with --values" do
205
- expect(eppface.render(:e => 'hello <%= $x %>', :values => '{x => "mr X"}')).to eq("hello mr X")
204
+ it "adds fully qualified values given in a puppet hash given on command line with --values" do
205
+ expect(eppface.render(:e => 'hello <%= $mr::x %>', :values => '{mr::x => "mr X"}')).to eq("hello mr X")
206
+ end
207
+
208
+ it "adds fully qualified values with leading :: given in a puppet hash given on command line with --values" do
209
+ expect(eppface.render(:e => 'hello <%= $::mr %>', :values => '{"::mr" => "mr X"}')).to eq("hello mr X")
206
210
  end
207
211
 
208
212
  it "adds values given in a puppet hash produced by a .pp file given with --values_file" do
@@ -239,7 +243,7 @@ describe Puppet::Face[:epp, :current] do
239
243
 
240
244
  it 'initializes the 4x loader' do
241
245
  expect(eppface.render({ :e => <<-EPP.unindent })).to eql("\nString\n\nInteger\n\nBoolean\n")
242
- <% $data = [type('a',generalized), type(2,generalized), type(true)] -%>
246
+ <% $data = [type('a',generalized), type(2,generalized), type(true,generalized)] -%>
243
247
  <% $data.each |$value| { %>
244
248
  <%= $value %>
245
249
  <% } -%>
@@ -64,6 +64,17 @@ describe "puppet module search" do
64
64
  expect(subject.render(results, ['apache', {}])).to match(/tag2/)
65
65
  end
66
66
 
67
+ it 'should mark deprecated modules in search results' do
68
+ results = {
69
+ :result => :success,
70
+ :answers => [
71
+ {'full_name' => 'puppetlabs-corosync', 'deprecated_at' => Time.new, 'author' => 'Author', 'desc' => 'Summary', 'tag_list' => ['tag1', 'tag2'] },
72
+ ]
73
+ }
74
+
75
+ expect(subject.render(results, ['apache', {}])).to match(/puppetlabs-corosync.*DEPRECATED/i)
76
+ end
77
+
67
78
  it 'should elide really long descriptions' do
68
79
  results = {
69
80
  :result => :success,
@@ -72,7 +72,7 @@ describe Puppet::Face[:parser, :current] do
72
72
  expect { parser.validate(manifest) }.to exit_with(1)
73
73
  end
74
74
 
75
- expect(@logs.join).to match(/environment special.*Syntax error at end of file/)
75
+ expect(@logs.join).to match(/environment special.*Syntax error at end of input/)
76
76
  end
77
77
 
78
78
  end
@@ -117,7 +117,7 @@ describe Puppet::Face[:parser, :current] do
117
117
  output = parser.dump({ :e => '{ invalid =>' })
118
118
 
119
119
  expect(output).to eq("")
120
- expect(@logs[0].message).to eq("Syntax error at end of file")
120
+ expect(@logs[0].message).to eq("Syntax error at end of input")
121
121
  expect(@logs[0].level).to eq(:err)
122
122
  end
123
123
 
@@ -145,6 +145,9 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
145
145
  describe "listing files in local filebucket" do
146
146
  with_digest_algorithms do
147
147
  it "should list all files present" do
148
+ if Puppet::Util::Platform.windows? && digest_algorithm == "sha512"
149
+ skip "PUP-8257: Skip file bucket test on windows for #{digest_algorithm} due to long path names"
150
+ end
148
151
  Puppet[:bucketdir] = "/my/bucket"
149
152
  file_bucket = tmpdir("bucket")
150
153
 
@@ -190,6 +193,9 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
190
193
  end
191
194
 
192
195
  it "should filter with the provided dates" do
196
+ if Puppet::Util::Platform.windows? && digest_algorithm == "sha512"
197
+ skip "PUP-8257: Skip file bucket test on windows for #{digest_algorithm} due to long path names"
198
+ end
193
199
  Puppet[:bucketdir] = "/my/bucket"
194
200
  file_bucket = tmpdir("bucket")
195
201
 
@@ -294,6 +300,9 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
294
300
  describe "backing up and retrieving local files" do
295
301
  with_digest_algorithms do
296
302
  it "should backup files to a local bucket" do
303
+ if Puppet::Util::Platform.windows? && digest_algorithm == "sha512"
304
+ skip "PUP-8257: Skip file bucket test on windows for #{digest_algorithm} due to long path names"
305
+ end
297
306
  Puppet[:bucketdir] = "/non/existent/directory"
298
307
  file_bucket = tmpdir("bucket")
299
308
 
@@ -311,7 +320,9 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
311
320
 
312
321
  file = make_tmp_file(plaintext)
313
322
 
314
- Puppet::FileBucket::File.indirection.expects(:head).returns true
323
+ Puppet::FileBucket::File.indirection.expects(:head).with(
324
+ regexp_matches(%r{#{digest_algorithm}/#{checksum}}), :bucket_path => "/my/bucket"
325
+ ).returns true
315
326
  Puppet::FileBucket::File.indirection.expects(:save).never
316
327
  expect(@dipper.backup(file)).to eq(checksum)
317
328
  end
@@ -215,4 +215,74 @@ describe Puppet::Forge::ModuleRelease do
215
215
 
216
216
  it_behaves_like 'a module release'
217
217
  end
218
+
219
+ context 'deprecated forge module' do
220
+ let(:release_json) do %Q{
221
+ {
222
+ "uri": "/#{api_version}/releases/#{module_full_name_versioned}",
223
+ "module": {
224
+ "uri": "/#{api_version}/modules/#{module_full_name}",
225
+ "name": "#{module_name}",
226
+ "deprecated_at": "2017-10-10 10:21:32 -0700",
227
+ "owner": {
228
+ "uri": "/#{api_version}/users/#{module_author}",
229
+ "username": "#{module_author}",
230
+ "gravatar_id": "fdd009b7c1ec96e088b389f773e87aec"
231
+ }
232
+ },
233
+ "version": "#{module_version}",
234
+ "metadata": {
235
+ "types": [ ],
236
+ "license": "Apache 2.0",
237
+ "checksums": { },
238
+ "version": "#{module_version}",
239
+ "description": "Standard Library for Puppet Modules",
240
+ "source": "git://github.com/puppetlabs/puppetlabs-stdlib.git",
241
+ "project_page": "https://github.com/puppetlabs/puppetlabs-stdlib",
242
+ "summary": "Puppet Module Standard Library",
243
+ "dependencies": [
244
+
245
+ ],
246
+ "author": "#{module_author}",
247
+ "name": "#{module_full_name}"
248
+ },
249
+ "tags": [
250
+ "puppetlabs",
251
+ "library",
252
+ "stdlib",
253
+ "standard",
254
+ "stages"
255
+ ],
256
+ "file_uri": "/#{api_version}/files/#{module_full_name_versioned}.tar.gz",
257
+ "file_size": 67586,
258
+ "file_md5": "#{module_md5}",
259
+ "downloads": 610751,
260
+ "readme": "",
261
+ "changelog": "",
262
+ "license": "",
263
+ "created_at": "2013-05-13 08:31:19 -0700",
264
+ "updated_at": "2013-05-13 08:31:19 -0700",
265
+ "deleted_at": null
266
+ }
267
+ }
268
+ end
269
+
270
+ it_behaves_like 'a module release'
271
+
272
+ describe '#prepare' do
273
+ before :each do
274
+ release.stubs(:tmpfile).returns(mock_file)
275
+ release.stubs(:tmpdir).returns(mock_dir)
276
+ release.stubs(:download)
277
+ release.stubs(:validate_checksum)
278
+ release.stubs(:unpack)
279
+ end
280
+
281
+ it 'should emit warning about module deprecation' do
282
+ Puppet.expects(:warning).with(regexp_matches(/#{Regexp.escape(module_full_name)}.*deprecated/i))
283
+
284
+ release.prepare
285
+ end
286
+ end
287
+ end
218
288
  end
@@ -17,7 +17,16 @@ describe 'the break function' do
17
17
  CODE
18
18
  end
19
19
 
20
- it 'breaks iteration as if at end of input in a reduce' do
20
+ it 'breaks iteration as if at end of input in a map for a hash' do
21
+ expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[[1, 2]]')
22
+ function please_break() {
23
+ {'a' => 1, 'b' => 2, 'c' => 3}.map |$x, $y| { if $y == 3 { break() } $y }
24
+ }
25
+ notify { String(please_break()): }
26
+ CODE
27
+ end
28
+
29
+ it 'breaks iteration as if at end of input in a reduce for an array' do
21
30
  expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[6]')
22
31
  function please_break() {
23
32
  [1,2,3,4].reduce |$memo, $x| { if $x == 4 { break() } $memo + $x }
@@ -26,7 +35,21 @@ describe 'the break function' do
26
35
  CODE
27
36
  end
28
37
 
29
- it 'breaks iteration as if at end of input in an each' do
38
+ it 'breaks iteration as if at end of input in a reduce for a hash' do
39
+ expect(compile_to_catalog(<<-CODE)).to have_resource("Notify[['abc', 6]]")
40
+ function please_break() {
41
+ {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4}.reduce |$memo, $x| {
42
+ if $x[1] == 4 { break() }
43
+ $string = "${memo[0]}${x[0]}"
44
+ $number = $memo[1] + $x[1]
45
+ [$string, $number]
46
+ }
47
+ }
48
+ notify { String(please_break()): }
49
+ CODE
50
+ end
51
+
52
+ it 'breaks iteration as if at end of input in an each for an array' do
30
53
  expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
31
54
  function please_break() {
32
55
  [1,2,3].each |$x| { if $x == 3 { break() } notify { "$x": } }
@@ -35,6 +58,15 @@ describe 'the break function' do
35
58
  CODE
36
59
  end
37
60
 
61
+ it 'breaks iteration as if at end of input in an each for a hash' do
62
+ expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
63
+ function please_break() {
64
+ {'a' => 1, 'b' => 2, 'c' => 3}.each |$x, $y| { if $y == 3 { break() } notify { "$y": } }
65
+ }
66
+ please_break()
67
+ CODE
68
+ end
69
+
38
70
  it 'breaks iteration as if at end of input in a reverse_each' do
39
71
  expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[2]')
40
72
  function please_break() {
@@ -295,4 +295,5 @@ describe 'The "contain" function' do
295
295
 
296
296
  it_should_behave_like 'all functions transforming relative to absolute names', :contain
297
297
  it_should_behave_like 'an inclusion function, regardless of the type of class reference,', :contain
298
+ it_should_behave_like 'an inclusion function, when --tasks is on,', :contain
298
299
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ require 'puppet_spec/compiler'
4
+ require 'matchers/resource'
5
+
6
+ describe 'the convert_to function' do
7
+ include PuppetSpec::Compiler
8
+ include Matchers::Resource
9
+
10
+ it 'converts and returns the converted when no lambda is given' do
11
+ expect(compile_to_catalog('notify{ "testing-${[a,1].convert_to(Hash) =~ Hash}": }')).to have_resource('Notify[testing-true]')
12
+ end
13
+
14
+ it 'converts given value to instance of type and calls a lambda with converted value' do
15
+ expect(compile_to_catalog('"1".convert_to(Integer) |$x| { notify { "testing-${x.type(generalized)}": } }')).to have_resource('Notify[testing-Integer]')
16
+ end
17
+
18
+ it 'returns the lambda return when lambda is given' do
19
+ expect(compile_to_catalog('notify{ "testing-${[a,1].convert_to(Hash) |$x| { yay }}": }')).to have_resource('Notify[testing-yay]')
20
+ end
21
+
22
+ end
@@ -13,6 +13,11 @@ describe "the epp function" do
13
13
  expect(eval_template("all your base <%= $what %> to us")).to eq("all your base are belong to us")
14
14
  end
15
15
 
16
+ it "looks up a fully qualified value from the scope" do
17
+ scope["what::is"] = "are belong"
18
+ expect(eval_template("all your base <%= $what::is %> to us")).to eq("all your base are belong to us")
19
+ end
20
+
16
21
  it "get nil accessing a variable that does not exist" do
17
22
  expect(eval_template("<%= $kryptonite == undef %>")).to eq("true")
18
23
  end
@@ -98,6 +98,20 @@ describe 'The "include" function' do
98
98
  }.to raise_error(Puppet::Error)
99
99
  end
100
100
 
101
+ { "''" => 'empty string',
102
+ 'undef' => 'undef',
103
+ "['']" => 'empty string',
104
+ "[undef]" => 'undef'
105
+ }.each_pair do |value, name_kind|
106
+ it "raises an error if class is #{name_kind}" do
107
+ expect {
108
+ catalog = compile_to_catalog(<<-MANIFEST)
109
+ include #{value}
110
+ MANIFEST
111
+ }.to raise_error(/Cannot use #{name_kind}/)
112
+ end
113
+ end
114
+
101
115
  it "does not contained the included class in the current class" do
102
116
  catalog = compile_to_catalog(<<-MANIFEST)
103
117
  class not_contained {
@@ -171,5 +185,6 @@ describe 'The "include" function' do
171
185
 
172
186
  it_should_behave_like 'all functions transforming relative to absolute names', :include
173
187
  it_should_behave_like 'an inclusion function, regardless of the type of class reference,', :include
188
+ it_should_behave_like 'an inclusion function, when --tasks is on,', :include
174
189
 
175
190
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'puppet_spec/compiler'
3
+ require 'matchers/resource'
4
+ require 'puppet_spec/files'
5
+
6
+ describe 'the module_directory function' do
7
+ include PuppetSpec::Compiler
8
+ include Matchers::Resource
9
+ include PuppetSpec::Files
10
+
11
+ it 'returns first found module from one or more given names' do
12
+ mod = mock 'module'
13
+ mod.stubs(:path).returns('expected_path')
14
+ Puppet[:code] = "notify { module_directory('one', 'two'):}"
15
+ node = Puppet::Node.new('localhost')
16
+ compiler = Puppet::Parser::Compiler.new(node)
17
+ compiler.environment.stubs(:module).with('one').returns(nil)
18
+ compiler.environment.stubs(:module).with('two').returns(mod)
19
+ expect(compiler.compile()).to have_resource("Notify[expected_path]")
20
+ end
21
+
22
+ it 'returns first found module from one or more given names in an array' do
23
+ mod = mock 'module'
24
+ mod.stubs(:path).returns('expected_path')
25
+ Puppet[:code] = "notify { module_directory(['one', 'two']):}"
26
+ node = Puppet::Node.new('localhost')
27
+ compiler = Puppet::Parser::Compiler.new(node)
28
+ compiler.environment.stubs(:module).with('one').returns(nil)
29
+ compiler.environment.stubs(:module).with('two').returns(mod)
30
+ expect(compiler.compile()).to have_resource("Notify[expected_path]")
31
+ end
32
+
33
+ it 'returns undef when none of the modules were found' do
34
+ mod = mock 'module'
35
+ mod.stubs(:path).returns('expected_path')
36
+ Puppet[:code] = "notify { String(type(module_directory('one', 'two'))):}"
37
+ node = Puppet::Node.new('localhost')
38
+ compiler = Puppet::Parser::Compiler.new(node)
39
+ compiler.environment.stubs(:module).with('one').returns(nil)
40
+ compiler.environment.stubs(:module).with('two').returns(nil)
41
+ expect(compiler.compile()).to have_resource("Notify[Undef]")
42
+ end
43
+ end