puppet 4.2.3-x64-mingw32 → 4.3.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 (337) hide show
  1. data/Gemfile +3 -0
  2. data/README.md +1 -1
  3. data/ext/debian/puppet.init +0 -1
  4. data/ext/debian/puppet.logrotate +14 -5
  5. data/ext/osx/puppet.plist +0 -2
  6. data/ext/redhat/client.init +13 -5
  7. data/ext/redhat/logrotate +15 -3
  8. data/ext/redhat/puppet.spec.erb +5 -1
  9. data/ext/redhat/server.init +1 -1
  10. data/ext/systemd/puppet.service +1 -0
  11. data/lib/puppet.rb +12 -0
  12. data/lib/puppet/agent.rb +4 -4
  13. data/lib/puppet/agent/locker.rb +11 -2
  14. data/lib/puppet/application/agent.rb +5 -1
  15. data/lib/puppet/application/apply.rb +4 -0
  16. data/lib/puppet/application/filebucket.rb +78 -4
  17. data/lib/puppet/application/lookup.rb +356 -0
  18. data/lib/puppet/application/master.rb +3 -0
  19. data/lib/puppet/configurer.rb +9 -5
  20. data/lib/puppet/context.rb +16 -1
  21. data/lib/puppet/context/trusted_information.rb +21 -1
  22. data/lib/puppet/daemon.rb +17 -13
  23. data/lib/puppet/data_binding.rb +4 -2
  24. data/lib/puppet/data_providers.rb +12 -13
  25. data/lib/puppet/data_providers/data_adapter.rb +7 -68
  26. data/lib/puppet/data_providers/data_function_support.rb +5 -26
  27. data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
  28. data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
  29. data/lib/puppet/data_providers/hiera_config.rb +106 -0
  30. data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
  31. data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
  32. data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
  33. data/lib/puppet/data_providers/hiera_support.rb +37 -0
  34. data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
  35. data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
  36. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
  37. data/lib/puppet/defaults.rb +12 -2
  38. data/lib/puppet/error.rb +4 -0
  39. data/lib/puppet/face/module/changes.rb +2 -1
  40. data/lib/puppet/feature/cfacter.rb +1 -0
  41. data/lib/puppet/file_bucket/dipper.rb +58 -2
  42. data/lib/puppet/functions.rb +2 -4
  43. data/lib/puppet/functions/assert_type.rb +48 -12
  44. data/lib/puppet/functions/defined.rb +79 -48
  45. data/lib/puppet/functions/each.rb +85 -27
  46. data/lib/puppet/functions/filter.rb +58 -23
  47. data/lib/puppet/functions/hiera.rb +76 -3
  48. data/lib/puppet/functions/hiera_array.rb +65 -3
  49. data/lib/puppet/functions/hiera_hash.rb +74 -2
  50. data/lib/puppet/functions/hiera_include.rb +75 -2
  51. data/lib/puppet/functions/lookup.rb +19 -17
  52. data/lib/puppet/functions/map.rb +56 -21
  53. data/lib/puppet/functions/match.rb +29 -12
  54. data/lib/puppet/functions/reduce.rb +95 -58
  55. data/lib/puppet/functions/versioncmp.rb +36 -0
  56. data/lib/puppet/functions/with.rb +15 -7
  57. data/lib/puppet/indirector/catalog/compiler.rb +3 -3
  58. data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
  59. data/lib/puppet/indirector/data_binding/none.rb +4 -1
  60. data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
  61. data/lib/puppet/indirector/hiera.rb +4 -0
  62. data/lib/puppet/indirector/json.rb +1 -1
  63. data/lib/puppet/indirector/msgpack.rb +1 -1
  64. data/lib/puppet/indirector/request.rb +7 -8
  65. data/lib/puppet/indirector/resource_type/parser.rb +5 -3
  66. data/lib/puppet/info_service.rb +7 -0
  67. data/lib/puppet/info_service/class_information_service.rb +111 -0
  68. data/lib/puppet/module_tool/metadata.rb +32 -9
  69. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
  70. data/lib/puppet/network/authconfig.rb +21 -1
  71. data/lib/puppet/network/authorization.rb +8 -1
  72. data/lib/puppet/network/http/api/master/v3.rb +7 -1
  73. data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
  74. data/lib/puppet/node/environment.rb +9 -2
  75. data/lib/puppet/parser.rb +3 -0
  76. data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
  77. data/lib/puppet/parser/compiler.rb +302 -12
  78. data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
  79. data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
  80. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
  81. data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
  82. data/lib/puppet/parser/environment_compiler.rb +165 -0
  83. data/lib/puppet/parser/functions/assert_type.rb +46 -16
  84. data/lib/puppet/parser/functions/defined.rb +105 -68
  85. data/lib/puppet/parser/functions/each.rb +85 -27
  86. data/lib/puppet/parser/functions/filter.rb +59 -23
  87. data/lib/puppet/parser/functions/hiera.rb +83 -27
  88. data/lib/puppet/parser/functions/hiera_array.rb +71 -28
  89. data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
  90. data/lib/puppet/parser/functions/hiera_include.rb +81 -40
  91. data/lib/puppet/parser/functions/map.rb +55 -20
  92. data/lib/puppet/parser/functions/match.rb +27 -12
  93. data/lib/puppet/parser/functions/reduce.rb +97 -60
  94. data/lib/puppet/parser/functions/with.rb +16 -8
  95. data/lib/puppet/parser/resource.rb +98 -19
  96. data/lib/puppet/plugins/configuration.rb +3 -2
  97. data/lib/puppet/plugins/data_providers.rb +12 -60
  98. data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
  99. data/lib/puppet/plugins/data_providers/registry.rb +84 -0
  100. data/lib/puppet/pops.rb +19 -17
  101. data/lib/puppet/pops/adapters.rb +12 -0
  102. data/lib/puppet/pops/binder/binder.rb +2 -2
  103. data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
  104. data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
  105. data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
  106. data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
  107. data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
  108. data/lib/puppet/pops/binder/injector.rb +4 -4
  109. data/lib/puppet/pops/binder/key_factory.rb +3 -9
  110. data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
  111. data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
  112. data/lib/puppet/pops/evaluator/closure.rb +8 -8
  113. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  114. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -5
  115. data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
  116. data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
  117. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  118. data/lib/puppet/pops/issues.rb +1 -1
  119. data/lib/puppet/pops/label_provider.rb +1 -1
  120. data/lib/puppet/pops/lookup.rb +25 -47
  121. data/lib/puppet/pops/lookup/explainer.rb +402 -0
  122. data/lib/puppet/pops/lookup/invocation.rb +117 -0
  123. data/lib/puppet/pops/merge_strategy.rb +73 -5
  124. data/lib/puppet/pops/model/factory.rb +34 -0
  125. data/lib/puppet/pops/model/model_label_provider.rb +10 -1
  126. data/lib/puppet/pops/model/model_meta.rb +15 -0
  127. data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
  128. data/lib/puppet/pops/parser/code_merger.rb +13 -1
  129. data/lib/puppet/pops/parser/egrammar.ra +56 -3
  130. data/lib/puppet/pops/parser/eparser.rb +1549 -1352
  131. data/lib/puppet/pops/parser/lexer2.rb +31 -6
  132. data/lib/puppet/pops/parser/locator.rb +1 -1
  133. data/lib/puppet/pops/parser/parser_support.rb +25 -13
  134. data/lib/puppet/pops/types/enumeration.rb +1 -2
  135. data/lib/puppet/pops/types/type_asserter.rb +16 -15
  136. data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
  137. data/lib/puppet/pops/types/type_calculator.rb +171 -1020
  138. data/lib/puppet/pops/types/type_factory.rb +87 -148
  139. data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
  140. data/lib/puppet/pops/types/type_parser.rb +116 -127
  141. data/lib/puppet/pops/types/types.rb +1394 -255
  142. data/lib/puppet/pops/types/types_meta.rb +0 -234
  143. data/lib/puppet/pops/validation.rb +7 -2
  144. data/lib/puppet/pops/validation/checker4_0.rb +28 -0
  145. data/lib/puppet/provider/augeas/augeas.rb +50 -0
  146. data/lib/puppet/provider/group/directoryservice.rb +10 -0
  147. data/lib/puppet/provider/package/dnf.rb +41 -0
  148. data/lib/puppet/provider/package/gem.rb +7 -2
  149. data/lib/puppet/provider/package/rpm.rb +1 -0
  150. data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
  151. data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
  152. data/lib/puppet/provider/package/windows/package.rb +9 -1
  153. data/lib/puppet/provider/package/yum.rb +14 -9
  154. data/lib/puppet/provider/service/bsd.rb +1 -1
  155. data/lib/puppet/provider/service/debian.rb +21 -0
  156. data/lib/puppet/provider/service/init.rb +6 -0
  157. data/lib/puppet/provider/service/rcng.rb +51 -0
  158. data/lib/puppet/provider/service/redhat.rb +2 -1
  159. data/lib/puppet/provider/service/smf.rb +43 -2
  160. data/lib/puppet/provider/service/src.rb +27 -0
  161. data/lib/puppet/provider/service/systemd.rb +15 -3
  162. data/lib/puppet/provider/sshkey/parsed.rb +19 -9
  163. data/lib/puppet/reference/report.rb +9 -12
  164. data/lib/puppet/reports.rb +5 -1
  165. data/lib/puppet/resource.rb +50 -73
  166. data/lib/puppet/resource/capability_finder.rb +95 -0
  167. data/lib/puppet/resource/catalog.rb +47 -7
  168. data/lib/puppet/resource/status.rb +0 -2
  169. data/lib/puppet/resource/type.rb +238 -44
  170. data/lib/puppet/resource/type_collection.rb +60 -2
  171. data/lib/puppet/settings.rb +2 -2
  172. data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
  173. data/lib/puppet/ssl/oids.rb +9 -1
  174. data/lib/puppet/transaction.rb +4 -1
  175. data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
  176. data/lib/puppet/transaction/resource_harness.rb +9 -4
  177. data/lib/puppet/type.rb +74 -3
  178. data/lib/puppet/type/augeas.rb +8 -0
  179. data/lib/puppet/type/file/source.rb +14 -12
  180. data/lib/puppet/type/user.rb +4 -2
  181. data/lib/puppet/util/windows/security.rb +4 -1
  182. data/lib/puppet/util/windows/taskscheduler.rb +1 -1
  183. data/lib/puppet/version.rb +1 -1
  184. data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
  185. data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
  186. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
  187. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
  188. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
  189. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
  190. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
  191. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
  192. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
  193. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
  194. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
  195. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
  196. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
  197. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
  198. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
  199. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
  200. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
  201. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
  202. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
  203. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
  204. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
  205. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
  206. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
  207. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
  208. data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
  209. data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
  210. data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
  211. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
  212. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
  213. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
  214. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
  215. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
  216. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
  217. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
  218. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
  219. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
  220. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
  221. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
  222. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
  223. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
  224. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
  225. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
  226. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
  227. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
  228. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
  229. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
  230. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
  231. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
  232. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
  233. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
  234. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
  235. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
  236. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
  237. data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
  238. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  239. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  240. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  241. data/spec/integration/data_binding_spec.rb +229 -0
  242. data/spec/integration/file_bucket/file_spec.rb +2 -2
  243. data/spec/integration/parser/compiler_spec.rb +23 -19
  244. data/spec/integration/parser/resource_expressions_spec.rb +4 -4
  245. data/spec/integration/parser/undef_param_spec.rb +1 -1
  246. data/spec/integration/resource/catalog_spec.rb +1 -1
  247. data/spec/integration/type/package_spec.rb +2 -0
  248. data/spec/integration/util/windows/security_spec.rb +18 -0
  249. data/spec/lib/matchers/include_in_order.rb +2 -2
  250. data/spec/shared_behaviours/iterative_functions.rb +8 -8
  251. data/spec/spec_helper.rb +7 -0
  252. data/spec/unit/agent/locker_spec.rb +4 -4
  253. data/spec/unit/agent_spec.rb +0 -8
  254. data/spec/unit/application/agent_spec.rb +5 -0
  255. data/spec/unit/application/apply_spec.rb +8 -0
  256. data/spec/unit/application/filebucket_spec.rb +87 -1
  257. data/spec/unit/application/lookup_spec.rb +195 -0
  258. data/spec/unit/appmgmt_spec.rb +657 -0
  259. data/spec/unit/capability_spec.rb +414 -0
  260. data/spec/unit/configurer_spec.rb +7 -1
  261. data/spec/unit/context/trusted_information_spec.rb +24 -1
  262. data/spec/unit/daemon_spec.rb +18 -8
  263. data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
  264. data/spec/unit/file_bucket/dipper_spec.rb +210 -1
  265. data/spec/unit/functions/assert_type_spec.rb +5 -7
  266. data/spec/unit/functions/defined_spec.rb +2 -2
  267. data/spec/unit/functions/epp_spec.rb +2 -2
  268. data/spec/unit/functions/lookup_spec.rb +200 -9
  269. data/spec/unit/functions/regsubst_spec.rb +17 -8
  270. data/spec/unit/functions/scanf_spec.rb +1 -1
  271. data/spec/unit/functions/split_spec.rb +2 -2
  272. data/spec/unit/functions/versioncmp_spec.rb +36 -0
  273. data/spec/unit/functions4_spec.rb +58 -72
  274. data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
  275. data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
  276. data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
  277. data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
  278. data/spec/unit/indirector/request_spec.rb +8 -8
  279. data/spec/unit/info_service_spec.rb +236 -0
  280. data/spec/unit/module_tool/metadata_spec.rb +31 -2
  281. data/spec/unit/network/authconfig_spec.rb +62 -32
  282. data/spec/unit/network/authorization_spec.rb +30 -2
  283. data/spec/unit/network/http/connection_spec.rb +14 -19
  284. data/spec/unit/parser/compiler_spec.rb +86 -2
  285. data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
  286. data/spec/unit/parser/resource_spec.rb +2 -20
  287. data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
  288. data/spec/unit/pops/binder/injector_spec.rb +3 -3
  289. data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
  290. data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
  291. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +19 -11
  292. data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
  293. data/spec/unit/pops/label_provider_spec.rb +5 -1
  294. data/spec/unit/pops/parser/lexer2_spec.rb +33 -7
  295. data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
  296. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
  297. data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
  298. data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
  299. data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
  300. data/spec/unit/pops/parser/parser_spec.rb +18 -0
  301. data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
  302. data/spec/unit/pops/types/type_factory_spec.rb +12 -12
  303. data/spec/unit/pops/types/type_parser_spec.rb +7 -12
  304. data/spec/unit/pops/validator/validator_spec.rb +25 -0
  305. data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
  306. data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
  307. data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
  308. data/spec/unit/provider/package/dnf_spec.rb +92 -0
  309. data/spec/unit/provider/package/gem_spec.rb +7 -0
  310. data/spec/unit/provider/package/rpm_spec.rb +25 -2
  311. data/spec/unit/provider/package/windows/package_spec.rb +41 -0
  312. data/spec/unit/provider/package/yum_spec.rb +21 -13
  313. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
  314. data/spec/unit/provider/service/debian_spec.rb +27 -0
  315. data/spec/unit/provider/service/rcng_spec.rb +41 -0
  316. data/spec/unit/provider/service/redhat_spec.rb +8 -1
  317. data/spec/unit/provider/service/smf_spec.rb +30 -5
  318. data/spec/unit/provider/service/src_spec.rb +19 -4
  319. data/spec/unit/provider/service/systemd_spec.rb +78 -29
  320. data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
  321. data/spec/unit/reports_spec.rb +10 -0
  322. data/spec/unit/resource/capability_finder_spec.rb +56 -0
  323. data/spec/unit/resource/catalog_spec.rb +31 -8
  324. data/spec/unit/resource/type_collection_spec.rb +23 -2
  325. data/spec/unit/resource/type_spec.rb +1 -1
  326. data/spec/unit/resource_spec.rb +22 -4
  327. data/spec/unit/settings_spec.rb +90 -1
  328. data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
  329. data/spec/unit/ssl/oids_spec.rb +8 -0
  330. data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
  331. data/spec/unit/transaction/report_spec.rb +24 -1
  332. data/spec/unit/type/package_spec.rb +1 -0
  333. data/spec/unit/type/user_spec.rb +14 -7
  334. data/spec/unit/type_spec.rb +1 -1
  335. metadata +169 -5
  336. data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
  337. data/spec/integration/data_binding.rb +0 -104
@@ -45,15 +45,24 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
45
45
  end
46
46
 
47
47
  describe "when setting signal traps" do
48
- signals = {:INT => :stop, :TERM => :stop }
49
- signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}) unless Puppet.features.microsoft_windows?
50
- signals.each do |signal, method|
51
- it "should log and call #{method} when it receives #{signal}" do
52
- Signal.expects(:trap).with(signal).yields
48
+ [:INT, :TERM].each do |signal|
49
+ it "logs a notice and exits when sent #{signal}" do
50
+ Signal.stubs(:trap).with(signal).yields
51
+ Puppet.expects(:notice).with("Caught #{signal}; exiting")
52
+ daemon.expects(:stop)
53
53
 
54
- Puppet.expects(:notice)
54
+ daemon.set_signal_traps
55
+ end
56
+ end
57
+
58
+ {:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}.each do |signal, method|
59
+ it "logs a notice and remembers to call #{method} when it receives #{signal}" do
60
+ Signal.stubs(:trap).with(signal).yields
61
+ Puppet.expects(:notice).with("Caught #{signal}; storing #{method}")
55
62
 
56
63
  daemon.set_signal_traps
64
+
65
+ expect(daemon.signals).to eq([method])
57
66
  end
58
67
  end
59
68
  end
@@ -176,7 +185,8 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
176
185
  end
177
186
 
178
187
  it "should do nothing if the agent is running" do
179
- agent.expects(:running?).returns true
188
+ agent.expects(:run).with({:splay => false}).raises Puppet::LockError, 'Failed to aquire lock'
189
+ Puppet.expects(:notice).with('Not triggering already-running agent')
180
190
 
181
191
  daemon.agent = agent
182
192
 
@@ -184,8 +194,8 @@ describe Puppet::Daemon, :unless => Puppet.features.microsoft_windows? do
184
194
  end
185
195
 
186
196
  it "should run the agent if one is available and it is not running" do
187
- agent.expects(:running?).returns false
188
197
  agent.expects(:run).with({:splay => false})
198
+ Puppet.expects(:notice).with('Not triggering already-running agent').never
189
199
 
190
200
  daemon.agent = agent
191
201
 
@@ -0,0 +1,201 @@
1
+ #! /usr/bin/env ruby
2
+ require 'spec_helper'
3
+ require 'puppet_spec/compiler'
4
+
5
+ describe "when using a hiera data provider" do
6
+ include PuppetSpec::Compiler
7
+
8
+ # There is a fully configured 'sample' environment in fixtures at this location
9
+ let(:environmentpath) { parent_fixture('environments') }
10
+
11
+ let(:facts) { Puppet::Node::Facts.new("facts", {}) }
12
+
13
+ around(:each) do |example|
14
+ # Initialize settings to get a full compile as close as possible to a real
15
+ # environment load
16
+ Puppet.settings.initialize_global_settings
17
+ # Initialize loaders based on the environmentpath. It does not work to
18
+ # just set the setting environmentpath for some reason - this achieves the same:
19
+ # - first a loader is created, loading directory environments from the fixture (there is
20
+ # one environment, 'sample', which will be loaded since the node references this
21
+ # environment by name).
22
+ # - secondly, the created env loader is set as 'environments' in the puppet context.
23
+ #
24
+ loader = Puppet::Environments::Directories.new(environmentpath, [])
25
+ Puppet.override(:environments => loader) do
26
+ example.run
27
+ end
28
+ end
29
+
30
+ def compile_and_get_notifications(environment, code = nil)
31
+ compile(environment, code).resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
32
+ end
33
+
34
+ def compile(environment, code = nil)
35
+ Puppet[:code] = code if code
36
+ node = Puppet::Node.new("testnode", :facts => facts, :environment => environment)
37
+ compiler = Puppet::Parser::Compiler.new(node)
38
+ block_given? ? compiler.compile() { |catalog| yield(compiler); catalog } : compiler.compile()
39
+ end
40
+
41
+ it 'uses default configuration for environment and module data' do
42
+ resources = compile_and_get_notifications('hiera_defaults')
43
+ expect(resources).to include('module data param_a is 100, param default is 200, env data param_c is 300')
44
+ end
45
+
46
+ it 'reads hiera.yaml in environment root and configures multiple json and yaml providers' do
47
+ resources = compile_and_get_notifications('hiera_env_config')
48
+ expect(resources).to include('env data param_a is 10, env data param_b is 20, env data param_c is 30, env data param_d is 40, env data param_e is 50')
49
+ end
50
+
51
+ it 'reads hiera.yaml in module root and configures multiple json and yaml providers' do
52
+ resources = compile_and_get_notifications('hiera_module_config')
53
+ expect(resources).to include('module data param_a is 100, module data param_b is 200, module data param_c is 300, module data param_d is 400, module data param_e is 500')
54
+ end
55
+
56
+ it 'does not perform merge of values declared in environment and module when resolving parameters' do
57
+ resources = compile_and_get_notifications('hiera_misc')
58
+ expect(resources).to include('env 1, ')
59
+ end
60
+
61
+ it 'performs hash merge of values declared in environment and module' do
62
+ resources = compile_and_get_notifications('hiera_misc', '$r = lookup(one::test::param, Hash[String,String], hash) notify{"${r[key1]}, ${r[key2]}":}')
63
+ expect(resources).to include('env 1, module 2')
64
+ end
65
+
66
+ it 'performs unique merge of values declared in environment and module' do
67
+ resources = compile_and_get_notifications('hiera_misc', '$r = lookup(one::array, Array[String], unique) notify{"${r}":}')
68
+ expect(resources.size).to eq(1)
69
+ expect(resources[0][1..-2].split(', ')).to contain_exactly('first', 'second', 'third', 'fourth')
70
+ end
71
+
72
+ it 'performs merge found in lookup_options in environment of values declared in environment and module' do
73
+ resources = compile_and_get_notifications('hiera_misc', 'include one::lopts_test')
74
+ expect(resources.size).to eq(1)
75
+ expect(resources[0]).to eq('A, B, C, MA, MB, MC')
76
+ end
77
+
78
+ it 'performs merge found in lookup_options in module of values declared in environment and module' do
79
+ resources = compile_and_get_notifications('hiera_misc', 'include one::loptsm_test')
80
+ expect(resources.size).to eq(1)
81
+ expect(resources[0]).to eq('A, B, C, MA, MB, MC')
82
+ end
83
+
84
+ it "can lookup the 'lookup_options' hash as a regular value" do
85
+ resources = compile_and_get_notifications('hiera_misc', '$r = lookup(lookup_options, Hash[String,Hash[String,String]], hash) notify{"${r[one::lopts_test::hash][merge]}":}')
86
+ expect(resources.size).to eq(1)
87
+ expect(resources[0]).to eq('deep')
88
+ end
89
+
90
+ it 'does find unqualified keys in the environment' do
91
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(ukey1):}')
92
+ expect(resources).to include('Some value')
93
+ end
94
+
95
+ it 'does not find unqualified keys in the module' do
96
+ expect do
97
+ compile_and_get_notifications('hiera_misc', 'notify{lookup(ukey2):}')
98
+ end.to raise_error(Puppet::ParseError, /did not find a value for the name 'ukey2'/)
99
+ end
100
+
101
+ it 'can use interpolation lookup method "alias"' do
102
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_alias):}')
103
+ expect(resources).to include('Value from interpolation with alias')
104
+ end
105
+
106
+ it 'can use interpolation lookup method "lookup"' do
107
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_lookup):}')
108
+ expect(resources).to include('Value from interpolation with lookup')
109
+ end
110
+
111
+ it 'can use interpolation lookup method "hiera"' do
112
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_hiera):}')
113
+ expect(resources).to include('Value from interpolation with hiera')
114
+ end
115
+
116
+ it 'can use interpolation lookup method "literal"' do
117
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_literal):}')
118
+ expect(resources).to include('Value from interpolation with literal')
119
+ end
120
+
121
+ it 'can use interpolation lookup method "scope"' do
122
+ resources = compile_and_get_notifications('hiera_misc', '$target_scope = "with scope" notify{lookup(km_scope):}')
123
+ expect(resources).to include('Value from interpolation with scope')
124
+ end
125
+
126
+ it 'can use interpolation using default lookup method (scope)' do
127
+ resources = compile_and_get_notifications('hiera_misc', '$target_default = "with default" notify{lookup(km_default):}')
128
+ expect(resources).to include('Value from interpolation with default')
129
+ end
130
+
131
+ it 'performs lookup using qualified expressions in interpolation' do
132
+ resources = compile_and_get_notifications('hiera_misc', "$os = { name => 'Fedora' } notify{lookup(km_qualified):}")
133
+ expect(resources).to include('Value from qualified interpolation OS = Fedora')
134
+ end
135
+
136
+ it 'can have multiple interpolate expressions in one value' do
137
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_multi):}')
138
+ expect(resources).to include('cluster/%{::cluster}/%{role}')
139
+ end
140
+
141
+ it 'performs single quoted interpolation' do
142
+ resources = compile_and_get_notifications('hiera_misc', 'notify{lookup(km_sqalias):}')
143
+ expect(resources).to include('Value from interpolation with alias')
144
+ end
145
+
146
+ it 'traps endless interpolate recursion' do
147
+ expect do
148
+ compile_and_get_notifications('hiera_misc', '$r1 = "%{r2}" $r2 = "%{r1}" notify{lookup(recursive):}')
149
+ end.to raise_error(Puppet::DataBinding::RecursiveLookupError, /detected in \[recursive, r1, r2\]/)
150
+ end
151
+
152
+ it 'traps bad alias declarations' do
153
+ expect do
154
+ compile_and_get_notifications('hiera_misc', "$r1 = 'Alias within string %{alias(\"r2\")}' $r2 = '%{r1}' notify{lookup(recursive):}")
155
+ end.to raise_error(Puppet::DataBinding::LookupError, /'alias' interpolation is only permitted if the expression is equal to the entire string/)
156
+ end
157
+
158
+ it 'reports syntax errors for JSON files' do
159
+ expect do
160
+ compile_and_get_notifications('hiera_bad_syntax_json')
161
+ end.to raise_error(Puppet::DataBinding::LookupError, /Unable to parse \(#{environmentpath}[^)]+\):/)
162
+ end
163
+
164
+ it 'reports syntax errors for YAML files' do
165
+ expect do
166
+ compile_and_get_notifications('hiera_bad_syntax_yaml')
167
+ end.to raise_error(Puppet::DataBinding::LookupError, /Unable to parse \(#{environmentpath}[^)]+\):/)
168
+ end
169
+
170
+ describe 'when using explain' do
171
+ it 'will report config path (original and resolved), data path (original and resolved), and interpolation (before and after)' do
172
+ compile('hiera_misc', '$target_scope = "with scope"') do |compiler|
173
+ lookup_invocation = Puppet::Pops::Lookup::Invocation.new(compiler.topscope, {}, {}, true)
174
+ value = Puppet::Pops::Lookup.lookup('km_scope', nil, nil, nil, nil, lookup_invocation)
175
+ expect(lookup_invocation.explainer.to_s).to eq(<<EOS)
176
+ Merge strategy first
177
+ Data Binding "hiera"
178
+ No such key: "km_scope"
179
+ Data Provider "Hiera Data Provider, version 4"
180
+ ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
181
+ Data Provider "common"
182
+ Path "#{environmentpath}/hiera_misc/data/common.yaml"
183
+ Original path: common
184
+ Interpolation on "Value from interpolation %{scope("target_scope")}"
185
+ Global Scope"
186
+ Found key: "target_scope" value: "with scope"
187
+ Found key: "km_scope" value: "Value from interpolation with scope"
188
+ Merged result: "Value from interpolation with scope"
189
+ EOS
190
+ end
191
+ end
192
+ end
193
+ def parent_fixture(dir_name)
194
+ File.absolute_path(File.join(my_fixture_dir(), "../#{dir_name}"))
195
+ end
196
+
197
+ def resources_in(catalog)
198
+ catalog.resources.map(&:ref)
199
+ end
200
+
201
+ end
@@ -72,6 +72,216 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
72
72
  expect { @dipper.backup(file) }.to raise_error(Puppet::Error)
73
73
  end
74
74
 
75
+ describe "when diffing on a local filebucket" do
76
+ describe "in non-windows environments", :unless => Puppet.features.microsoft_windows? do
77
+ with_digest_algorithms do
78
+
79
+ it "should fail in an informative way when one or more checksum doesn't exists" do
80
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => tmpdir("bucket"))
81
+ wrong_checksum = "DEADBEEF"
82
+
83
+ # First checksum fails
84
+ expect { @dipper.diff(wrong_checksum, "WEIRDCKSM", nil, nil) }.to raise_error(RuntimeError, "Invalid checksum #{wrong_checksum.inspect}")
85
+
86
+ file = make_tmp_file(plaintext)
87
+ @dipper.backup(file)
88
+
89
+ #Diff_with checksum fails
90
+ expect { @dipper.diff(checksum, wrong_checksum, nil, nil) }.to raise_error(RuntimeError, "could not find diff_with #{wrong_checksum}")
91
+ end
92
+
93
+ it "should properly diff files on the filebucket" do
94
+ file1 = make_tmp_file("OriginalContent")
95
+ file2 = make_tmp_file("ModifiedContent")
96
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => tmpdir("bucket"))
97
+ checksum1 = @dipper.backup(file1)
98
+ checksum2 = @dipper.backup(file2)
99
+
100
+ # Diff without the context
101
+ diff12 = `diff -uN #{file1} #{file2} | sed '1,2d'`
102
+ diff21 = `diff -uN #{file2} #{file1} | sed '1,2d'`
103
+
104
+ expect(@dipper.diff(checksum1, checksum2, nil, nil)).to include(diff12)
105
+ expect(@dipper.diff(checksum1, nil, nil, file2)).to include(diff12)
106
+ expect(@dipper.diff(nil, checksum2, file1, nil)).to include(diff12)
107
+ expect(@dipper.diff(nil, nil, file1, file2)).to include(diff12)
108
+ expect(@dipper.diff(checksum2, checksum1, nil, nil)).to include(diff21)
109
+ expect(@dipper.diff(checksum2, nil, nil, file1)).to include(diff21)
110
+ expect(@dipper.diff(nil, checksum1, file2, nil)).to include(diff21)
111
+ expect(@dipper.diff(nil, nil, file2, file1)).to include(diff21)
112
+
113
+ end
114
+ end
115
+ describe "in windows environment", :if => Puppet.features.microsoft_windows? do
116
+ it "should fail in an informative way when trying to diff" do
117
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => tmpdir("bucket"))
118
+ wrong_checksum = "DEADBEEF"
119
+
120
+ # First checksum fails
121
+ expect { @dipper.diff(wrong_checksum, "WEIRDCKSM", nil, nil) }.to raise_error(RuntimeError, "Diff is not supported on this platform")
122
+
123
+ # Diff_with checksum fails
124
+ expect { @dipper.diff(checksum, wrong_checksum, nil, nil) }.to raise_error(RuntimeError, "Diff is not supported on this platform")
125
+ end
126
+ end
127
+ end
128
+ end
129
+ it "should fail in an informative way when there are failures listing files on the server" do
130
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => "/unexistent/bucket")
131
+ Puppet::FileBucket::File.indirection.expects(:find).returns nil
132
+
133
+ expect { @dipper.list(nil, nil) }.to raise_error(Puppet::Error)
134
+ end
135
+
136
+ describe "listing files in local filebucket" do
137
+ with_digest_algorithms do
138
+ it "should list all files present" do
139
+ Puppet[:bucketdir] = "/my/bucket"
140
+ file_bucket = tmpdir("bucket")
141
+
142
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => file_bucket)
143
+
144
+ onehour=60*60
145
+ twohours=onehour*2
146
+
147
+ #First File
148
+ file1 = make_tmp_file(plaintext)
149
+ real_path = Pathname.new(file1).realpath
150
+ expect(digest(plaintext)).to eq(checksum)
151
+ expect(@dipper.backup(file1)).to eq(checksum)
152
+ expected_list1_1 = /#{checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
153
+
154
+ File.open(file1, 'w') {|f| f.write("Blahhhh")}
155
+ new_checksum = digest("Blahhhh")
156
+ expect(@dipper.backup(file1)).to eq(new_checksum)
157
+ expected_list1_2 = /#{new_checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
158
+
159
+ #Second File
160
+ content = "DummyFileWithNonSenseTextInIt"
161
+ file2 = make_tmp_file(content)
162
+ real_path = Pathname.new(file2).realpath
163
+ checksum = digest(content)
164
+ expect(@dipper.backup(file2)).to eq(checksum)
165
+ expected_list2 = /#{checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
166
+
167
+ #Third file : Same as the first one with a different path
168
+ file3 = make_tmp_file(plaintext)
169
+ real_path = Pathname.new(file3).realpath
170
+ checksum = digest(plaintext)
171
+ expect(digest(plaintext)).to eq(checksum)
172
+ expect(@dipper.backup(file3)).to eq(checksum)
173
+ date = Time.now
174
+ expected_list3 = /#{checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
175
+
176
+ result = @dipper.list(nil, nil)
177
+ expect(result).to match(expected_list1_1)
178
+ expect(result).to match(expected_list1_2)
179
+ expect(result).to match(expected_list2)
180
+ expect(result).to match(expected_list3)
181
+ end
182
+
183
+ it "should filter with the provided dates" do
184
+ Puppet[:bucketdir] = "/my/bucket"
185
+ file_bucket = tmpdir("bucket")
186
+
187
+ twentyminutes=60*20
188
+ thirtyminutes=60*30
189
+ onehour=60*60
190
+ twohours=onehour*2
191
+ threehours=onehour*3
192
+
193
+ # First File created now
194
+ @dipper = Puppet::FileBucket::Dipper.new(:Path => file_bucket)
195
+ file1 = make_tmp_file(plaintext)
196
+ real_path = Pathname.new(file1).realpath
197
+
198
+ expect(digest(plaintext)).to eq(checksum)
199
+ expect(@dipper.backup(file1)).to eq(checksum)
200
+ expected_list1 = /#{checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
201
+
202
+ # Second File created an hour ago
203
+ content = "DummyFileWithNonSenseTextInIt"
204
+ file2 = make_tmp_file(content)
205
+ real_path = Pathname.new(file2).realpath
206
+ checksum = digest(content)
207
+ expect(@dipper.backup(file2)).to eq(checksum)
208
+
209
+ # Modify mtime of the second file to be an hour ago
210
+ onehourago = Time.now - onehour
211
+ bucketed_paths_file = Dir.glob("#{file_bucket}/**/#{checksum}/paths")
212
+ FileUtils.touch(bucketed_paths_file, :mtime => onehourago)
213
+ expected_list2 = /#{checksum} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} #{real_path}\n/
214
+
215
+ now = Time.now
216
+
217
+ #Future
218
+ expect(@dipper.list((now + threehours).strftime("%F %T"), nil )).to eq("")
219
+
220
+ #Epoch -> Future = Everything (Sorted (desc) by date)
221
+ expect(@dipper.list(nil, (now + twohours).strftime("%F %T"))).to match(expected_list1)
222
+ expect(@dipper.list(nil, (now + twohours).strftime("%F %T"))).to match(expected_list2)
223
+
224
+ #Now+1sec -> Future = Nothing
225
+ expect(@dipper.list((now + 1).strftime("%F %T"), (now + twohours).strftime("%F %T"))).to eq("")
226
+
227
+ #Now-30mins -> Now-20mins = Nothing
228
+ expect(@dipper.list((now - thirtyminutes).strftime("%F %T"), (now - twentyminutes).strftime("%F %T"))).to eq("")
229
+
230
+ #Now-2hours -> Now-30mins = Second file only
231
+ expect(@dipper.list((now - twohours).strftime("%F %T"), (now - thirtyminutes).strftime("%F %T"))).to match(expected_list2)
232
+ expect(@dipper.list((now - twohours).strftime("%F %T"), (now - thirtyminutes).strftime("%F %T"))).not_to match(expected_list1)
233
+
234
+ #Now-30minutes -> Now = First file only
235
+ expect(@dipper.list((now - thirtyminutes).strftime("%F %T"), now.strftime("%F %T"))).to match(expected_list1)
236
+ expect(@dipper.list((now - thirtyminutes).strftime("%F %T"), now.strftime("%F %T"))).not_to match(expected_list2)
237
+ end
238
+ end
239
+ end
240
+
241
+ describe "when diffing on a remote filebucket" do
242
+ describe "in non-windows environments", :unless => Puppet.features.microsoft_windows? do
243
+ with_digest_algorithms do
244
+ it "should fail in an informative way when one or more checksum doesn't exists" do
245
+ @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337")
246
+ wrong_checksum = "DEADBEEF"
247
+
248
+ Puppet::FileBucketFile::Rest.any_instance.expects(:find).returns(nil)
249
+ expect { @dipper.diff(wrong_checksum, "WEIRDCKSM", nil, nil) }.to raise_error(Puppet::Error, "Failed to diff files")
250
+
251
+ end
252
+
253
+ it "should properly diff files on the filebucket" do
254
+ @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337")
255
+
256
+ Puppet::FileBucketFile::Rest.any_instance.expects(:find).returns("Probably valid diff")
257
+
258
+ expect(@dipper.diff("checksum1", "checksum2", nil, nil)).to eq("Probably valid diff")
259
+ end
260
+ end
261
+ end
262
+
263
+ describe "in windows environment", :if => Puppet.features.microsoft_windows? do
264
+ it "should fail in an informative way when trying to diff" do
265
+ @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337")
266
+ wrong_checksum = "DEADBEEF"
267
+
268
+ expect { @dipper.diff(wrong_checksum, "WEIRDCKSM", nil, nil) }.to raise_error(RuntimeError, "Diff is not supported on this platform")
269
+
270
+ expect { @dipper.diff(wrong_checksum, nil, nil, nil) }.to raise_error(RuntimeError, "Diff is not supported on this platform")
271
+ end
272
+ end
273
+ end
274
+
275
+ describe "listing files in remote filebucket" do
276
+ it "is not allowed" do
277
+ @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port=> "31337")
278
+
279
+ expect {
280
+ @dipper.list(nil, nil)
281
+ }.to raise_error(Puppet::Error, "Listing remote file buckets is not allowed")
282
+ end
283
+ end
284
+
75
285
  describe "backing up and retrieving local files" do
76
286
  with_digest_algorithms do
77
287
  it "should backup files to a local bucket" do
@@ -173,4 +383,3 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
173
383
  end
174
384
  end
175
385
  end
176
-