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
@@ -22,7 +22,7 @@ describe provider_class do
22
22
  end
23
23
 
24
24
  before do
25
- provider.stubs(:yum).returns 'yum'
25
+ provider_class.stubs(:command).with(:cmd).returns('/usr/bin/yum')
26
26
  provider.stubs(:rpm).returns 'rpm'
27
27
  provider.stubs(:get).with(:version).returns '1'
28
28
  provider.stubs(:get).with(:release).returns '1'
@@ -186,7 +186,7 @@ describe provider_class do
186
186
 
187
187
  it 'should call yum install for :installed' do
188
188
  resource.stubs(:should).with(:ensure).returns :installed
189
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, name)
189
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'mypackage'])
190
190
  provider.install
191
191
  end
192
192
 
@@ -197,7 +197,7 @@ describe provider_class do
197
197
 
198
198
  it 'should catch yum install failures when status code is wrong' do
199
199
  resource.stubs(:should).with(:ensure).returns :installed
200
- provider.expects(:yum).with('-e', '0', '-y', :install, name).returns("No package #{name} available.")
200
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-e', '0', '-y', :install, name]).returns("No package #{name} available.")
201
201
  expect {
202
202
  provider.install
203
203
  }.to raise_error(Puppet::Error, "Could not find package #{name}")
@@ -212,7 +212,7 @@ describe provider_class do
212
212
  it 'should be able to set version' do
213
213
  version = '1.2'
214
214
  resource[:ensure] = version
215
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, "#{name}-#{version}")
215
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "#{name}-#{version}"])
216
216
  provider.stubs(:query).returns :ensure => version
217
217
  provider.install
218
218
  end
@@ -220,6 +220,7 @@ describe provider_class do
220
220
  it 'should handle partial versions specified' do
221
221
  version = '1.3.4'
222
222
  resource[:ensure] = version
223
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'mypackage-1.3.4'])
223
224
  provider.stubs(:query).returns :ensure => '1.3.4-1.el6'
224
225
  provider.install
225
226
  end
@@ -228,7 +229,7 @@ describe provider_class do
228
229
  current_version = '1.2'
229
230
  version = '1.0'
230
231
  resource[:ensure] = '1.0'
231
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :downgrade, "#{name}-#{version}")
232
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :downgrade, "#{name}-#{version}"])
232
233
  provider.stubs(:query).returns(:ensure => current_version).then.returns(:ensure => version)
233
234
  provider.install
234
235
  end
@@ -237,22 +238,22 @@ describe provider_class do
237
238
  resource[:ensure] = :installed
238
239
  resource[:install_options] = ['-t', {'-x' => 'expackage'}]
239
240
 
240
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', ['-t', '-x=expackage'], :install, name)
241
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', ['-t', '-x=expackage'], :install, name])
241
242
  provider.install
242
243
  end
243
244
 
244
245
  it 'allow virtual packages' do
245
246
  resource[:ensure] = :installed
246
247
  resource[:allow_virtual] = true
247
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :list, name).never
248
- provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, name)
248
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :list, name]).never
249
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, name])
249
250
  provider.install
250
251
  end
251
252
  end
252
253
 
253
254
  describe 'when uninstalling' do
254
255
  it 'should use erase to purge' do
255
- provider.expects(:yum).with('-y', :erase, name)
256
+ Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-y', :erase, name])
256
257
  provider.purge
257
258
  end
258
259
  end
@@ -397,10 +398,6 @@ describe provider_class do
397
398
  end
398
399
 
399
400
  describe "executing yum check-update" do
400
- before do
401
- described_class.stubs(:command).with(:yum).returns '/usr/bin/yum'
402
- end
403
-
404
401
  it "passes repos to enable to 'yum check-update'" do
405
402
  Puppet::Util::Execution.expects(:execute).with do |args, *rest|
406
403
  expect(args).to eq %w[/usr/bin/yum check-update --enablerepo=updates --enablerepo=centosplus]
@@ -497,6 +494,17 @@ describe provider_class do
497
494
  expect(output).not_to include("1:1.0.0-14.git20150121.b4ea599c.el7")
498
495
  end
499
496
  end
497
+ describe "with security notifications" do
498
+ let(:check_update) { File.read(my_fixture('yum-check-update-security.txt')) }
499
+ let(:output) { described_class.parse_updates(check_update) }
500
+
501
+ it "ignores all entries including and after 'Security'" do
502
+ expect(output).not_to include("Security")
503
+ end
504
+ it "includes updates before 'Security'" do
505
+ expect(output).to include("yum-plugin-fastestmirror.noarch")
506
+ end
507
+ end
500
508
  end
501
509
 
502
510
  describe "parsing a line from yum check-update" do
@@ -600,6 +600,16 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
600
600
 
601
601
  expect(resource.provider.exists?).to eq(true)
602
602
  end
603
+
604
+ it "uses SystemRoot in the path of Task folder" do
605
+ Win32::TaskScheduler.unstub(:new)
606
+ exists_test_task = Win32::TaskScheduler.new
607
+ Dir.stubs(:foreach).with('D:/WinNT/Tasks').returns([])
608
+
609
+ Puppet::Util.withenv('SystemRoot' => 'D:/WinNT') do
610
+ exists_test_task.exists?('Test Task')
611
+ end
612
+ end
603
613
  end
604
614
 
605
615
  describe '#clear_task' do
@@ -141,4 +141,31 @@ describe provider_class do
141
141
  end
142
142
  end
143
143
 
144
+ describe "when checking service status" do
145
+ context "On systems which use the systemd-sysvinit compatibility layer" do
146
+ it "should call systemctl to determine running status in Debian" do
147
+ Facter.stubs(:value).with(:operatingsystem).returns('Debian')
148
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
149
+ @resource.stubs(:[]).with(:hasstatus).returns(:true)
150
+ expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
151
+ end
152
+
153
+ it "should call systemctl to determine running status in Ubuntu" do
154
+ Facter.stubs(:value).with(:operatingsystem).returns('Ubuntu')
155
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns('15.04')
156
+ @resource.stubs(:[]).with(:hasstatus).returns(:true)
157
+ expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
158
+ end
159
+ end
160
+
161
+ context "On systems which only use sysvinit" do
162
+ it "should use the service init script" do
163
+ Facter.stubs(:value).with(:operatingsystem).returns('Debian')
164
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns('7')
165
+ @resource.stubs(:[]).with(:hasstatus).returns(:true)
166
+ @provider.stubs(:initscript).returns("/etc/init.d/script")
167
+ expect(@provider.statuscmd).to eq(["/etc/init.d/script", :status])
168
+ end
169
+ end
170
+ end
144
171
  end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+
5
+ provider_class = Puppet::Type.type(:service).provider(:rcng)
6
+
7
+ describe provider_class, :unless => Puppet.features.microsoft_windows? do
8
+ before :each do
9
+ Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class
10
+ Facter.stubs(:value).with(:operatingsystem).returns :netbsd
11
+ Facter.stubs(:value).with(:osfamily).returns 'NetBSD'
12
+ described_class.stubs(:defpath).returns('/etc/rc.d')
13
+ @provider = provider_class.new
14
+ @provider.stubs(:initscript)
15
+ end
16
+
17
+ describe "#enable" do
18
+ it "should have an enable method" do
19
+ expect(@provider).to respond_to(:enable)
20
+ end
21
+
22
+ it "should set the proper contents to enable" do
23
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
24
+ Dir.stubs(:mkdir).with('/etc/rc.conf.d')
25
+ fh = stub 'fh'
26
+ Puppet::Util.expects(:replace_file).with('/etc/rc.conf.d/sshd', 0644).yields(fh)
27
+ fh.expects(:puts).with("sshd=${sshd:=YES}\n")
28
+ provider.enable
29
+ end
30
+
31
+ it "should set the proper contents to enable when disabled" do
32
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
33
+ Dir.stubs(:mkdir).with('/etc/rc.conf.d')
34
+ File.stubs(:read).with('/etc/rc.conf.d/sshd').returns("sshd_enable=\"NO\"\n")
35
+ fh = stub 'fh'
36
+ Puppet::Util.expects(:replace_file).with('/etc/rc.conf.d/sshd', 0644).yields(fh)
37
+ fh.expects(:puts).with("sshd=${sshd:=YES}\n")
38
+ provider.enable
39
+ end
40
+ end
41
+ end
@@ -23,7 +23,7 @@ describe provider_class, :if => Puppet.features.posix? do
23
23
  Facter.stubs(:value).with(:osfamily).returns 'RedHat'
24
24
  end
25
25
 
26
- osfamily = [ 'RedHat', 'Suse' ]
26
+ osfamily = [ 'RedHat' ]
27
27
 
28
28
  osfamily.each do |osfamily|
29
29
  it "should be the default provider on #{osfamily}" do
@@ -32,6 +32,13 @@ describe provider_class, :if => Puppet.features.posix? do
32
32
  end
33
33
  end
34
34
 
35
+ it "should be the default provider on sles11" do
36
+ Facter.stubs(:value).with(:osfamily).returns(:suse)
37
+ Facter.stubs(:value).with(:operatingsystem).returns(:suse)
38
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("11")
39
+ expect(described_class.default?).to be_truthy
40
+ end
41
+
35
42
  # test self.instances
36
43
  describe "when getting all service instances" do
37
44
  before :each do
@@ -28,7 +28,7 @@ describe provider_class, :if => Puppet.features.posix? do
28
28
  end
29
29
 
30
30
  it "should get a list of services (excluding legacy)" do
31
- provider_class.expects(:svcs).with().returns File.read(my_fixture('svcs.out'))
31
+ provider_class.expects(:svcs).with('-H').returns File.read(my_fixture('svcs.out'))
32
32
  instances = provider_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
33
33
  # we dont manage legacy
34
34
  expect(instances.size).to eq(2)
@@ -99,21 +99,31 @@ describe provider_class, :if => Puppet.features.posix? do
99
99
  describe "when starting" do
100
100
  it "should enable the service if it is not enabled" do
101
101
  @provider.expects(:status).returns :stopped
102
- @provider.expects(:texecute)
102
+ @provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-s', '/system/myservice'], true)
103
+ @provider.expects(:wait).with('online')
103
104
  @provider.start
104
105
  end
105
106
 
106
107
  it "should always execute external command 'svcadm enable /system/myservice'" do
107
- @provider.stubs(:status).returns :running
108
- @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "-s", "/system/myservice"], true)
108
+ @provider.expects(:status).returns :running
109
+ @provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-s', '/system/myservice'], true)
110
+ @provider.expects(:wait).with('online')
109
111
  @provider.start
110
112
  end
111
113
 
112
114
  it "should execute external command 'svcadm clear /system/myservice' if in maintenance" do
113
115
  @provider.stubs(:status).returns :maintenance
114
116
  @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :clear, "/system/myservice"], true)
117
+ @provider.expects(:wait).with('online')
115
118
  @provider.start
116
119
  end
120
+
121
+ it "should error if timeout occurs while starting the service" do
122
+ @provider.expects(:status).returns :stopped
123
+ @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "-s", "/system/myservice"], true)
124
+ Timeout.expects(:timeout).with(60).raises(Timeout::Error)
125
+ expect { @provider.start }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
126
+ end
117
127
  end
118
128
 
119
129
  describe "when starting a service with a manifest" do
@@ -126,6 +136,7 @@ describe provider_class, :if => Puppet.features.posix? do
126
136
  it "should import the manifest if service is missing" do
127
137
  @provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
128
138
  @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "-s", "/system/myservice"], true)
139
+ @provider.expects(:wait).with('online')
129
140
  @provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
130
141
  @provider.start
131
142
  end
@@ -139,15 +150,29 @@ describe provider_class, :if => Puppet.features.posix? do
139
150
  describe "when stopping" do
140
151
  it "should execute external command 'svcadm disable /system/myservice'" do
141
152
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, "-s", "/system/myservice"], true)
153
+ @provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
142
154
  @provider.stop
143
155
  end
156
+
157
+ it "should error if timeout occurs while stopping the service" do
158
+ @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, "-s", "/system/myservice"], true)
159
+ Timeout.expects(:timeout).with(60).raises(Timeout::Error)
160
+ expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
161
+ end
144
162
  end
145
163
 
146
164
  describe "when restarting" do
147
165
  it "should call 'svcadm restart /system/myservice'" do
148
166
  @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
167
+ @provider.expects(:wait).with('online')
149
168
  @provider.restart
150
169
  end
151
- end
152
170
 
171
+ it "should error if timeout occurs while restarting the service" do
172
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
173
+ Timeout.expects(:timeout).with(60).raises(Timeout::Error)
174
+ expect { @provider.restart }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
175
+ end
176
+
177
+ end
153
178
  end
@@ -37,7 +37,7 @@ describe provider_class do
37
37
  end
38
38
 
39
39
  describe ".instances" do
40
- it "should has a .instances method" do
40
+ it "should have a .instances method" do
41
41
  expect(provider_class).to respond_to :instances
42
42
  end
43
43
 
@@ -63,15 +63,29 @@ _EOF_
63
63
  describe "when starting a service" do
64
64
  it "should execute the startsrc command" do
65
65
  @provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
66
+ @provider.expects(:status).returns :running
66
67
  @provider.start
67
68
  end
69
+
70
+ it "should error if timeout occurs while stopping the service" do
71
+ @provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
72
+ Timeout.expects(:timeout).with(60).raises(Timeout::Error)
73
+ expect { @provider.start }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
74
+ end
68
75
  end
69
76
 
70
77
  describe "when stopping a service" do
71
78
  it "should execute the stopsrc command" do
72
79
  @provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
80
+ @provider.expects(:status).returns :stopped
73
81
  @provider.stop
74
82
  end
83
+
84
+ it "should error if timeout occurs while stopping the service" do
85
+ @provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
86
+ Timeout.expects(:timeout).with(60).raises(Timeout::Error)
87
+ expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
88
+ end
75
89
  end
76
90
 
77
91
  describe "should have a set of methods" do
@@ -160,14 +174,15 @@ _EOF_
160
174
  @provider.restart
161
175
  end
162
176
 
163
- it "should execute restart which runs stopsrc then startsrc" do
177
+ it "should execute restart which runs stop then start" do
164
178
  sample_output = <<_EOF_
165
179
  #subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
166
180
  myservice::--no-daemonize:/usr/sbin/puppetd:0:0:/dev/null:/var/log/puppet.log:/var/log/puppet.log:-O:-Q:-S:0:0:20:15:9:-d:20::"
167
181
  _EOF_
182
+
168
183
  @provider.expects(:execute).with(['/usr/bin/lssrc', '-Ss', "myservice"]).returns sample_output
169
- @provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
170
- @provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
184
+ @provider.expects(:stop)
185
+ @provider.expects(:start)
171
186
  @provider.restart
172
187
  end
173
188
  end
@@ -10,7 +10,6 @@ describe Puppet::Type.type(:service).provider(:systemd) do
10
10
  described_class.stubs(:which).with('systemctl').returns '/bin/systemctl'
11
11
  end
12
12
 
13
-
14
13
  let :provider do
15
14
  described_class.new(:name => 'sshd.service')
16
15
  end
@@ -19,14 +18,14 @@ describe Puppet::Type.type(:service).provider(:systemd) do
19
18
 
20
19
  osfamily.each do |osfamily|
21
20
  it "should be the default provider on #{osfamily}" do
22
- Facter.expects(:value).with(:osfamily).returns(osfamily)
21
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
23
22
  expect(described_class.default?).to be_truthy
24
23
  end
25
24
  end
26
25
 
27
26
  it "should be the default provider on rhel7" do
28
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:redhat)
29
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("7")
27
+ Facter.stubs(:value).with(:osfamily).returns(:redhat)
28
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
30
29
  expect(described_class.default?).to be_truthy
31
30
  end
32
31
 
@@ -36,7 +35,7 @@ describe Puppet::Type.type(:service).provider(:systemd) do
36
35
  # caused short-circuiting of the logic used by default.all? in the
37
36
  # provider. As a workaround we need to use stubs() instead of
38
37
  # expects() here.
39
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:redhat)
38
+ Facter.stubs(:value).with(:osfamily).returns(:redhat)
40
39
  Facter.stubs(:value).with(:operatingsystem).returns(:redhat)
41
40
  Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
42
41
  expect(described_class.default?).not_to be_truthy
@@ -45,57 +44,64 @@ describe Puppet::Type.type(:service).provider(:systemd) do
45
44
 
46
45
  [ 17, 18, 19, 20, 21 ].each do |ver|
47
46
  it "should be the default provider on fedora#{ver}" do
48
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:redhat)
49
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:fedora)
50
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("#{ver}")
47
+ Facter.stubs(:value).with(:osfamily).returns(:redhat)
48
+ Facter.stubs(:value).with(:operatingsystem).returns(:fedora)
49
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
51
50
  expect(described_class.default?).to be_truthy
52
51
  end
53
52
  end
54
53
 
55
54
  it "should be the default provider on sles12" do
56
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:suse)
57
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("12")
55
+ Facter.stubs(:value).with(:osfamily).returns(:suse)
56
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("12")
58
57
  expect(described_class.default?).to be_truthy
59
58
  end
60
59
 
61
60
  it "should be the default provider on opensuse13" do
62
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:suse)
63
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("13")
61
+ Facter.stubs(:value).with(:osfamily).returns(:suse)
62
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("13")
64
63
  expect(described_class.default?).to be_truthy
65
64
  end
66
65
 
67
- it "should not be the default provider on sles11" do
68
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:suse)
69
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:suse)
70
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("11")
71
- expect(described_class.default?).not_to be_truthy
66
+ # tumbleweed is a rolling release with date-based major version numbers
67
+ it "should be the default provider on tumbleweed" do
68
+ Facter.stubs(:value).with(:osfamily).returns(:suse)
69
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("20150829")
70
+ expect(described_class.default?).to be_truthy
71
+ end
72
+
73
+ # leap is the next generation suse release
74
+ it "should be the default provider on leap" do
75
+ Facter.stubs(:value).with(:osfamily).returns(:suse)
76
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("42")
77
+ expect(described_class.default?).to be_truthy
72
78
  end
73
79
 
74
80
  it "should not be the default provider on debian7" do
75
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian)
76
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:debian)
77
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("7")
81
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
82
+ Facter.stubs(:value).with(:operatingsystem).returns(:debian)
83
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
78
84
  expect(described_class.default?).not_to be_truthy
79
85
  end
80
86
 
81
87
  it "should be the default provider on debian8" do
82
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian)
83
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:debian)
84
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("8")
88
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
89
+ Facter.stubs(:value).with(:operatingsystem).returns(:debian)
90
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("8")
85
91
  expect(described_class.default?).to be_truthy
86
92
  end
87
93
 
88
94
  it "should not be the default provider on ubuntu14.04" do
89
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian)
90
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:ubuntu)
91
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("14.04")
95
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
96
+ Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
97
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("14.04")
92
98
  expect(described_class.default?).not_to be_truthy
93
99
  end
94
100
 
95
101
  it "should be the default provider on ubuntu15.04" do
96
- Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian)
97
- Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:ubuntu)
98
- Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("15.04")
102
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
103
+ Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
104
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("15.04")
99
105
  expect(described_class.default?).to be_truthy
100
106
  end
101
107
 
@@ -264,6 +270,49 @@ describe Puppet::Type.type(:service).provider(:systemd) do
264
270
  end
265
271
  end
266
272
 
273
+ describe "#debian_enabled?" do
274
+ [104, 106].each do |status|
275
+ it "should return true when invoke-rc.d returns #{status}" do
276
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
277
+ provider.stubs(:system)
278
+ $CHILD_STATUS.expects(:exitstatus).returns(status)
279
+ expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:true)
280
+ end
281
+ end
282
+
283
+ [101, 105].each do |status|
284
+ it "should return true when status is #{status} and there are at least 4 start links" do
285
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
286
+ provider.stubs(:system)
287
+ provider.expects(:get_start_link_count).returns(4)
288
+ $CHILD_STATUS.expects(:exitstatus).twice.returns(status)
289
+ expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:true)
290
+ end
291
+
292
+ it "should return false when status is #{status} and there are less than 4 start links" do
293
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
294
+ provider.stubs(:system)
295
+ provider.expects(:get_start_link_count).returns(1)
296
+ $CHILD_STATUS.expects(:exitstatus).twice.returns(status)
297
+ expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:false)
298
+ end
299
+ end
300
+ end
301
+
302
+ describe "#get_start_link_count" do
303
+ it "should strip the '.service' from the search if present in the resource name" do
304
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
305
+ Dir.expects(:glob).with("/etc/rc*.d/S??sshd").returns(['files'])
306
+ provider.get_start_link_count
307
+ end
308
+
309
+ it "should use the full service name if it does not include '.service'" do
310
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
311
+ Dir.expects(:glob).with("/etc/rc*.d/S??sshd").returns(['files'])
312
+ provider.get_start_link_count
313
+ end
314
+ end
315
+
267
316
  it "(#16451) has command systemctl without being fully qualified" do
268
317
  expect(described_class.instance_variable_get(:@commands)).to include(:systemctl => 'systemctl')
269
318
  end