puppet 4.7.1-x86-mingw32 → 4.8.0-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 (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  module Puppet
10
- PUPPETVERSION = '4.7.1'
10
+ PUPPETVERSION = '4.8.0'
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -1,6 +1,12 @@
1
1
  # The Puppet Extensions Module.
2
2
  #
3
- # Submodules of this module should be named after the publisher (e.g. 'user' part of a Puppet Module name).
3
+ # Submodules of this module should be named after the publisher (e.g.
4
+ # 'user' part of a Puppet Module name). You should also add the module
5
+ # name to avoid further conflicts in the same namespace. So the
6
+ # structure should be
7
+ # `lib/puppet_x/<namespace>/<module_name>/<extension.rb>`.
8
+ # A Puppet Extension for 'puppetlabs-powershell' would live at
9
+ # `lib/puppet_x/puppetlabs/powershell/<extension.rb>`.
4
10
  #
5
11
  # @api public
6
12
  #
@@ -309,6 +309,124 @@ end
309
309
  expect(logs).to include(match(/doesn't match server specified environment/))
310
310
  end
311
311
  end
312
+ end
313
+
314
+ context 'when compiling a provided catalog with rich data and then applying from file' do
315
+ include PuppetSpec::Compiler
316
+
317
+ let(:env_dir) { tmpdir('environments') }
318
+ let(:execute) { 'include amod' }
319
+ let(:rich_data) { false }
320
+ let(:env_name) { 'spec' }
321
+ let(:populated_env_dir) do
322
+ dir_contained_in(env_dir, {
323
+ env_name => {
324
+ 'modules' => {
325
+ 'amod' => {
326
+ 'manifests' => {
327
+ 'init.pp' => <<-EOF
328
+ class amod {
329
+ notify { rx: message => /[Rr]eg[Ee]xp/ }
330
+ notify { bin: message => Binary('w5ZzdGVuIG1lZCByw7ZzdGVuCg==') }
331
+ notify { ver: message => SemVer('2.3.1') }
332
+ notify { vrange: message => SemVerRange('>=2.3.0') }
333
+ notify { tspan: message => Timespan(3600) }
334
+ notify { tstamp: message => Timestamp('2012-03-04T18:15:11.001') }
335
+ }
336
+
337
+ class amod::bad_type {
338
+ notify { bogus: message => amod::bogus() }
339
+ }
340
+ EOF
341
+ },
342
+ 'lib' => {
343
+ 'puppet' => {
344
+ 'functions' => {
345
+ 'amod' => {
346
+ 'bogus.rb' => <<-RUBY
347
+ # Function that leaks an object that is not recognized in the catalog
348
+ Puppet::Functions.create_function(:'amod::bogus') do
349
+ def bogus()
350
+ Time.new(2016, 10, 6, 23, 51, 14, '+02:00')
351
+ end
352
+ end
353
+ RUBY
354
+ }
355
+ }
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+ })
362
+ env_dir
363
+ end
364
+
365
+ let(:env) { Puppet::Node::Environment.create(env_name.to_sym, [File.join(populated_env_dir, 'spec', 'modules')]) }
366
+ let(:node) { Puppet::Node.new('test', :environment => env) }
367
+
368
+ around(:each) do |example|
369
+ Puppet[:rich_data] = rich_data
370
+ Puppet.override(:loaders => Puppet::Pops::Loaders.new(env)) { example.run }
371
+ end
372
+
373
+ context 'and rich_data is set to false during compile' do
374
+ it 'will notify a string that is the result of Regexp#inspect (from Runtime3xConverter)' do
375
+ catalog = compile_to_catalog(execute, node)
376
+ apply = Puppet::Application[:apply]
377
+ apply.options[:catalog] = file_containing('manifest', catalog.to_pson)
378
+ apply.expects(:apply_catalog).with do |catalog|
379
+ catalog.resource(:notify, 'rx')['message'].is_a?(String)
380
+ catalog.resource(:notify, 'bin')['message'].is_a?(String)
381
+ catalog.resource(:notify, 'ver')['message'].is_a?(String)
382
+ catalog.resource(:notify, 'vrange')['message'].is_a?(String)
383
+ catalog.resource(:notify, 'tspan')['message'].is_a?(String)
384
+ catalog.resource(:notify, 'tstamp')['message'].is_a?(String)
385
+ end
386
+ apply.run
387
+ end
388
+
389
+ it 'will notify a string that is the result of to_s on uknown data types' do
390
+ logs = []
391
+ json = Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
392
+ compile_to_catalog('include amod::bad_type', node).to_pson
393
+ end
394
+ logs = logs.select { |log| log.level == :warning }.map { |log| log.message }
395
+ expect(logs.empty?).to be_falsey
396
+ expect(logs[0]).to eql("Resource 'Notify[bogus]' contains a Time value. It will be converted to the String '2016-10-06 23:51:14 +0200'")
397
+
398
+ apply = Puppet::Application[:apply]
399
+ apply.options[:catalog] = file_containing('manifest', json)
400
+ apply.expects(:apply_catalog).with do |catalog|
401
+ catalog.resource(:notify, 'bogus')['message'].is_a?(String)
402
+ end
403
+ apply.run
404
+ end
405
+ end
406
+
407
+ context 'and rich_data is set to true during compile' do
408
+ let(:rich_data) { true }
409
+
410
+ it 'will notify a regexp using Regexp#to_s' do
411
+ catalog = compile_to_catalog(execute, node)
412
+ apply = Puppet::Application[:apply]
413
+ apply.options[:catalog] = file_containing('manifest', catalog.to_pson)
414
+ apply.expects(:apply_catalog).with do |catalog|
415
+ catalog.resource(:notify, 'rx')['message'].is_a?(Regexp)
416
+ catalog.resource(:notify, 'bin')['message'].is_a?(Puppet::Pops::Types::PBinaryType::Binary)
417
+ catalog.resource(:notify, 'ver')['message'].is_a?(Semantic::Version)
418
+ catalog.resource(:notify, 'vrange')['message'].is_a?(Semantic::VersionRange)
419
+ catalog.resource(:notify, 'tspan')['message'].is_a?(Puppet::Pops::Time::Timespan)
420
+ catalog.resource(:notify, 'tstamp')['message'].is_a?(Puppet::Pops::Time::Timestamp)
421
+ end
422
+ apply.run
423
+ end
424
+
425
+ it 'will raise an error on uknown data types' do
426
+ catalog = compile_to_catalog('include amod::bad_type', node)
427
+ expect { catalog.to_pson }.to raise_error(/No Puppet Type found for Time/)
428
+ end
429
+ end
312
430
 
313
431
  end
314
432
  end
@@ -153,6 +153,25 @@ describe Puppet::Parser::Compiler do
153
153
  end
154
154
  end
155
155
 
156
+ context 'when working with $settings name space' do
157
+ include PuppetSpec::Compiler
158
+ it 'makes $settings::strict available as string' do
159
+ node = Puppet::Node.new("testing")
160
+ catalog = compile_to_catalog(<<-MANIFEST, node)
161
+ notify { 'test': message => $settings::strict == 'warning' }
162
+ MANIFEST
163
+ expect(catalog).to have_resource("Notify[test]").with_parameter(:message, true)
164
+ end
165
+
166
+ it 'can return boolean settings as Boolean' do
167
+ node = Puppet::Node.new("testing")
168
+ catalog = compile_to_catalog(<<-MANIFEST, node)
169
+ notify { 'test': message => $settings::storeconfigs == false }
170
+ MANIFEST
171
+ expect(catalog).to have_resource("Notify[test]").with_parameter(:message, true)
172
+ end
173
+ end
174
+
156
175
  context 'when working with $server_facts' do
157
176
  include PuppetSpec::Compiler
158
177
  context 'and have opted in to trusted_server_facts' do
@@ -206,6 +225,15 @@ describe Puppet::Parser::Compiler do
206
225
  notify { 'test': message => $server_facts == 'changed' }
207
226
  MANIFEST
208
227
 
228
+ expect(catalog).to have_resource("Notify[test]").with_parameter(:message, true)
229
+ end
230
+ it 'should warn about assignment to $server_facts' do
231
+ catalog = compile_to_catalog(<<-MANIFEST)
232
+ $server_facts = 'changed'
233
+ notify { 'test': message => $server_facts == 'changed' }
234
+ MANIFEST
235
+ expect(@logs).to have_matching_log(/Assignment to \$server_facts is deprecated/)
236
+
209
237
  expect(catalog).to have_resource("Notify[test]").with_parameter(:message, true)
210
238
  end
211
239
  end
@@ -37,9 +37,9 @@ describe 'when pcore described resources types are in use' do
37
37
  } }
38
38
  },
39
39
  },
40
- 'm2' => {
40
+ 'm2' => {
41
41
  'lib' => { 'puppet' => { 'type' => {
42
- 'test2.rb' => <<-EOF
42
+ 'test2.rb' => <<-EOF,
43
43
  module Puppet
44
44
  Type.newtype(:test2) do
45
45
  @doc = "Docs for resource"
@@ -57,6 +57,16 @@ describe 'when pcore described resources types are in use' do
57
57
  end
58
58
  end;end
59
59
  EOF
60
+ 'cap.rb' => <<-EOF
61
+ module Puppet
62
+ Type.newtype(:cap, :is_capability => true) do
63
+ @doc = "Docs for capability"
64
+ @isomorphic = false
65
+ newproperty(:message) do
66
+ desc "Docs for 'message' property"
67
+ end
68
+ end;end
69
+ EOF
60
70
  } } },
61
71
  }
62
72
  }}})
@@ -102,14 +112,18 @@ describe 'when pcore described resources types are in use' do
102
112
  test2 { 'b':
103
113
  message => 'b works'
104
114
  }
115
+ cap { 'c':
116
+ message => 'c works'
117
+ }
105
118
  MANIFEST
106
119
  expect(catalog.resource(:test1, "a")['message']).to eq('a works')
107
120
  expect(catalog.resource(:test2, "b")['message']).to eq('b works')
121
+ expect(catalog.resource(:cap, "c")['message']).to eq('c works')
108
122
  end
109
123
 
110
124
  it 'the validity of attribute names are checked' do
111
125
  genface.types
112
- expect do
126
+ expect do
113
127
  compile_to_catalog(<<-MANIFEST)
114
128
  test1 { 'a':
115
129
  mezzage => 'a works'
@@ -129,6 +143,20 @@ describe 'when pcore described resources types are in use' do
129
143
  expect(catalog.resource(:test1, "a")['noop']).to eq(true)
130
144
  end
131
145
 
146
+ it 'capability is propagated to the catalog' do
147
+ genface.types
148
+ catalog = compile_to_catalog(<<-MANIFEST)
149
+ test2 { 'r':
150
+ message => 'a resource'
151
+ }
152
+ cap { 'c':
153
+ message => 'a cap'
154
+ }
155
+ MANIFEST
156
+ expect(catalog.resource(:test2, "r").is_capability?).to eq(false)
157
+ expect(catalog.resource(:cap, "c").is_capability?).to eq(true)
158
+ end
159
+
132
160
  it 'a generated type describes if it is isomorphic' do
133
161
  generate_and_in_a_compilers_context do |compiler|
134
162
  t1 = find_resource_type(compiler.topscope, 'test1')
@@ -138,6 +166,15 @@ describe 'when pcore described resources types are in use' do
138
166
  end
139
167
  end
140
168
 
169
+ it 'a generated type describes if it is a capability' do
170
+ generate_and_in_a_compilers_context do |compiler|
171
+ t1 = find_resource_type(compiler.topscope, 'test1')
172
+ expect(t1.is_capability?).to be(false)
173
+ t2 = find_resource_type(compiler.topscope, 'cap')
174
+ expect(t2.is_capability?).to be(true)
175
+ end
176
+ end
177
+
141
178
  it 'a generated type returns parameters defined in pcore' do
142
179
  generate_and_in_a_compilers_context do |compiler|
143
180
  t1 = find_resource_type(compiler.topscope, 'test1')
@@ -149,9 +149,10 @@ describe "mount provider (integration)", :unless => Puppet.features.microsoft_wi
149
149
  pending "Due to bug 6309"
150
150
  @mounted = true
151
151
  @current_device = "/dev/disk2s2"
152
+ @current_options = "local"
152
153
  create_fake_fstab(true)
153
154
  @desired_options = "local"
154
- run_in_catalog(:ensure=>:mounted, :options=>'local')
155
+ run_in_catalog(:ensure=>:mounted, :options=>'msdos,local')
155
156
  expect(@current_device).to eq("/dev/disk1s1")
156
157
  expect(@mounted).to eq(true)
157
158
  expect(@current_options).to eq('local')
@@ -8,7 +8,7 @@ describe Puppet::Util::Windows::SID::Principal, :if => Puppet.features.microsoft
8
8
  let (:system_bytes) { [1, 1, 0, 0, 0, 0, 0, 5, 18, 0, 0, 0] }
9
9
  let (:null_sid_bytes) { bytes = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
10
10
  let (:administrator_bytes) { [1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0, 0] }
11
- let (:computer_sid) { Puppet::Util::Windows::SID.name_to_sid_object(Puppet::Util::Windows::ADSI.computer_name) }
11
+ let (:computer_sid) { Puppet::Util::Windows::SID.name_to_sid_object(Socket.gethostname) }
12
12
  # BUILTIN is localized on German Windows, but not French
13
13
  # looking this up like this dilutes the values of the tests as we're comparing two mechanisms
14
14
  # for returning the same values, rather than to a known good
@@ -64,7 +64,7 @@ describe Puppet::Util::Windows::SID::Principal, :if => Puppet.features.microsoft
64
64
  # otherwise running in AppVeyor there is no Administrator and a the current local user can be used
65
65
  skip if (running_as_system && !user_exists)
66
66
 
67
- hostname = Puppet::Util::Windows::ADSI.computer_name
67
+ hostname = Socket.gethostname
68
68
 
69
69
  principal = Puppet::Util::Windows::SID::Principal.lookup_account_name("#{hostname}\\#{username}")
70
70
  expect(principal.account).to match(/^#{Regexp.quote(username)}$/i)
@@ -129,7 +129,7 @@ describe Puppet::Util::Windows::Registry do
129
129
 
130
130
  let (:hklm) { Win32::Registry::HKEY_LOCAL_MACHINE }
131
131
  let (:puppet_key) { "SOFTWARE\\Puppet Labs"}
132
- let (:subkey_name) { "PuppetRegistryTest#{SecureRandom.uuid}" }
132
+ let (:subkey_name) { "PuppetRegistryTest" }
133
133
  let (:guid) { SecureRandom.uuid }
134
134
  let (:regsam) { Puppet::Util::Windows::Registry::KEY32 }
135
135
 
@@ -187,7 +187,7 @@ describe Puppet::Util::Windows::Registry do
187
187
  context "when reading values" do
188
188
  let (:hklm) { Win32::Registry::HKEY_LOCAL_MACHINE }
189
189
  let (:puppet_key) { "SOFTWARE\\Puppet Labs"}
190
- let (:subkey_name) { "PuppetRegistryTest#{SecureRandom.uuid}" }
190
+ let (:subkey_name) { "PuppetRegistryTest" }
191
191
  let (:value_name) { SecureRandom.uuid }
192
192
 
193
193
  after(:each) do
@@ -228,7 +228,7 @@ describe Puppet::Util::Windows::Registry do
228
228
  context "when reading corrupt values" do
229
229
  let (:hklm) { Win32::Registry::HKEY_LOCAL_MACHINE }
230
230
  let (:puppet_key) { "SOFTWARE\\Puppet Labs"}
231
- let (:subkey_name) { "PuppetRegistryTest#{SecureRandom.uuid}" }
231
+ let (:subkey_name) { "PuppetRegistryTest" }
232
232
  let (:value_name) { SecureRandom.uuid }
233
233
 
234
234
  before(:each) do
@@ -254,4 +254,4 @@ describe Puppet::Util::Windows::Registry do
254
254
  end
255
255
  end
256
256
  end
257
- end
257
+ end
@@ -59,8 +59,12 @@ module PuppetSpec::Compiler
59
59
  logs
60
60
  end
61
61
 
62
- def eval_and_collect_notices(code, node = Puppet::Node.new('foonode'))
62
+ def eval_and_collect_notices(code, node = Puppet::Node.new('foonode'), topscope_vars = {})
63
63
  collect_notices(code, node) do |compiler|
64
+ unless topscope_vars.empty?
65
+ scope = compiler.topscope
66
+ topscope_vars.each {|k,v| scope.setvar(k, v) }
67
+ end
64
68
  if block_given?
65
69
  compiler.compile do |catalog|
66
70
  yield(compiler.topscope, catalog)
@@ -0,0 +1,5 @@
1
+ class String
2
+ def unindent
3
+ gsub(/^#{scan(/^\s*/).min_by{ |l| l.length }}/, '')
4
+ end
5
+ end
@@ -34,6 +34,10 @@ shared_context 'types_setup' do
34
34
  Puppet::Pops::Types::PTypeAliasType,
35
35
  Puppet::Pops::Types::PSemVerType,
36
36
  Puppet::Pops::Types::PSemVerRangeType,
37
+ Puppet::Pops::Types::PTimespanType,
38
+ Puppet::Pops::Types::PTimestampType,
39
+ Puppet::Pops::Types::PSensitiveType,
40
+ Puppet::Pops::Types::PBinaryType,
37
41
  ]
38
42
  end
39
43
 
@@ -51,6 +55,8 @@ shared_context 'types_setup' do
51
55
  Puppet::Pops::Types::PEnumType,
52
56
  Puppet::Pops::Types::PSemVerType,
53
57
  Puppet::Pops::Types::PSemVerRangeType,
58
+ Puppet::Pops::Types::PTimespanType,
59
+ Puppet::Pops::Types::PTimestampType,
54
60
  ]
55
61
  end
56
62
 
@@ -125,6 +125,22 @@ shared_examples "RHEL package provider" do |provider_class, provider_name|
125
125
  provider.stubs(:query).returns(:ensure => current_version).then.returns(:ensure => version)
126
126
  provider.install
127
127
  end
128
+ it 'should not run upgrade command if absent and ensure latest' do
129
+ current_version = ''
130
+ version = '1.2'
131
+ resource[:ensure] = :latest
132
+ Puppet::Util::Execution.expects(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, name])
133
+ provider.stubs(:query).returns(:ensure => current_version).then.returns(:ensure => version)
134
+ provider.install
135
+ end
136
+ it 'should run upgrade command if present and ensure latest' do
137
+ current_version = '1.0'
138
+ version = '1.2'
139
+ resource[:ensure] = :latest
140
+ Puppet::Util::Execution.expects(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', upgrade_command, name])
141
+ provider.stubs(:query).returns(:ensure => current_version).then.returns(:ensure => version)
142
+ provider.install
143
+ end
128
144
  it 'should accept install options' do
129
145
  resource[:ensure] = :installed
130
146
  resource[:install_options] = ['-t', {'-x' => 'expackage'}]
@@ -33,6 +33,7 @@ require 'puppet_spec/files'
33
33
  require 'puppet_spec/settings'
34
34
  require 'puppet_spec/fixtures'
35
35
  require 'puppet_spec/matchers'
36
+ require 'puppet_spec/unindent'
36
37
  require 'puppet/test/test_helper'
37
38
 
38
39
  Pathname.glob("#{dir}/shared_contexts/*.rb") do |file|
@@ -63,6 +63,17 @@ describe Puppet::Agent do
63
63
  @agent.run
64
64
  end
65
65
 
66
+ it "should initialize the client's transaction_uuid if passed as a client_option" do
67
+ client = mock 'client'
68
+ transaction_uuid = 'foo'
69
+ AgentTestClient.expects(:new).with(anything, transaction_uuid).returns client
70
+
71
+ client.expects(:run)
72
+
73
+ @agent.stubs(:disabled?).returns false
74
+ @agent.run(:transaction_uuid => transaction_uuid)
75
+ end
76
+
66
77
  it "should be considered running if the lock file is locked" do
67
78
  lockfile = mock 'lockfile'
68
79
 
@@ -162,12 +162,14 @@ describe Puppet::Application::Lookup do
162
162
  end
163
163
  end
164
164
 
165
- it '--explain produces human readable text by default' do
165
+ it '--explain produces human readable text by default and does not produce output to debug logger' do
166
166
  lookup.options[:node] = node
167
167
  lookup.options[:explain] = true
168
168
  lookup.command_line.stubs(:args).returns(['a'])
169
+ logs = []
169
170
  begin
170
- expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
171
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
172
+ expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
171
173
  Merge strategy first
172
174
  Data Binding "hiera"
173
175
  No such key: "a"
@@ -179,12 +181,54 @@ Merge strategy first
179
181
  Found key: "a" value: "This is A"
180
182
  Merged result: "This is A"
181
183
  EXPLANATION
184
+ end
185
+ rescue SystemExit => e
186
+ expect(e.status).to eq(0)
187
+ end
188
+ expect(logs.any? { |log| log.level == :debug }).to be_falsey
189
+ end
190
+
191
+ it '--explain produces human readable text by default and --debug produces the same output to debug logger' do
192
+ lookup.options[:node] = node
193
+ lookup.options[:explain] = true
194
+ lookup.command_line.stubs(:args).returns(['a'])
195
+ Puppet.debug = true
196
+ logs = []
197
+ begin
198
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
199
+ expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
200
+ Merge strategy first
201
+ Data Binding "hiera"
202
+ No such key: "a"
203
+ Data Provider "Hiera Data Provider, version 4"
204
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
205
+ Data Provider "common"
206
+ Path "#{environmentpath}/production/data/common.yaml"
207
+ Original path: "common"
208
+ Found key: "a" value: "This is A"
209
+ Merged result: "This is A"
210
+ EXPLANATION
211
+ end
182
212
  rescue SystemExit => e
183
213
  expect(e.status).to eq(0)
184
214
  end
215
+ logs = logs.select { |log| log.level == :debug }.map { |log| log.message }
216
+ expect(logs).to include(<<-EXPLANATION.chomp)
217
+ Lookup of 'a'
218
+ Merge strategy first
219
+ Data Binding "hiera"
220
+ No such key: "a"
221
+ Data Provider "Hiera Data Provider, version 4"
222
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
223
+ Data Provider "common"
224
+ Path "#{environmentpath}/production/data/common.yaml"
225
+ Original path: "common"
226
+ Found key: "a" value: "This is A"
227
+ Merged result: "This is A"
228
+ EXPLANATION
185
229
  end
186
230
 
187
- it '--explain produces human readable text of a hash merge when using --explain-options' do
231
+ it '--explain-options produces human readable text of a hash merge' do
188
232
  lookup.options[:node] = node
189
233
  lookup.options[:explain_options] = true
190
234
  begin
@@ -209,6 +253,53 @@ Merge strategy hash
209
253
  end
210
254
  end
211
255
 
256
+ it '--explain-options produces human readable text of a hash merge and --debug produces the same output to debug logger' do
257
+ lookup.options[:node] = node
258
+ lookup.options[:explain_options] = true
259
+ Puppet.debug = true
260
+ logs = []
261
+ begin
262
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
263
+ expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
264
+ Merge strategy hash
265
+ Data Binding "hiera"
266
+ No such key: "lookup_options"
267
+ Data Provider "Hiera Data Provider, version 4"
268
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
269
+ Data Provider "common"
270
+ Path "#{environmentpath}/production/data/common.yaml"
271
+ Original path: "common"
272
+ Found key: "lookup_options" value: {
273
+ "a" => "first"
274
+ }
275
+ Merged result: {
276
+ "a" => "first"
277
+ }
278
+ EXPLANATION
279
+ end
280
+ rescue SystemExit => e
281
+ expect(e.status).to eq(0)
282
+ end
283
+ logs = logs.select { |log| log.level == :debug }.map { |log| log.message }
284
+ expect(logs).to include(<<-EXPLANATION.chomp)
285
+ Lookup of '__global__'
286
+ Merge strategy hash
287
+ Data Binding "hiera"
288
+ No such key: "lookup_options"
289
+ Data Provider "Hiera Data Provider, version 4"
290
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
291
+ Data Provider "common"
292
+ Path "#{environmentpath}/production/data/common.yaml"
293
+ Original path: "common"
294
+ Found key: "lookup_options" value: {
295
+ "a" => "first"
296
+ }
297
+ Merged result: {
298
+ "a" => "first"
299
+ }
300
+ EXPLANATION
301
+ end
302
+
212
303
  it '--explain produces human readable text of a hash merge when using both --explain and --explain-options' do
213
304
  lookup.options[:node] = node
214
305
  lookup.options[:explain] = true