puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (342) hide show
  1. data/CONTRIBUTING.md +5 -0
  2. data/Gemfile +17 -9
  3. data/README.md +1 -0
  4. data/conf/fileserver.conf +4 -3
  5. data/ext/README.environment +8 -0
  6. data/ext/build_defaults.yaml +1 -1
  7. data/ext/debian/control +2 -2
  8. data/ext/debian/puppet-common.dirs +4 -0
  9. data/ext/debian/rules +4 -0
  10. data/ext/emacs/puppet-mode-init.el +1 -1
  11. data/ext/emacs/puppet-mode.el +36 -17
  12. data/ext/redhat/client.init +3 -3
  13. data/ext/redhat/puppet.spec.erb +9 -0
  14. data/ext/systemd/puppet.service +3 -4
  15. data/ext/systemd/puppetmaster.service +1 -3
  16. data/install.rb +1 -1
  17. data/lib/puppet.rb +2 -1
  18. data/lib/puppet/agent.rb +1 -1
  19. data/lib/puppet/application.rb +17 -17
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/configurer.rb +4 -1
  22. data/lib/puppet/configurer/downloader.rb +13 -12
  23. data/lib/puppet/configurer/plugin_handler.rb +3 -3
  24. data/lib/puppet/context.rb +6 -1
  25. data/lib/puppet/defaults.rb +82 -12
  26. data/lib/puppet/environments.rb +169 -13
  27. data/lib/puppet/external/nagios/grammar.ry +2 -0
  28. data/lib/puppet/external/nagios/parser.rb +28 -19
  29. data/lib/puppet/face/config.rb +19 -6
  30. data/lib/puppet/face/module/generate.rb +209 -7
  31. data/lib/puppet/face/module/install.rb +17 -16
  32. data/lib/puppet/face/module/list.rb +83 -82
  33. data/lib/puppet/face/module/search.rb +1 -1
  34. data/lib/puppet/face/module/upgrade.rb +10 -9
  35. data/lib/puppet/face/parser.rb +3 -2
  36. data/lib/puppet/face/plugin.rb +8 -4
  37. data/lib/puppet/file_bucket/dipper.rb +6 -3
  38. data/lib/puppet/file_bucket/file.rb +4 -2
  39. data/lib/puppet/file_serving/metadata.rb +1 -1
  40. data/lib/puppet/file_system/memory_file.rb +27 -1
  41. data/lib/puppet/file_system/memory_impl.rb +15 -1
  42. data/lib/puppet/forge.rb +148 -52
  43. data/lib/puppet/forge/cache.rb +5 -1
  44. data/lib/puppet/forge/errors.rb +10 -0
  45. data/lib/puppet/forge/repository.rb +61 -26
  46. data/lib/puppet/functions.rb +548 -0
  47. data/lib/puppet/functions/assert_type.rb +42 -0
  48. data/lib/puppet/functions/import.rb +7 -0
  49. data/lib/puppet/indirector/facts/facter.rb +1 -1
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  51. data/lib/puppet/indirector/rest.rb +18 -0
  52. data/lib/puppet/loaders.rb +20 -0
  53. data/lib/puppet/module.rb +2 -2
  54. data/lib/puppet/module_tool.rb +40 -14
  55. data/lib/puppet/module_tool/applications.rb +0 -1
  56. data/lib/puppet/module_tool/applications/application.rb +35 -26
  57. data/lib/puppet/module_tool/applications/builder.rb +16 -6
  58. data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
  59. data/lib/puppet/module_tool/applications/installer.rb +196 -35
  60. data/lib/puppet/module_tool/applications/searcher.rb +1 -0
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
  62. data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
  63. data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
  64. data/lib/puppet/module_tool/checksums.rb +5 -8
  65. data/lib/puppet/module_tool/errors/installer.rb +12 -44
  66. data/lib/puppet/module_tool/errors/shared.rb +84 -11
  67. data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
  68. data/lib/puppet/module_tool/install_directory.rb +7 -6
  69. data/lib/puppet/module_tool/installed_modules.rb +92 -0
  70. data/lib/puppet/module_tool/local_tarball.rb +91 -0
  71. data/lib/puppet/module_tool/metadata.rb +119 -115
  72. data/lib/puppet/module_tool/modulefile.rb +9 -9
  73. data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
  74. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
  75. data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
  76. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
  77. data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
  78. data/lib/puppet/module_tool/tar.rb +3 -7
  79. data/lib/puppet/module_tool/tar/gnu.rb +21 -9
  80. data/lib/puppet/module_tool/tar/mini.rb +2 -8
  81. data/lib/puppet/network/http/api/v1.rb +1 -1
  82. data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
  83. data/lib/puppet/network/http/issues.rb +1 -0
  84. data/lib/puppet/network/http_pool.rb +15 -6
  85. data/lib/puppet/node/environment.rb +91 -20
  86. data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
  87. data/lib/puppet/parser/collector.rb +1 -1
  88. data/lib/puppet/parser/compiler.rb +50 -7
  89. data/lib/puppet/parser/functions.rb +6 -0
  90. data/lib/puppet/parser/functions/generate.rb +1 -1
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/pops.rb +22 -1
  93. data/lib/puppet/pops/adapters.rb +8 -1
  94. data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
  95. data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
  96. data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
  97. data/lib/puppet/pops/binder/producers.rb +2 -2
  98. data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
  99. data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
  100. data/lib/puppet/pops/evaluator/closure.rb +57 -2
  101. data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
  102. data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
  103. data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
  104. data/lib/puppet/pops/functions/dispatch.rb +71 -0
  105. data/lib/puppet/pops/functions/dispatcher.rb +237 -0
  106. data/lib/puppet/pops/functions/function.rb +77 -0
  107. data/lib/puppet/pops/issues.rb +12 -0
  108. data/lib/puppet/pops/loader/base_loader.rb +102 -0
  109. data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
  110. data/lib/puppet/pops/loader/gem_support.rb +49 -0
  111. data/lib/puppet/pops/loader/loader.rb +180 -0
  112. data/lib/puppet/pops/loader/loader_paths.rb +137 -0
  113. data/lib/puppet/pops/loader/module_loaders.rb +242 -0
  114. data/lib/puppet/pops/loader/null_loader.rb +44 -0
  115. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
  116. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
  117. data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
  118. data/lib/puppet/pops/loader/static_loader.rb +69 -0
  119. data/lib/puppet/pops/loader/uri_helper.rb +22 -0
  120. data/lib/puppet/pops/loaders.rb +240 -0
  121. data/lib/puppet/pops/model/factory.rb +13 -5
  122. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
  123. data/lib/puppet/pops/parser/egrammar.ra +31 -18
  124. data/lib/puppet/pops/parser/eparser.rb +1137 -1106
  125. data/lib/puppet/pops/parser/lexer2.rb +17 -16
  126. data/lib/puppet/pops/semantic_error.rb +17 -0
  127. data/lib/puppet/pops/types/type_calculator.rb +150 -15
  128. data/lib/puppet/pops/types/type_factory.rb +69 -0
  129. data/lib/puppet/pops/types/type_parser.rb +9 -0
  130. data/lib/puppet/pops/types/types.rb +65 -4
  131. data/lib/puppet/pops/validation/checker4_0.rb +1 -1
  132. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  133. data/lib/puppet/property/list.rb +1 -1
  134. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  135. data/lib/puppet/provider/cron/crontab.rb +13 -2
  136. data/lib/puppet/provider/package.rb +24 -0
  137. data/lib/puppet/provider/package/apt.rb +6 -1
  138. data/lib/puppet/provider/package/gem.rb +8 -2
  139. data/lib/puppet/provider/package/msi.rb +0 -15
  140. data/lib/puppet/provider/package/openbsd.rb +0 -24
  141. data/lib/puppet/provider/package/rpm.rb +3 -29
  142. data/lib/puppet/provider/package/windows.rb +0 -15
  143. data/lib/puppet/provider/package/yum.rb +101 -24
  144. data/lib/puppet/provider/package/yumhelper.py +31 -1
  145. data/lib/puppet/provider/package/zypper.rb +10 -28
  146. data/lib/puppet/provider/service/debian.rb +1 -1
  147. data/lib/puppet/provider/service/init.rb +3 -0
  148. data/lib/puppet/provider/service/openbsd.rb +318 -0
  149. data/lib/puppet/provider/service/redhat.rb +6 -3
  150. data/lib/puppet/provider/service/systemd.rb +2 -2
  151. data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
  152. data/lib/puppet/resource.rb +13 -9
  153. data/lib/puppet/resource/catalog.rb +12 -6
  154. data/lib/puppet/resource/type_collection.rb +3 -3
  155. data/lib/puppet/settings.rb +57 -36
  156. data/lib/puppet/settings/config_file.rb +5 -0
  157. data/lib/puppet/settings/environment_conf.rb +147 -0
  158. data/lib/puppet/settings/ttl_setting.rb +48 -0
  159. data/lib/puppet/ssl/certificate_authority.rb +2 -3
  160. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
  161. data/lib/puppet/ssl/certificate_request.rb +4 -4
  162. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  163. data/lib/puppet/status.rb +1 -1
  164. data/lib/puppet/test/test_helper.rb +1 -0
  165. data/lib/puppet/type/augeas.rb +13 -1
  166. data/lib/puppet/type/cron.rb +32 -18
  167. data/lib/puppet/type/file.rb +4 -2
  168. data/lib/puppet/type/file/checksum.rb +15 -5
  169. data/lib/puppet/type/file/content.rb +3 -1
  170. data/lib/puppet/type/file/source.rb +5 -5
  171. data/lib/puppet/type/package.rb +12 -17
  172. data/lib/puppet/type/resources.rb +3 -1
  173. data/lib/puppet/type/scheduled_task.rb +4 -5
  174. data/lib/puppet/type/service.rb +12 -2
  175. data/lib/puppet/type/user.rb +106 -0
  176. data/lib/puppet/type/yumrepo.rb +9 -1
  177. data/lib/puppet/util/checksums.rb +60 -1
  178. data/lib/puppet/util/diff.rb +3 -1
  179. data/lib/puppet/util/execution.rb +20 -16
  180. data/lib/puppet/util/feature.rb +3 -0
  181. data/lib/puppet/util/logging.rb +19 -12
  182. data/lib/puppet/util/rubygems.rb +10 -0
  183. data/lib/puppet/util/watched_file.rb +1 -1
  184. data/lib/puppet/util/windows/security.rb +5 -3
  185. data/lib/puppet/vendor/load_semantic.rb +1 -0
  186. data/lib/puppet/vendor/require_vendored.rb +2 -0
  187. data/lib/puppet/vendor/semantic/Gemfile +20 -0
  188. data/lib/puppet/vendor/semantic/Rakefile +69 -0
  189. data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
  190. data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
  191. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
  192. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
  193. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
  194. data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
  195. data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
  196. data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
  197. data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
  198. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
  199. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
  200. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
  201. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
  202. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
  203. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
  204. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
  205. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
  206. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
  207. data/lib/puppet/version.rb +1 -1
  208. data/spec/fixtures/java.tgz +0 -0
  209. data/spec/fixtures/stdlib.tgz +0 -0
  210. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
  211. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
  212. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
  213. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
  214. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
  215. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
  216. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
  217. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
  218. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
  219. data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
  220. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
  221. data/spec/fixtures/unit/type/user/authorized_keys +5 -0
  222. data/spec/integration/application/apply_spec.rb +1 -2
  223. data/spec/integration/configurer_spec.rb +2 -2
  224. data/spec/integration/faces/plugin_spec.rb +62 -0
  225. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
  226. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  227. data/spec/integration/node/environment_spec.rb +2 -2
  228. data/spec/integration/parser/future_compiler_spec.rb +96 -142
  229. data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
  230. data/spec/integration/provider/cron/crontab_spec.rb +35 -0
  231. data/spec/integration/type/file_spec.rb +74 -72
  232. data/spec/integration/util/windows/security_spec.rb +17 -0
  233. data/spec/lib/matchers/resource.rb +45 -13
  234. data/spec/lib/puppet_spec/files.rb +18 -0
  235. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
  236. data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
  237. data/spec/shared_contexts/checksums.rb +55 -0
  238. data/spec/unit/application/apply_spec.rb +10 -7
  239. data/spec/unit/application/doc_spec.rb +17 -10
  240. data/spec/unit/application/indirection_base_spec.rb +18 -10
  241. data/spec/unit/application/inspect_spec.rb +22 -20
  242. data/spec/unit/configurer/downloader_spec.rb +7 -6
  243. data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
  244. data/spec/unit/configurer_spec.rb +1 -1
  245. data/spec/unit/context_spec.rb +23 -0
  246. data/spec/unit/environments_spec.rb +274 -16
  247. data/spec/unit/face/config_spec.rb +111 -11
  248. data/spec/unit/face/module/install_spec.rb +14 -85
  249. data/spec/unit/face/module/list_spec.rb +108 -62
  250. data/spec/unit/face/module/search_spec.rb +1 -1
  251. data/spec/unit/face/module/uninstall_spec.rb +21 -42
  252. data/spec/unit/face/parser_spec.rb +5 -2
  253. data/spec/unit/file_bucket/dipper_spec.rb +92 -86
  254. data/spec/unit/file_bucket/file_spec.rb +23 -75
  255. data/spec/unit/file_serving/metadata_spec.rb +74 -74
  256. data/spec/unit/forge/module_release_spec.rb +131 -0
  257. data/spec/unit/forge/repository_spec.rb +21 -20
  258. data/spec/unit/forge_spec.rb +99 -23
  259. data/spec/unit/functions/assert_type_spec.rb +59 -0
  260. data/spec/unit/functions4_spec.rb +671 -0
  261. data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
  262. data/spec/unit/indirector/facts/facter_spec.rb +9 -3
  263. data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
  264. data/spec/unit/indirector/rest_spec.rb +8 -0
  265. data/spec/unit/interface/face_collection_spec.rb +35 -23
  266. data/spec/unit/module_spec.rb +20 -8
  267. data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
  268. data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
  269. data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
  270. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
  271. data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
  272. data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
  273. data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
  274. data/spec/unit/module_tool/metadata_spec.rb +223 -14
  275. data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
  276. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  277. data/spec/unit/module_tool/tar_spec.rb +4 -18
  278. data/spec/unit/module_tool_spec.rb +123 -27
  279. data/spec/unit/network/formats_spec.rb +2 -2
  280. data/spec/unit/network/http_pool_spec.rb +21 -0
  281. data/spec/unit/network/rights_spec.rb +10 -8
  282. data/spec/unit/node/environment_spec.rb +27 -2
  283. data/spec/unit/parser/collector_spec.rb +1 -1
  284. data/spec/unit/parser/compiler_spec.rb +1 -1
  285. data/spec/unit/parser/functions/generate_spec.rb +4 -0
  286. data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
  287. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
  288. data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
  289. data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
  290. data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
  291. data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
  292. data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
  293. data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
  294. data/spec/unit/pops/types/type_factory_spec.rb +101 -0
  295. data/spec/unit/pops/types/type_parser_spec.rb +22 -0
  296. data/spec/unit/property/list_spec.rb +9 -1
  297. data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
  298. data/spec/unit/provider/cron/crontab_spec.rb +1 -0
  299. data/spec/unit/provider/cron/parsed_spec.rb +15 -0
  300. data/spec/unit/provider/naginator_spec.rb +14 -0
  301. data/spec/unit/provider/package/apt_spec.rb +78 -64
  302. data/spec/unit/provider/package/gem_spec.rb +15 -0
  303. data/spec/unit/provider/package/rpm_spec.rb +6 -6
  304. data/spec/unit/provider/package/windows_spec.rb +1 -1
  305. data/spec/unit/provider/package/yum_spec.rb +199 -104
  306. data/spec/unit/provider/package/zypper_spec.rb +41 -15
  307. data/spec/unit/provider/service/openbsd_spec.rb +129 -22
  308. data/spec/unit/provider/service/redhat_spec.rb +18 -4
  309. data/spec/unit/provider/service/systemd_spec.rb +5 -9
  310. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  311. data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
  312. data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
  313. data/spec/unit/resource/catalog_spec.rb +20 -104
  314. data/spec/unit/resource/type_collection_spec.rb +10 -9
  315. data/spec/unit/settings/config_file_spec.rb +29 -6
  316. data/spec/unit/settings/environment_conf_spec.rb +51 -0
  317. data/spec/unit/settings_spec.rb +97 -12
  318. data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
  319. data/spec/unit/type/augeas_spec.rb +1 -1
  320. data/spec/unit/type/cron_spec.rb +6 -7
  321. data/spec/unit/type/file/checksum_spec.rb +6 -0
  322. data/spec/unit/type/file/content_spec.rb +277 -207
  323. data/spec/unit/type/file_spec.rb +9 -7
  324. data/spec/unit/type/user_spec.rb +106 -18
  325. data/spec/unit/type/yumrepo_spec.rb +8 -0
  326. data/spec/unit/util/checksums_spec.rb +12 -5
  327. data/spec/unit/util/diff_spec.rb +8 -0
  328. data/spec/unit/util/execution_spec.rb +4 -4
  329. data/spec/unit/util/feature_spec.rb +2 -0
  330. data/spec/unit/util/logging_spec.rb +14 -4
  331. data/spec/unit/util/rdoc/parser_spec.rb +5 -4
  332. data/spec/unit/util/rubygems_spec.rb +14 -0
  333. data/tasks/parallel.rake +2 -2
  334. metadata +154 -21
  335. checksums.yaml +0 -7
  336. data/lib/puppet/module_tool/applications/generator.rb +0 -142
  337. data/lib/puppet/module_tool/skeleton.rb +0 -37
  338. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
  339. data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
  340. data/lib/puppet/module_tool/tar/solaris.rb +0 -5
  341. data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
  342. data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -49,8 +49,7 @@ describe provider_class do
49
49
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
50
50
  @provider.stubs(:zypper_version).returns "1.2.8"
51
51
 
52
- @provider.expects(:zypper).with('--quiet', :install,
53
- '--auto-agree-with-licenses', '--no-confirm', nil, 'mypackage-1.2.3-4.5.6')
52
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage-1.2.3-4.5.6')
54
53
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
55
54
  @provider.install
56
55
  end
@@ -58,8 +57,7 @@ describe provider_class do
58
57
  it "should use a command-line without versioned package" do
59
58
  @resource.stubs(:should).with(:ensure).returns :latest
60
59
  @provider.stubs(:zypper_version).returns "1.2.8"
61
- @provider.expects(:zypper).with('--quiet', :install,
62
- '--auto-agree-with-licenses', '--no-confirm', nil, 'mypackage')
60
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
63
61
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
64
62
  @provider.install
65
63
  end
@@ -70,8 +68,7 @@ describe provider_class do
70
68
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
71
69
  @provider.stubs(:zypper_version).returns "0.6.104"
72
70
 
73
- @provider.expects(:zypper).with('--terse', :install,
74
- '--auto-agree-with-licenses', '--no-confirm', nil, 'mypackage-1.2.3-4.5.6')
71
+ @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage-1.2.3-4.5.6')
75
72
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
76
73
  @provider.install
77
74
  end
@@ -79,8 +76,7 @@ describe provider_class do
79
76
  it "should use a command-line without versioned package" do
80
77
  @resource.stubs(:should).with(:ensure).returns :latest
81
78
  @provider.stubs(:zypper_version).returns "0.6.104"
82
- @provider.expects(:zypper).with('--terse', :install,
83
- '--auto-agree-with-licenses', '--no-confirm', nil, 'mypackage')
79
+ @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
84
80
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
85
81
  @provider.install
86
82
  end
@@ -91,8 +87,7 @@ describe provider_class do
91
87
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
92
88
  @provider.stubs(:zypper_version).returns "0.6.13"
93
89
 
94
- @provider.expects(:zypper).with('--terse', :install,
95
- '--no-confirm', nil, 'mypackage-1.2.3-4.5.6')
90
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage-1.2.3-4.5.6')
96
91
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
97
92
  @provider.install
98
93
  end
@@ -100,8 +95,7 @@ describe provider_class do
100
95
  it "should use a command-line without versioned package" do
101
96
  @resource.stubs(:should).with(:ensure).returns :latest
102
97
  @provider.stubs(:zypper_version).returns "0.6.13"
103
- @provider.expects(:zypper).with('--terse', :install,
104
- '--no-confirm', nil, 'mypackage')
98
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
105
99
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
106
100
  @provider.install
107
101
  end
@@ -127,15 +121,47 @@ describe provider_class do
127
121
  describe "when installing with zypper install options" do
128
122
  it "should install the package without checking keys" do
129
123
  @resource.stubs(:[]).with(:name).returns "php5"
130
- @resource.stubs(:should).with(:install_options).returns ['--no-gpg-check', {'-p' => '/vagrant/files/localrepo/'}]
124
+ @resource.stubs(:[]).with(:install_options).returns ['--no-gpg-check', {'-p' => '/vagrant/files/localrepo/'}]
131
125
  @resource.stubs(:should).with(:ensure).returns "5.4.10-4.5.6"
132
126
  @provider.stubs(:zypper_version).returns "1.2.8"
133
127
 
134
- @provider.expects(:install_options).returns "--no-gpg-check -p \"/vagrant/files/localrepo/\""
135
128
  @provider.expects(:zypper).with('--quiet', :install,
136
- '--auto-agree-with-licenses', '--no-confirm', '--no-gpg-check -p "/vagrant/files/localrepo/"', 'php5-5.4.10-4.5.6')
129
+ '--auto-agree-with-licenses', '--no-confirm', '--no-gpg-check', '-p=/vagrant/files/localrepo/', 'php5-5.4.10-4.5.6')
137
130
  @provider.expects(:query).returns "php5 0 5.4.10 4.5.6 x86_64"
138
131
  @provider.install
139
132
  end
133
+
134
+ it "should install package with hash install options" do
135
+ @resource.stubs(:[]).with(:name).returns 'vim'
136
+ @resource.stubs(:[]).with(:install_options).returns([{ '--a' => 'foo', '--b' => '"quoted bar"' }])
137
+ @resource.stubs(:should).with(:ensure).returns :present
138
+
139
+ @provider.stubs(:zypper_version).returns '1.2.8'
140
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a=foo', '--b="quoted bar"', 'vim')
141
+ @provider.expects(:query).returns 'package vim is not installed'
142
+ @provider.install
143
+ end
144
+
145
+ it "should install package with array install options" do
146
+ @resource.stubs(:[]).with(:name).returns 'vim'
147
+ @resource.stubs(:[]).with(:install_options).returns([['--a', '--b', '--c']])
148
+ @resource.stubs(:should).with(:ensure).returns :present
149
+
150
+ @provider.stubs(:zypper_version).returns '1.2.8'
151
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a', '--b', '--c', 'vim')
152
+ @provider.expects(:query).returns 'package vim is not installed'
153
+ @provider.install
154
+ end
155
+
156
+ it "should install package with string install options" do
157
+ @resource.stubs(:[]).with(:name).returns 'vim'
158
+ @resource.stubs(:[]).with(:install_options).returns(['--a --b --c'])
159
+ @resource.stubs(:should).with(:ensure).returns :present
160
+
161
+ @provider.stubs(:zypper_version).returns '1.2.8'
162
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a --b --c', 'vim')
163
+ @provider.expects(:query).returns 'package vim is not installed'
164
+ @provider.install
165
+ end
140
166
  end
141
167
  end
@@ -14,11 +14,11 @@ describe provider_class do
14
14
 
15
15
  let :rcscripts do
16
16
  [
17
- 'apmd',
18
- 'aucat',
19
- 'cron',
20
- 'puppetd'
21
- ]
17
+ '/etc/rc.d/apmd',
18
+ '/etc/rc.d/aucat',
19
+ '/etc/rc.d/cron',
20
+ '/etc/rc.d/puppetd'
21
+ ]
22
22
  end
23
23
 
24
24
  describe "#instances" do
@@ -27,11 +27,11 @@ describe provider_class do
27
27
  end
28
28
 
29
29
  it "should list all available services" do
30
- FileTest.expects(:directory?).with('/etc/rc.d').returns true
31
- Dir.expects(:entries).with('/etc/rc.d').returns rcscripts
30
+ File.expects(:directory?).with('/etc/rc.d').returns true
31
+ Dir.expects(:glob).with('/etc/rc.d/*').returns rcscripts
32
32
 
33
33
  rcscripts.each do |script|
34
- FileTest.expects(:executable?).with("/etc/rc.d/#{script}").returns true
34
+ File.expects(:executable?).with(script).returns true
35
35
  end
36
36
 
37
37
  described_class.instances.map(&:name).should == [
@@ -81,21 +81,21 @@ describe provider_class do
81
81
  provider.status
82
82
  end
83
83
 
84
- it "should return :stopped when status command returns with a non-zero exitcode" do
85
- provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
86
- provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
87
- provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
88
- $CHILD_STATUS.stubs(:exitstatus).returns 3
89
- provider.status.should == :stopped
90
- end
84
+ it "should return :stopped when status command returns with a non-zero exitcode" do
85
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
86
+ provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
87
+ provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
88
+ $CHILD_STATUS.stubs(:exitstatus).returns 3
89
+ provider.status.should == :stopped
90
+ end
91
91
 
92
- it "should return :running when status command returns with a zero exitcode" do
93
- provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
94
- provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
95
- provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
96
- $CHILD_STATUS.stubs(:exitstatus).returns 0
97
- provider.status.should == :running
98
- end
92
+ it "should return :running when status command returns with a zero exitcode" do
93
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
94
+ provider.expects(:execute).with(['/etc/rc.d/sshd', :status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
95
+ provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
96
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
97
+ provider.status.should == :running
98
+ end
99
99
  end
100
100
 
101
101
  describe "#restart" do
@@ -122,4 +122,111 @@ describe provider_class do
122
122
  provider.restart
123
123
  end
124
124
  end
125
+
126
+ describe "#parse_rc_line" do
127
+ it "can parse a flag line with a known value" do
128
+ output = described_class.parse_rc_line('daemon_flags=')
129
+ output.should eq('')
130
+ end
131
+
132
+ it "can parse a flag line with a flag is wrapped in single quotes" do
133
+ output = described_class.parse_rc_line('daemon_flags=\'\'')
134
+ output.should eq('\'\'')
135
+ end
136
+
137
+ it "can parse a flag line with a flag is wrapped in double quotes" do
138
+ output = described_class.parse_rc_line('daemon_flags=""')
139
+ output.should eq('')
140
+ end
141
+
142
+ it "can parse a flag line with a trailing comment" do
143
+ output = described_class.parse_rc_line('daemon_flags="-d" # bees')
144
+ output.should eq('-d')
145
+ end
146
+
147
+ it "can parse a flag line with a bare word" do
148
+ output = described_class.parse_rc_line('daemon_flags=YES')
149
+ output.should eq('YES')
150
+ end
151
+
152
+ it "can parse a flag line with a flag that contains an equals" do
153
+ output = described_class.parse_rc_line('daemon_flags="-Dbla -tmpdir=foo"')
154
+ output.should eq('-Dbla -tmpdir=foo')
155
+ end
156
+ end
157
+
158
+ describe "#pkg_scripts" do
159
+ it "can retrieve the package_scripts array from rc.conf.local" do
160
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
161
+ provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon cupsd"']
162
+ expect(provider.pkg_scripts).to match_array(['dbus_daemon', 'cupsd'])
163
+ end
164
+
165
+ it "returns an empty array when no pkg_scripts line is found" do
166
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
167
+ provider.expects(:load_rcconf_local_array).returns ["#\n#\n#"]
168
+ expect(provider.pkg_scripts).to match_array([])
169
+ end
170
+ end
171
+
172
+ describe "#pkg_scripts_append" do
173
+ it "can append to the package_scripts array and return the result" do
174
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
175
+ provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon"']
176
+ expect(provider.pkg_scripts_append).to match_array(['dbus_daemon', 'cupsd'])
177
+ end
178
+
179
+ it "should not duplicate the script name" do
180
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
181
+ provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="cupsd dbus_daemon"']
182
+ expect(provider.pkg_scripts_append).to match_array(['dbus_daemon', 'cupsd'])
183
+ end
184
+ end
185
+
186
+ describe "#pkg_scripts_remove" do
187
+ it "can append to the package_scripts array and return the result" do
188
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
189
+ provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon cupsd"']
190
+ expect(provider.pkg_scripts_remove).to match_array(['dbus_daemon'])
191
+ end
192
+
193
+ it "should not remove the script from the array unless its needed" do
194
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
195
+ provider.expects(:load_rcconf_local_array).returns ['pkg_scripts="dbus_daemon"']
196
+ expect(provider.pkg_scripts_remove).to match_array(['dbus_daemon'])
197
+ end
198
+ end
199
+
200
+ describe "#set_content_flags" do
201
+ it "can create the necessary content where none is provided" do
202
+ content = []
203
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
204
+ provider.set_content_flags(content,'-d').should match_array(['cupsd_flags="-d"'])
205
+ end
206
+
207
+ it "can modify the existing content" do
208
+ content = ['cupsd_flags="-f"']
209
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
210
+ output = provider.set_content_flags(content,"-d")
211
+ output.should match_array(['cupsd_flags="-d"'])
212
+ end
213
+ end
214
+
215
+ describe "#remove_content_flags" do
216
+ it "can remove the flags line from the requested content" do
217
+ content = ['cupsd_flags="-d"']
218
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
219
+ output = provider.remove_content_flags(content)
220
+ output.should_not match_array(['cupsd_flags="-d"'])
221
+ end
222
+ end
223
+
224
+ describe "#set_content_scripts" do
225
+ it "should append to the list of scripts" do
226
+ content = ['pkg_scripts="dbus_daemon"']
227
+ scripts = ['dbus_daemon','cupsd']
228
+ provider = described_class.new(Puppet::Type.type(:service).new(:name => 'cupsd'))
229
+ provider.set_content_scripts(content,scripts).should match_array(['pkg_scripts="dbus_daemon cupsd"'])
230
+ end
231
+ end
125
232
  end
@@ -69,11 +69,25 @@ describe provider_class, :as_platform => :posix do
69
69
  @provider.should respond_to(:enabled?)
70
70
  end
71
71
 
72
- it "should use --check on SuSE" do
73
- Facter.expects(:value).with(:osfamily).returns 'Suse'
74
- provider_class.expects(:chkconfig).with(@resource[:name], '--check')
72
+ describe "when checking enabled? on Suse" do
73
+ before :each do
74
+ Facter.expects(:value).with(:osfamily).returns 'Suse'
75
+ end
76
+
77
+ it "should check for on" do
78
+ provider_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]} on"
79
+ @provider.enabled?.should == :true
80
+ end
75
81
 
76
- @provider.enabled?
82
+ it "should check for off" do
83
+ provider_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]} off"
84
+ @provider.enabled?.should == :false
85
+ end
86
+
87
+ it "should check for unknown service" do
88
+ provider_class.stubs(:chkconfig).with(@resource[:name]).returns "#{@resource[:name]}: unknown service"
89
+ @provider.enabled?.should == :false
90
+ end
77
91
  end
78
92
 
79
93
  it "should have an enable method" do
@@ -48,17 +48,13 @@ describe Puppet::Type.type(:service).provider(:systemd) do
48
48
  end
49
49
 
50
50
  it "should return only services" do
51
- described_class.expects(:systemctl).with('list-units', '--type', 'service', '--full', '--all', '--no-pager').returns File.read(my_fixture('list_units_services'))
51
+ described_class.expects(:systemctl).with('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager').returns File.read(my_fixture('list_unit_files_services'))
52
52
  described_class.instances.map(&:name).should =~ %w{
53
+ arp-ethers.service
53
54
  auditd.service
54
- crond.service
55
- dbus.service
56
- display-manager.service
57
- ebtables.service
58
- fedora-readonly.service
59
- initrd-switch-root.service
60
- ip6tables.service
61
- puppet.service
55
+ autovt@.service
56
+ avahi-daemon.service
57
+ blk-availability.service
62
58
  }
63
59
  end
64
60
  end
@@ -50,7 +50,7 @@ describe Puppet::Type.type(:service).provider(:upstart) do
50
50
  end
51
51
 
52
52
  it "should not find excluded services" do
53
- processes = "wait-for-state stop/waiting\nportmap-wait start/running"
53
+ processes = "wait-for-state stop/waiting\nportmap-wait start/running\nidmapd-mounting stop/waiting\nstartpar-bridge start/running"
54
54
  provider_class.stubs(:execpipe).yields(processes)
55
55
  provider_class.instances.should be_empty
56
56
  end
@@ -643,6 +643,11 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
643
643
  }]
644
644
  end
645
645
 
646
+ before :each do
647
+ # Ensure we don't have a value cached from another spec
648
+ provider.class.instance_variable_set(:@groups, nil) if provider.class.instance_variable_defined? :@groups
649
+ end
650
+
646
651
  it 'should return an array of hashes containing group data' do
647
652
  provider.class.expects(:dscl).with('-plist', '.', 'readall', '/Groups').returns(groups_xml)
648
653
  provider.class.get_list_of_groups.should == groups_hash
@@ -989,6 +994,11 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
989
994
  end
990
995
 
991
996
  describe 'self#get_os_version' do
997
+ before :each do
998
+ # Ensure we don't have a value cached from another spec
999
+ provider.class.instance_variable_set(:@os_version, nil) if provider.class.instance_variable_defined? :@os_version
1000
+ end
1001
+
992
1002
  it 'should call Facter.value(:macosx_productversion_major) ONLY ONCE no matter how ' +
993
1003
  'many times get_os_version() is called' do
994
1004
  Facter.expects(:value).with(:macosx_productversion_major).once.returns('10.8')
@@ -2,13 +2,77 @@ require 'spec_helper'
2
2
 
3
3
  describe Puppet::Type.type(:yumrepo).provider(:inifile) do
4
4
 
5
- let(:virtual_inifile) { stub('virtual inifile') }
5
+ after(:each) do
6
+ described_class.clear
7
+ end
8
+
9
+ describe "enumerating all yum repo files" do
10
+ it "reads all files in the directories specified by reposdir" do
11
+ described_class.expects(:reposdir).returns ['/etc/yum.repos.d']
12
+
13
+ Dir.expects(:glob).with("/etc/yum.repos.d/*.repo").returns(['/etc/yum.repos.d/first.repo', '/etc/yum.repos.d/second.repo'])
14
+
15
+ actual = described_class.repofiles
16
+ expect(actual).to include("/etc/yum.repos.d/first.repo")
17
+ expect(actual).to include("/etc/yum.repos.d/second.repo")
18
+ end
19
+
20
+ it "includes '/etc/yum.conf' as the first element" do
21
+ described_class.expects(:reposdir).returns []
22
+
23
+ actual = described_class.repofiles
24
+ expect(actual[0]).to eq "/etc/yum.conf"
25
+ end
26
+ end
27
+
28
+ describe "generating the virtual inifile" do
29
+ let(:files) { ['/etc/yum.repos.d/first.repo', '/etc/yum.repos.d/second.repo', '/etc/yum.conf'] }
30
+ let(:collection) { mock('virtual inifile') }
31
+
32
+ before do
33
+ described_class.clear
34
+ Puppet::Util::IniConfig::FileCollection.expects(:new).returns collection
35
+ end
36
+
37
+ it "reads all files in the directories specified by self.repofiles" do
38
+ described_class.expects(:repofiles).returns(files)
39
+
40
+ files.each do |file|
41
+ Puppet::FileSystem.stubs(:file?).with(file).returns true
42
+ collection.expects(:read).with(file)
43
+ end
44
+ described_class.virtual_inifile
45
+ end
6
46
 
7
- before :each do
8
- described_class.stubs(:virtual_inifile).returns(virtual_inifile)
47
+ it "ignores repofile entries that are not files" do
48
+ described_class.expects(:repofiles).returns(files)
49
+
50
+ Puppet::FileSystem.stubs(:file?).with('/etc/yum.repos.d/first.repo').returns true
51
+ Puppet::FileSystem.stubs(:file?).with('/etc/yum.repos.d/second.repo').returns false
52
+ Puppet::FileSystem.stubs(:file?).with('/etc/yum.conf').returns true
53
+
54
+ collection.expects(:read).with('/etc/yum.repos.d/first.repo').once
55
+ collection.expects(:read).with('/etc/yum.repos.d/second.repo').never
56
+ collection.expects(:read).with('/etc/yum.conf').once
57
+ described_class.virtual_inifile
58
+ end
9
59
  end
10
60
 
11
- describe 'self.instances' do
61
+ describe 'creating provider instances' do
62
+ let(:virtual_inifile) { stub('virtual inifile') }
63
+
64
+ before :each do
65
+ described_class.stubs(:virtual_inifile).returns(virtual_inifile)
66
+ end
67
+
68
+ let(:main_section) do
69
+ sect = Puppet::Util::IniConfig::Section.new('main', '/some/imaginary/file')
70
+ sect.entries << ['distroverpkg', 'centos-release']
71
+ sect.entries << ['plugins', '1']
72
+
73
+ sect
74
+ end
75
+
12
76
  let(:updates_section) do
13
77
  sect = Puppet::Util::IniConfig::Section.new('updates', '/some/imaginary/file')
14
78
  sect.entries << ['name', 'Some long description of the repo']
@@ -17,15 +81,65 @@ describe Puppet::Type.type(:yumrepo).provider(:inifile) do
17
81
  sect
18
82
  end
19
83
 
20
- it 'finds any existing sections' do
21
- virtual_inifile.expects(:each_section).yields(updates_section)
22
- virtual_inifile.stubs(:[]).with('updates').returns(updates_section)
84
+ it "ignores the main section" do
85
+ virtual_inifile.expects(:each_section).multiple_yields(main_section, updates_section)
86
+
87
+ instances = described_class.instances
88
+ expect(instances).to have(1).items
89
+ expect(instances[0].name).to eq 'updates'
90
+ end
91
+
92
+ it "creates provider instances for every non-main section that was found" do
93
+ virtual_inifile.expects(:each_section).multiple_yields(main_section, updates_section)
23
94
 
24
- providers = described_class.instances
25
- providers.should have(1).items
26
- providers[0].name.should == 'updates'
27
- providers[0].descr.should == 'Some long description of the repo'
28
- providers[0].enabled.should == '1'
95
+ sect = described_class.instances.first
96
+ expect(sect.name).to eq 'updates'
97
+ expect(sect.descr).to eq 'Some long description of the repo'
98
+ expect(sect.enabled).to eq '1'
99
+ end
100
+ end
101
+
102
+ describe "retrieving a section from the inifile" do
103
+
104
+ let(:collection) { stub('ini file collection') }
105
+
106
+ let(:ini_section) { stub('ini file section') }
107
+
108
+ before do
109
+ described_class.stubs(:virtual_inifile).returns(collection)
110
+ end
111
+
112
+ describe "and the requested section exists" do
113
+ before do
114
+ collection.stubs(:[]).with('updates').returns ini_section
115
+ end
116
+
117
+ it "returns the existing section" do
118
+ expect(described_class.section('updates')).to eq ini_section
119
+ end
120
+
121
+ it "doesn't create a new section" do
122
+ collection.expects(:add_section).never
123
+ described_class.section('updates')
124
+ end
125
+ end
126
+
127
+ describe "and the requested section doesn't exist" do
128
+ it "creates a section in the preferred repodir" do
129
+ described_class.stubs(:reposdir).returns ['/etc/yum.repos.d', '/etc/alternate.repos.d']
130
+ collection.expects(:[]).with('updates')
131
+ collection.expects(:add_section).with('updates', '/etc/alternate.repos.d/updates.repo')
132
+
133
+ described_class.section('updates')
134
+ end
135
+
136
+ it "creates a section in yum.conf if no repodirs exist" do
137
+ described_class.stubs(:reposdir).returns []
138
+ collection.expects(:[]).with('updates')
139
+ collection.expects(:add_section).with('updates', '/etc/yum.conf')
140
+
141
+ described_class.section('updates')
142
+ end
29
143
  end
30
144
  end
31
145
 
@@ -135,19 +249,61 @@ describe Puppet::Type.type(:yumrepo).provider(:inifile) do
135
249
  described_class.reposdir('/etc/yum.conf').should include("/etc/yum/extra.repos.d")
136
250
  end
137
251
 
138
- it "doesn't the directory specified by the yum.conf 'reposdir' entry when the directory is absent" do
252
+ it "doesn't include the directory specified by the yum.conf 'reposdir' entry when the directory is absent" do
139
253
  Puppet::FileSystem.expects(:exist?).with("/etc/yum/extra.repos.d").returns(false)
140
254
 
141
255
  described_class.expects(:find_conf_value).with('reposdir', '/etc/yum.conf').returns "/etc/yum/extra.repos.d"
142
256
  described_class.reposdir('/etc/yum.conf').should_not include("/etc/yum/extra.repos.d")
143
257
  end
144
258
 
145
- it "raises an entry if none of the specified repo directories exist" do
259
+ it "logs a warning and returns an empty array if none of the specified repo directories exist" do
146
260
  Puppet::FileSystem.unstub(:exist?)
147
261
  Puppet::FileSystem.stubs(:exist?).returns false
148
262
 
149
263
  described_class.stubs(:find_conf_value).with('reposdir', '/etc/yum.conf')
150
- expect { described_class.reposdir('/etc/yum.conf') }.to raise_error('No yum directories were found on the local filesystem')
264
+ Puppet.expects(:debug).with('No yum directories were found on the local filesystem')
265
+ expect(described_class.reposdir('/etc/yum.conf')).to be_empty
266
+ end
267
+ end
268
+
269
+ describe "looking up a conf value" do
270
+ describe "and the file doesn't exist" do
271
+ it "returns nil" do
272
+ Puppet::FileSystem.stubs(:exist?).returns false
273
+ expect(described_class.find_conf_value('reposdir')).to be_nil
274
+ end
275
+ end
276
+
277
+ describe "and the file exists" do
278
+ let(:pfile) { stub('yum.conf physical file') }
279
+ let(:sect) { stub('ini section') }
280
+
281
+ before do
282
+ Puppet::FileSystem.stubs(:exist?).with('/etc/yum.conf').returns true
283
+ Puppet::Util::IniConfig::PhysicalFile.stubs(:new).with('/etc/yum.conf').returns pfile
284
+ end
285
+
286
+ it "creates a PhysicalFile to parse the given file" do
287
+ pfile.expects(:get_section)
288
+ described_class.find_conf_value('reposdir')
289
+ end
290
+
291
+ it "returns nil if the file exists but the 'main' section doesn't exist" do
292
+ pfile.expects(:get_section).with('main')
293
+ expect(described_class.find_conf_value('reposdir')).to be_nil
294
+ end
295
+
296
+ it "returns nil if the file exists but the INI property doesn't exist" do
297
+ pfile.expects(:get_section).with('main').returns sect
298
+ sect.expects(:[]).with('reposdir')
299
+ expect(described_class.find_conf_value('reposdir')).to be_nil
300
+ end
301
+
302
+ it "returns the value if the value is defined in the PhysicalFile" do
303
+ pfile.expects(:get_section).with('main').returns sect
304
+ sect.expects(:[]).with('reposdir').returns '/etc/alternate.repos.d'
305
+ expect(described_class.find_conf_value('reposdir')).to eq '/etc/alternate.repos.d'
306
+ end
151
307
  end
152
308
  end
153
309
  end