puppet 3.2.4 → 3.3.0.rc2

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 (562) hide show
  1. data/COMMITTERS.md +101 -42
  2. data/Gemfile +15 -4
  3. data/README.md +5 -1
  4. data/README_DEVELOPER.md +117 -54
  5. data/Rakefile +4 -0
  6. data/ext/build_defaults.yaml +3 -2
  7. data/ext/debian/puppet-common.manpages +33 -1
  8. data/ext/gentoo/init.d/puppet +1 -1
  9. data/ext/gentoo/init.d/puppetmaster +1 -1
  10. data/ext/redhat/puppet.spec.erb +0 -1
  11. data/install.rb +2 -1
  12. data/lib/hiera/backend/puppet_backend.rb +1 -1
  13. data/lib/puppet/application.rb +10 -9
  14. data/lib/puppet/application/agent.rb +87 -93
  15. data/lib/puppet/application/apply.rb +0 -2
  16. data/lib/puppet/application/device.rb +3 -3
  17. data/lib/puppet/application/kick.rb +2 -2
  18. data/lib/puppet/application/master.rb +41 -19
  19. data/lib/puppet/application/queue.rb +5 -3
  20. data/lib/puppet/bindings.rb +147 -0
  21. data/lib/puppet/configurer.rb +25 -15
  22. data/lib/puppet/configurer/fact_handler.rb +2 -9
  23. data/lib/puppet/daemon.rb +44 -33
  24. data/lib/puppet/defaults.rb +57 -26
  25. data/lib/puppet/error.rb +1 -1
  26. data/lib/puppet/external/dot.rb +2 -2
  27. data/lib/puppet/external/nagios/base.rb +1 -6
  28. data/lib/puppet/external/pson/common.rb +2 -2
  29. data/lib/puppet/external/pson/pure/generator.rb +2 -2
  30. data/lib/puppet/external/pson/pure/parser.rb +1 -1
  31. data/lib/puppet/face/ca.rb +1 -1
  32. data/lib/puppet/face/config.rb +1 -1
  33. data/lib/puppet/face/help.rb +2 -2
  34. data/lib/puppet/face/module/list.rb +2 -2
  35. data/lib/puppet/feature/rails.rb +1 -1
  36. data/lib/puppet/file_bucket/dipper.rb +0 -1
  37. data/lib/puppet/file_serving/base.rb +1 -1
  38. data/lib/puppet/file_serving/configuration/parser.rb +20 -14
  39. data/lib/puppet/forge.rb +0 -32
  40. data/lib/puppet/forge/cache.rb +1 -1
  41. data/lib/puppet/forge/errors.rb +3 -3
  42. data/lib/puppet/forge/repository.rb +7 -42
  43. data/lib/puppet/graph.rb +11 -0
  44. data/lib/puppet/graph/key.rb +26 -0
  45. data/lib/puppet/graph/prioritizer.rb +29 -0
  46. data/lib/puppet/graph/random_prioritizer.rb +16 -0
  47. data/lib/puppet/{rb_tree_map.rb → graph/rb_tree_map.rb} +3 -3
  48. data/lib/puppet/graph/relationship_graph.rb +246 -0
  49. data/lib/puppet/graph/sequential_prioritizer.rb +31 -0
  50. data/lib/puppet/{simple_graph.rb → graph/simple_graph.rb} +22 -3
  51. data/lib/puppet/graph/title_hash_prioritizer.rb +16 -0
  52. data/lib/puppet/indirector.rb +2 -2
  53. data/lib/puppet/indirector/catalog/compiler.rb +10 -7
  54. data/lib/puppet/indirector/catalog/static_compiler.rb +50 -0
  55. data/lib/puppet/indirector/certificate/rest.rb +1 -1
  56. data/lib/puppet/indirector/exec.rb +1 -1
  57. data/lib/puppet/indirector/facts/facter.rb +2 -2
  58. data/lib/puppet/indirector/facts/inventory_active_record.rb +0 -1
  59. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  60. data/lib/puppet/indirector/file_bucket_file/file.rb +0 -1
  61. data/lib/puppet/indirector/indirection.rb +2 -2
  62. data/lib/puppet/indirector/memory.rb +9 -0
  63. data/lib/puppet/indirector/node/ldap.rb +2 -4
  64. data/lib/puppet/indirector/report/processor.rb +1 -2
  65. data/lib/puppet/indirector/report/rest.rb +1 -1
  66. data/lib/puppet/indirector/request.rb +32 -10
  67. data/lib/puppet/indirector/resource/rest.rb +1 -1
  68. data/lib/puppet/indirector/resource_type/parser.rb +31 -12
  69. data/lib/puppet/interface.rb +1 -1
  70. data/lib/puppet/interface/documentation.rb +7 -11
  71. data/lib/puppet/interface/option.rb +1 -1
  72. data/lib/puppet/interface/option_builder.rb +1 -1
  73. data/lib/puppet/metatype/manager.rb +2 -2
  74. data/lib/puppet/module.rb +7 -1
  75. data/lib/puppet/module_tool.rb +1 -1
  76. data/lib/puppet/module_tool/applications/application.rb +10 -0
  77. data/lib/puppet/module_tool/applications/installer.rb +6 -3
  78. data/lib/puppet/module_tool/dependency.rb +2 -0
  79. data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
  80. data/lib/puppet/module_tool/metadata.rb +25 -13
  81. data/lib/puppet/module_tool/modulefile.rb +7 -7
  82. data/lib/puppet/module_tool/shared_behaviors.rb +4 -2
  83. data/lib/puppet/module_tool/skeleton.rb +1 -1
  84. data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +5 -5
  85. data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +5 -4
  86. data/lib/puppet/network/auth_config_parser.rb +3 -0
  87. data/lib/puppet/network/authconfig.rb +0 -1
  88. data/lib/puppet/network/authorization.rb +1 -1
  89. data/lib/puppet/network/authstore.rb +2 -2
  90. data/lib/puppet/network/format_handler.rb +25 -114
  91. data/lib/puppet/network/format_support.rb +106 -0
  92. data/lib/puppet/network/formats.rb +10 -4
  93. data/lib/puppet/network/http/compression.rb +1 -1
  94. data/lib/puppet/network/http/connection.rb +76 -32
  95. data/lib/puppet/network/http/handler.rb +122 -61
  96. data/lib/puppet/network/http/rack/rest.rb +1 -1
  97. data/lib/puppet/network/http/webrick/rest.rb +9 -3
  98. data/lib/puppet/network/http_pool.rb +2 -2
  99. data/lib/puppet/network/resolver.rb +1 -0
  100. data/lib/puppet/network/server.rb +5 -81
  101. data/lib/puppet/node/environment.rb +256 -13
  102. data/lib/puppet/node/facts.rb +28 -2
  103. data/lib/puppet/parameter.rb +27 -18
  104. data/lib/puppet/parameter/boolean.rb +20 -0
  105. data/lib/puppet/parameter/path.rb +1 -1
  106. data/lib/puppet/parameter/value.rb +1 -1
  107. data/lib/puppet/parameter/value_collection.rb +1 -1
  108. data/lib/puppet/parser/ast/arithmetic_operator.rb +8 -0
  109. data/lib/puppet/parser/ast/casestatement.rb +0 -3
  110. data/lib/puppet/parser/ast/lambda.rb +25 -6
  111. data/lib/puppet/parser/ast/leaf.rb +10 -3
  112. data/lib/puppet/parser/ast/nop.rb +1 -1
  113. data/lib/puppet/parser/ast/resource_override.rb +0 -2
  114. data/lib/puppet/parser/compiler.rb +92 -34
  115. data/lib/puppet/parser/files.rb +0 -5
  116. data/lib/puppet/parser/functions/create_resources.rb +23 -46
  117. data/lib/puppet/parser/functions/each.rb +0 -2
  118. data/lib/puppet/parser/functions/extlookup.rb +2 -2
  119. data/lib/puppet/parser/functions/foreach.rb +0 -2
  120. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  121. data/lib/puppet/parser/functions/lookup.rb +44 -0
  122. data/lib/puppet/parser/functions/slice.rb +1 -1
  123. data/lib/puppet/parser/grammar.ra +0 -1
  124. data/lib/puppet/parser/lexer.rb +0 -1
  125. data/lib/puppet/parser/parser.rb +0 -1
  126. data/lib/puppet/parser/parser_factory.rb +3 -2
  127. data/lib/puppet/parser/parser_support.rb +1 -1
  128. data/lib/puppet/parser/relationship.rb +1 -1
  129. data/lib/puppet/parser/scope.rb +49 -24
  130. data/lib/puppet/parser/type_loader.rb +13 -18
  131. data/lib/puppet/pops.rb +45 -0
  132. data/lib/puppet/pops/adaptable.rb +2 -2
  133. data/lib/puppet/pops/adapters.rb +4 -0
  134. data/lib/puppet/pops/binder/binder.rb +421 -0
  135. data/lib/puppet/pops/binder/binder_issues.rb +142 -0
  136. data/lib/puppet/pops/binder/bindings_checker.rb +217 -0
  137. data/lib/puppet/pops/binder/bindings_composer.rb +241 -0
  138. data/lib/puppet/pops/binder/bindings_factory.rb +847 -0
  139. data/lib/puppet/pops/binder/bindings_label_provider.rb +46 -0
  140. data/lib/puppet/pops/binder/bindings_loader.rb +79 -0
  141. data/lib/puppet/pops/binder/bindings_model.rb +215 -0
  142. data/lib/puppet/pops/binder/bindings_model_dumper.rb +205 -0
  143. data/lib/puppet/pops/binder/bindings_validator_factory.rb +28 -0
  144. data/lib/puppet/pops/binder/config/binder_config.rb +139 -0
  145. data/lib/puppet/pops/binder/config/binder_config_checker.rb +183 -0
  146. data/lib/puppet/pops/binder/config/diagnostic_producer.rb +32 -0
  147. data/lib/puppet/pops/binder/config/issues.rb +106 -0
  148. data/lib/puppet/pops/binder/hiera2.rb +10 -0
  149. data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +148 -0
  150. data/lib/puppet/pops/binder/hiera2/config.rb +69 -0
  151. data/lib/puppet/pops/binder/hiera2/config_checker.rb +68 -0
  152. data/lib/puppet/pops/binder/hiera2/diagnostic_producer.rb +36 -0
  153. data/lib/puppet/pops/binder/hiera2/issues.rb +67 -0
  154. data/lib/puppet/pops/binder/hiera2/json_backend.rb +18 -0
  155. data/lib/puppet/pops/binder/hiera2/yaml_backend.rb +21 -0
  156. data/lib/puppet/pops/binder/injector.rb +688 -0
  157. data/lib/puppet/pops/binder/injector_entry.rb +53 -0
  158. data/lib/puppet/pops/binder/key_factory.rb +61 -0
  159. data/lib/puppet/pops/binder/producers.rb +829 -0
  160. data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +67 -0
  161. data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +34 -0
  162. data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +92 -0
  163. data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +84 -0
  164. data/lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb +54 -0
  165. data/lib/puppet/pops/binder/system_bindings.rb +72 -0
  166. data/lib/puppet/pops/issue_reporter.rb +75 -0
  167. data/lib/puppet/pops/issues.rb +9 -5
  168. data/lib/puppet/pops/model/ast_transformer.rb +4 -4
  169. data/lib/puppet/pops/model/ast_tree_dumper.rb +1 -1
  170. data/lib/puppet/pops/model/factory.rb +25 -13
  171. data/lib/puppet/pops/model/model.rb +1 -1
  172. data/lib/puppet/pops/model/tree_dumper.rb +2 -2
  173. data/lib/puppet/pops/parser/egrammar.ra +0 -1
  174. data/lib/puppet/pops/parser/eparser.rb +1 -2
  175. data/lib/puppet/pops/parser/evaluating_parser.rb +162 -0
  176. data/lib/puppet/pops/parser/lexer.rb +8 -6
  177. data/lib/puppet/pops/types/class_loader.rb +118 -0
  178. data/lib/puppet/pops/types/type_calculator.rb +557 -0
  179. data/lib/puppet/pops/types/type_factory.rb +147 -0
  180. data/lib/puppet/pops/types/type_parser.rb +117 -0
  181. data/lib/puppet/pops/types/types.rb +132 -0
  182. data/lib/puppet/pops/validation.rb +146 -17
  183. data/lib/puppet/pops/validation/checker3_1.rb +1 -1
  184. data/lib/puppet/pops/validation/validator_factory_3_1.rb +6 -16
  185. data/lib/puppet/property.rb +3 -3
  186. data/lib/puppet/property/keyvalue.rb +1 -1
  187. data/lib/puppet/provider.rb +2 -2
  188. data/lib/puppet/provider/aixobject.rb +19 -21
  189. data/lib/puppet/provider/augeas/augeas.rb +3 -1
  190. data/lib/puppet/provider/command.rb +2 -2
  191. data/lib/puppet/provider/group/aix.rb +1 -1
  192. data/lib/puppet/provider/group/ldap.rb +1 -1
  193. data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
  194. data/lib/puppet/provider/mailalias/aliases.rb +3 -8
  195. data/lib/puppet/provider/mcx/mcxcontent.rb +7 -1
  196. data/lib/puppet/provider/mount.rb +8 -3
  197. data/lib/puppet/provider/nameservice.rb +1 -1
  198. data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
  199. data/lib/puppet/provider/package/appdmg.rb +1 -1
  200. data/lib/puppet/provider/package/apt.rb +0 -1
  201. data/lib/puppet/provider/package/dpkg.rb +86 -32
  202. data/lib/puppet/provider/package/fink.rb +0 -2
  203. data/lib/puppet/provider/package/freebsd.rb +0 -2
  204. data/lib/puppet/provider/package/openbsd.rb +57 -10
  205. data/lib/puppet/provider/package/opkg.rb +0 -1
  206. data/lib/puppet/provider/package/pacman.rb +0 -1
  207. data/lib/puppet/provider/package/pip.rb +1 -1
  208. data/lib/puppet/provider/package/pkgdmg.rb +17 -6
  209. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  210. data/lib/puppet/provider/package/portage.rb +9 -1
  211. data/lib/puppet/provider/package/ports.rb +2 -2
  212. data/lib/puppet/provider/package/rpm.rb +29 -12
  213. data/lib/puppet/provider/package/rug.rb +1 -1
  214. data/lib/puppet/provider/package/urpmi.rb +11 -15
  215. data/lib/puppet/provider/package/windows/exe_package.rb +1 -1
  216. data/lib/puppet/provider/package/windows/package.rb +1 -26
  217. data/lib/puppet/provider/package/yum.rb +1 -1
  218. data/lib/puppet/provider/package/zypper.rb +22 -3
  219. data/lib/puppet/provider/parsedfile.rb +1 -12
  220. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -1
  221. data/lib/puppet/provider/service/base.rb +1 -1
  222. data/lib/puppet/provider/service/daemontools.rb +3 -3
  223. data/lib/puppet/provider/service/debian.rb +1 -1
  224. data/lib/puppet/provider/service/init.rb +14 -20
  225. data/lib/puppet/provider/service/openrc.rb +3 -1
  226. data/lib/puppet/provider/service/redhat.rb +5 -8
  227. data/lib/puppet/provider/service/runit.rb +3 -2
  228. data/lib/puppet/provider/service/systemd.rb +1 -1
  229. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  230. data/lib/puppet/provider/sshkey/parsed.rb +0 -2
  231. data/lib/puppet/provider/user/aix.rb +25 -12
  232. data/lib/puppet/provider/user/directoryservice.rb +4 -7
  233. data/lib/puppet/provider/user/ldap.rb +0 -1
  234. data/lib/puppet/provider/user/user_role_add.rb +2 -0
  235. data/lib/puppet/provider/user/useradd.rb +1 -1
  236. data/lib/puppet/provider/zone/solaris.rb +1 -2
  237. data/lib/puppet/reference/metaparameter.rb +1 -1
  238. data/lib/puppet/reference/type.rb +1 -1
  239. data/lib/puppet/reports/rrdgraph.rb +1 -1
  240. data/lib/puppet/reports/tagmail.rb +1 -1
  241. data/lib/puppet/resource.rb +16 -4
  242. data/lib/puppet/resource/catalog.rb +111 -173
  243. data/lib/puppet/resource/status.rb +42 -3
  244. data/lib/puppet/resource/type.rb +33 -46
  245. data/lib/puppet/resource/type_collection.rb +19 -15
  246. data/lib/puppet/run.rb +5 -1
  247. data/lib/puppet/scheduler/scheduler.rb +14 -15
  248. data/lib/puppet/settings.rb +78 -41
  249. data/lib/puppet/settings/boolean_setting.rb +0 -2
  250. data/lib/puppet/settings/config_file.rb +0 -2
  251. data/lib/puppet/settings/directory_setting.rb +0 -2
  252. data/lib/puppet/settings/duration_setting.rb +0 -2
  253. data/lib/puppet/settings/enum_setting.rb +16 -0
  254. data/lib/puppet/settings/file_setting.rb +0 -2
  255. data/lib/puppet/settings/path_setting.rb +0 -2
  256. data/lib/puppet/settings/string_setting.rb +0 -3
  257. data/lib/puppet/settings/terminus_setting.rb +0 -2
  258. data/lib/puppet/ssl/certificate_authority.rb +102 -9
  259. data/lib/puppet/test/test_helper.rb +1 -0
  260. data/lib/puppet/transaction.rb +130 -292
  261. data/lib/puppet/transaction/additional_resource_generator.rb +126 -0
  262. data/lib/puppet/transaction/event.rb +16 -1
  263. data/lib/puppet/transaction/report.rb +34 -14
  264. data/lib/puppet/transaction/resource_harness.rb +16 -19
  265. data/lib/puppet/type.rb +59 -53
  266. data/lib/puppet/type/component.rb +0 -2
  267. data/lib/puppet/type/cron.rb +13 -2
  268. data/lib/puppet/type/exec.rb +5 -7
  269. data/lib/puppet/type/file.rb +9 -32
  270. data/lib/puppet/type/file/content.rb +4 -1
  271. data/lib/puppet/type/file/ctime.rb +3 -1
  272. data/lib/puppet/type/file/ensure.rb +1 -1
  273. data/lib/puppet/type/file/mode.rb +0 -1
  274. data/lib/puppet/type/file/mtime.rb +2 -1
  275. data/lib/puppet/type/group.rb +7 -9
  276. data/lib/puppet/type/host.rb +1 -2
  277. data/lib/puppet/type/mcx.rb +0 -1
  278. data/lib/puppet/type/mount.rb +38 -6
  279. data/lib/puppet/type/package.rb +2 -2
  280. data/lib/puppet/type/resources.rb +5 -4
  281. data/lib/puppet/type/schedule.rb +1 -4
  282. data/lib/puppet/type/selmodule.rb +1 -1
  283. data/lib/puppet/type/service.rb +1 -3
  284. data/lib/puppet/type/tidy.rb +3 -3
  285. data/lib/puppet/type/user.rb +9 -13
  286. data/lib/puppet/type/yumrepo.rb +11 -7
  287. data/lib/puppet/util.rb +14 -7
  288. data/lib/puppet/util/autoload.rb +0 -1
  289. data/lib/puppet/util/backups.rb +1 -3
  290. data/lib/puppet/util/classgen.rb +1 -1
  291. data/lib/puppet/util/command_line/puppet_option_parser.rb +1 -3
  292. data/lib/puppet/util/command_line/trollop.rb +1 -1
  293. data/lib/puppet/util/constant_inflector.rb +1 -2
  294. data/lib/puppet/util/errors.rb +1 -0
  295. data/lib/puppet/util/file_watcher.rb +28 -0
  296. data/lib/puppet/util/fileparsing.rb +1 -3
  297. data/lib/puppet/util/filetype.rb +0 -1
  298. data/lib/puppet/util/http_proxy.rb +38 -0
  299. data/lib/puppet/util/ldap/manager.rb +1 -2
  300. data/lib/puppet/util/log.rb +31 -10
  301. data/lib/puppet/util/log/destinations.rb +0 -50
  302. data/lib/puppet/util/metric.rb +8 -1
  303. data/lib/puppet/util/monkey_patches.rb +14 -148
  304. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  305. data/lib/puppet/util/network_device/config.rb +6 -9
  306. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  307. data/lib/puppet/util/pidlock.rb +3 -0
  308. data/lib/puppet/util/posix.rb +1 -1
  309. data/lib/puppet/util/profiler.rb +1 -1
  310. data/lib/puppet/util/rdoc.rb +1 -1
  311. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -1
  312. data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +50 -42
  313. data/lib/puppet/util/retryaction.rb +0 -1
  314. data/lib/puppet/util/symbolic_file_mode.rb +5 -1
  315. data/lib/puppet/util/tagging.rb +0 -2
  316. data/lib/puppet/util/warnings.rb +3 -0
  317. data/lib/puppet/util/watched_file.rb +37 -0
  318. data/lib/puppet/util/watcher.rb +17 -0
  319. data/lib/puppet/util/watcher/change_watcher.rb +33 -0
  320. data/lib/puppet/util/watcher/periodic_watcher.rb +37 -0
  321. data/lib/puppet/util/watcher/timer.rb +19 -0
  322. data/lib/puppet/util/windows/user.rb +1 -1
  323. data/lib/puppet/version.rb +1 -1
  324. data/lib/puppetx.rb +109 -0
  325. data/lib/puppetx/puppet/bindings_scheme_handler.rb +130 -0
  326. data/lib/puppetx/puppet/hiera2_backend.rb +31 -0
  327. data/lib/puppetx/puppet/syntax_checker.rb +91 -0
  328. data/lib/puppetx/puppetlabs/syntax_checkers/json.rb +39 -0
  329. data/lib/semver.rb +1 -1
  330. data/man/man8/puppet-kick.8 +1 -1
  331. data/spec/fixtures/integration/provider/cron/crontab/unspecialized +15 -0
  332. data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/binder_config.yaml +18 -0
  333. data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/hiera.yaml +8 -0
  334. data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/common.yaml +1 -0
  335. data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/hiera.yaml +10 -0
  336. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/binder_config.yaml +19 -0
  337. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/common.yaml +1 -0
  338. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/hiera.yaml +11 -0
  339. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/localhost.yaml +1 -0
  340. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/common.yaml +3 -0
  341. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/hiera.yaml +13 -0
  342. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppet/bindings/awesome/default.rb +4 -0
  343. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_backend.rb +11 -0
  344. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_scheme_handler.rb +18 -0
  345. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/localhost.yaml +1 -0
  346. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/common.yaml +3 -0
  347. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/hiera_config.yaml +9 -0
  348. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/common.yaml +2 -0
  349. data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/hiera.yaml +11 -0
  350. data/spec/fixtures/unit/pops/binder/config/binder_config/ok/binder_config.yaml +9 -0
  351. data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/hiera.yaml +9 -0
  352. data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.json +9 -0
  353. data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.yaml +5 -0
  354. data/spec/fixtures/unit/pops/binder/hiera2/config/bad_syntax/hiera.yaml +10 -0
  355. data/spec/fixtures/unit/pops/binder/hiera2/config/malformed_hierarchy/hiera.yaml +8 -0
  356. data/spec/fixtures/unit/pops/binder/hiera2/config/missing/foo.txt +1 -0
  357. data/spec/fixtures/unit/pops/binder/hiera2/config/no_backends/hiera.yaml +7 -0
  358. data/spec/fixtures/unit/pops/binder/hiera2/config/no_hierarchy/hiera.yaml +4 -0
  359. data/spec/fixtures/unit/pops/binder/hiera2/config/not_a_hash/hiera.yaml +2 -0
  360. data/spec/fixtures/unit/pops/binder/hiera2/config/ok/hiera.yaml +8 -0
  361. data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/empty/common.yaml +0 -0
  362. data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/invalid/common.yaml +1 -0
  363. data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/ok/common.yaml +2 -0
  364. data/spec/fixtures/unit/provider/package/openbsd/pkginfo_flavors.list +2 -0
  365. data/spec/integration/agent/logging_spec.rb +178 -0
  366. data/spec/integration/configurer_spec.rb +1 -1
  367. data/spec/integration/defaults_spec.rb +0 -6
  368. data/spec/integration/network/authconfig_spec.rb +19 -0
  369. data/spec/integration/network/server/webrick_spec.rb +10 -11
  370. data/spec/integration/parser/catalog_spec.rb +85 -0
  371. data/spec/integration/provider/cron/crontab_spec.rb +11 -0
  372. data/spec/integration/provider/mount_spec.rb +1 -0
  373. data/spec/integration/transaction_spec.rb +8 -8
  374. data/spec/integration/type/file_spec.rb +1 -1
  375. data/spec/integration/util/settings_spec.rb +58 -11
  376. data/spec/lib/matchers/include_in_order.rb +21 -0
  377. data/spec/lib/matchers/include_in_order_spec.rb +30 -0
  378. data/spec/lib/matchers/relationship_graph_matchers.rb +48 -0
  379. data/spec/lib/puppet_spec/compiler.rb +24 -0
  380. data/spec/lib/puppet_spec/pops.rb +16 -0
  381. data/spec/spec_helper.rb +0 -1
  382. data/spec/unit/application/agent_spec.rb +145 -145
  383. data/spec/unit/application/apply_spec.rb +1 -1
  384. data/spec/unit/application/doc_spec.rb +1 -1
  385. data/spec/unit/application/face_base_spec.rb +3 -3
  386. data/spec/unit/application/facts_spec.rb +1 -0
  387. data/spec/unit/application/master_spec.rb +0 -15
  388. data/spec/unit/application/queue_spec.rb +6 -12
  389. data/spec/unit/application/resource_spec.rb +1 -1
  390. data/spec/unit/configurer/fact_handler_spec.rb +19 -50
  391. data/spec/unit/configurer_spec.rb +23 -7
  392. data/spec/unit/daemon_spec.rb +97 -121
  393. data/spec/unit/defaults_spec.rb +44 -0
  394. data/spec/unit/face/node_spec.rb +2 -2
  395. data/spec/unit/file_serving/configuration/parser_spec.rb +23 -33
  396. data/spec/unit/file_serving/configuration_spec.rb +2 -2
  397. data/spec/unit/file_serving/mount/file_spec.rb +4 -4
  398. data/spec/unit/forge/repository_spec.rb +9 -29
  399. data/spec/unit/graph/key_spec.rb +41 -0
  400. data/spec/unit/{rb_tree_map_spec.rb → graph/rb_tree_map_spec.rb} +7 -7
  401. data/spec/unit/graph/relationship_graph_spec.rb +393 -0
  402. data/spec/unit/graph/sequential_prioritizer_spec.rb +32 -0
  403. data/spec/unit/{simple_graph_spec.rb → graph/simple_graph.rb} +42 -254
  404. data/spec/unit/graph/title_hash_prioritizer_spec.rb +49 -0
  405. data/spec/unit/hiera_puppet_spec.rb +1 -1
  406. data/spec/unit/indirector/catalog/active_record_spec.rb +4 -2
  407. data/spec/unit/indirector/catalog/compiler_spec.rb +20 -26
  408. data/spec/unit/indirector/face_spec.rb +1 -1
  409. data/spec/unit/indirector/facts/facter_spec.rb +11 -1
  410. data/spec/unit/indirector/facts/network_device_spec.rb +11 -1
  411. data/spec/unit/indirector/hiera_spec.rb +1 -1
  412. data/spec/unit/indirector/instrumentation_data/local_spec.rb +1 -1
  413. data/spec/unit/indirector/instrumentation_listener/local_spec.rb +1 -1
  414. data/spec/unit/indirector/request_spec.rb +92 -39
  415. data/spec/unit/indirector/rest_spec.rb +1 -0
  416. data/spec/unit/indirector_spec.rb +2 -2
  417. data/spec/unit/interface/option_builder_spec.rb +1 -0
  418. data/spec/unit/interface/option_spec.rb +1 -0
  419. data/spec/unit/interface_spec.rb +2 -2
  420. data/spec/unit/module_tool/applications/installer_spec.rb +49 -2
  421. data/spec/unit/module_tool/metadata_spec.rb +13 -0
  422. data/spec/unit/network/authstore_spec.rb +1 -1
  423. data/spec/unit/network/format_handler_spec.rb +33 -282
  424. data/spec/unit/network/format_support_spec.rb +199 -0
  425. data/spec/unit/network/formats_spec.rb +2 -2
  426. data/spec/unit/network/http/connection_spec.rb +88 -7
  427. data/spec/unit/network/http/handler_spec.rb +271 -249
  428. data/spec/unit/network/http/rack/rest_spec.rb +1 -1
  429. data/spec/unit/network/http/webrick/rest_spec.rb +73 -22
  430. data/spec/unit/network/http_pool_spec.rb +40 -0
  431. data/spec/unit/network/server_spec.rb +18 -207
  432. data/spec/unit/node/facts_spec.rb +68 -17
  433. data/spec/unit/other/selinux_spec.rb +24 -20
  434. data/spec/unit/parameter/boolean_spec.rb +25 -0
  435. data/spec/unit/parameter/value_collection_spec.rb +7 -7
  436. data/spec/unit/parameter_spec.rb +10 -13
  437. data/spec/unit/parser/ast/function_spec.rb +4 -4
  438. data/spec/unit/parser/ast/leaf_spec.rb +45 -6
  439. data/spec/unit/parser/collector_spec.rb +3 -3
  440. data/spec/unit/parser/compiler_spec.rb +4 -3
  441. data/spec/unit/parser/functions/create_resources_spec.rb +9 -25
  442. data/spec/unit/parser/functions/extlookup_spec.rb +2 -2
  443. data/spec/unit/parser/functions/hiera_include_spec.rb +12 -0
  444. data/spec/unit/parser/functions/lookup_spec.rb +96 -0
  445. data/spec/unit/parser/functions/regsubst_spec.rb +2 -2
  446. data/spec/unit/parser/functions/split_spec.rb +2 -2
  447. data/spec/unit/parser/functions/sprintf_spec.rb +1 -1
  448. data/spec/unit/parser/functions/versioncmp_spec.rb +2 -2
  449. data/spec/unit/parser/functions_spec.rb +7 -7
  450. data/spec/unit/parser/lexer_spec.rb +1 -1
  451. data/spec/unit/parser/methods/collect_spec.rb +43 -0
  452. data/spec/unit/parser/resource_spec.rb +9 -9
  453. data/spec/unit/parser/scope_spec.rb +45 -2
  454. data/spec/unit/parser/type_loader_spec.rb +159 -175
  455. data/spec/unit/pops/binder/binder_spec.rb +62 -0
  456. data/spec/unit/pops/binder/bindings_checker_spec.rb +196 -0
  457. data/spec/unit/pops/binder/bindings_composer_spec.rb +89 -0
  458. data/spec/unit/pops/binder/bindings_validator_factory_spec.rb +18 -0
  459. data/spec/unit/pops/binder/config/binder_config_spec.rb +48 -0
  460. data/spec/unit/pops/binder/hiera2/bindings_provider_spec.rb +74 -0
  461. data/spec/unit/pops/binder/hiera2/config_spec.rb +61 -0
  462. data/spec/unit/pops/binder/hiera2/yaml_backend_spec.rb +33 -0
  463. data/spec/unit/pops/binder/injector_spec.rb +789 -0
  464. data/spec/unit/pops/containment_spec.rb +1 -0
  465. data/spec/unit/pops/issues_spec.rb +1 -1
  466. data/spec/unit/pops/parser/evaluating_parser_spec.rb +88 -0
  467. data/spec/unit/pops/parser/lexer_spec.rb +1 -1
  468. data/spec/unit/pops/parser/parse_calls_spec.rb +4 -0
  469. data/spec/unit/pops/parser/parser_spec.rb +1 -1
  470. data/spec/unit/pops/types/type_calculator_spec.rb +484 -0
  471. data/spec/unit/pops/types/type_factory_spec.rb +65 -0
  472. data/spec/unit/pops/types/type_parser_spec.rb +93 -0
  473. data/spec/unit/property/list_spec.rb +1 -1
  474. data/spec/unit/property/ordered_list_spec.rb +1 -1
  475. data/spec/unit/provider/aixobject_spec.rb +101 -0
  476. data/spec/unit/provider/augeas/augeas_spec.rb +14 -3
  477. data/spec/unit/provider/mcx/mcxcontent_spec.rb +52 -16
  478. data/spec/unit/provider/mount/parsed_spec.rb +44 -56
  479. data/spec/unit/provider/mount_spec.rb +11 -2
  480. data/spec/unit/provider/naginator_spec.rb +8 -0
  481. data/spec/unit/provider/package/apt_spec.rb +5 -1
  482. data/spec/unit/provider/package/aptitude_spec.rb +9 -5
  483. data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
  484. data/spec/unit/provider/package/dpkg_spec.rb +274 -99
  485. data/spec/unit/provider/package/openbsd_spec.rb +84 -1
  486. data/spec/unit/provider/package/opkg_spec.rb +3 -3
  487. data/spec/unit/provider/package/pip_spec.rb +16 -0
  488. data/spec/unit/provider/package/pkgdmg_spec.rb +62 -7
  489. data/spec/unit/provider/package/rpm_spec.rb +112 -21
  490. data/spec/unit/provider/package/urpmi.rb +80 -0
  491. data/spec/unit/provider/package/windows/exe_package_spec.rb +1 -1
  492. data/spec/unit/provider/package/yum_spec.rb +85 -0
  493. data/spec/unit/provider/package/zypper_spec.rb +25 -6
  494. data/spec/unit/provider/parsedfile_spec.rb +3 -2
  495. data/spec/unit/provider/service/init_spec.rb +10 -10
  496. data/spec/unit/provider/service/openrc_spec.rb +16 -0
  497. data/spec/unit/provider/service/openwrt_spec.rb +1 -1
  498. data/spec/unit/provider/service/redhat_spec.rb +7 -0
  499. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  500. data/spec/unit/provider/user/aix_spec.rb +89 -0
  501. data/spec/unit/provider/user/directoryservice_spec.rb +11 -4
  502. data/spec/unit/provider/user/user_role_add_spec.rb +18 -0
  503. data/spec/unit/provider_spec.rb +2 -13
  504. data/spec/unit/reports/http_spec.rb +1 -1
  505. data/spec/unit/resource/catalog_spec.rb +23 -97
  506. data/spec/unit/resource/resource_type.json +34 -0
  507. data/spec/unit/resource/status_spec.rb +56 -0
  508. data/spec/unit/resource/type_collection_spec.rb +6 -6
  509. data/spec/unit/resource/type_spec.rb +25 -5
  510. data/spec/unit/resource_spec.rb +68 -24
  511. data/spec/unit/run_spec.rb +16 -0
  512. data/spec/unit/scheduler/scheduler_spec.rb +14 -27
  513. data/spec/unit/semver_spec.rb +5 -0
  514. data/spec/unit/settings/enum_setting_spec.rb +27 -0
  515. data/spec/unit/settings_spec.rb +53 -44
  516. data/spec/unit/ssl/certificate_authority_spec.rb +155 -19
  517. data/spec/unit/transaction/additional_resource_generator_spec.rb +419 -0
  518. data/spec/unit/transaction/event_manager_spec.rb +2 -2
  519. data/spec/unit/transaction/event_spec.rb +57 -0
  520. data/spec/unit/transaction/report_spec.rb +66 -0
  521. data/spec/unit/transaction/resource_harness_spec.rb +27 -20
  522. data/spec/unit/transaction_spec.rb +182 -390
  523. data/spec/unit/type/augeas_spec.rb +3 -3
  524. data/spec/unit/type/component_spec.rb +0 -9
  525. data/spec/unit/type/computer_spec.rb +1 -1
  526. data/spec/unit/type/cron_spec.rb +2 -2
  527. data/spec/unit/type/exec_spec.rb +4 -2
  528. data/spec/unit/type/file/content_spec.rb +11 -0
  529. data/spec/unit/type/file/group_spec.rb +1 -1
  530. data/spec/unit/type/file_spec.rb +16 -8
  531. data/spec/unit/type/mount_spec.rb +445 -259
  532. data/spec/unit/type/package_spec.rb +4 -4
  533. data/spec/unit/type/resources_spec.rb +30 -1
  534. data/spec/unit/type/user_spec.rb +26 -3
  535. data/spec/unit/type/yumrepo_spec.rb +7 -27
  536. data/spec/unit/type/zone_spec.rb +4 -1
  537. data/spec/unit/type_spec.rb +66 -33
  538. data/spec/unit/util/backups_spec.rb +3 -3
  539. data/spec/unit/util/http_proxy_spec.rb +83 -0
  540. data/spec/unit/util/log_spec.rb +79 -8
  541. data/spec/unit/util/metric_spec.rb +12 -0
  542. data/spec/unit/util/monkey_patches_spec.rb +6 -0
  543. data/spec/unit/util/network_device/config_spec.rb +26 -64
  544. data/spec/unit/util/pidlock_spec.rb +4 -1
  545. data/spec/unit/util/tagging_spec.rb +5 -9
  546. data/spec/unit/util/warnings_spec.rb +1 -1
  547. data/spec/unit/util/watched_file_spec.rb +52 -0
  548. data/spec/unit/util/watcher/periodic_watcher_spec.rb +52 -0
  549. data/spec/unit/util/watcher_spec.rb +56 -0
  550. data/spec/unit/util_spec.rb +16 -0
  551. metadata +2767 -2576
  552. data/ext/debian/puppet.manpages +0 -32
  553. data/ext/osx/PackageInfo.plist +0 -36
  554. data/ext/osx/createpackage.sh +0 -187
  555. data/ext/redhat/rundir-perms.patch +0 -28
  556. data/lib/puppet/external/base64.rb +0 -19
  557. data/lib/puppet/util/graph.rb +0 -27
  558. data/lib/puppet/util/loadedfile.rb +0 -61
  559. data/lib/puppet/util/log_paths.rb +0 -22
  560. data/lib/puppet/util/subclass_loader.rb +0 -78
  561. data/spec/monkey_patches/publicize_methods.rb +0 -11
  562. data/spec/unit/util/loadedfile_spec.rb +0 -71
@@ -2,105 +2,93 @@
2
2
  require 'spec_helper'
3
3
  require 'shared_behaviours/all_parsedfile_providers'
4
4
 
5
- provider_class = Puppet::Type.type(:mount).provider(:parsed)
5
+ describe Puppet::Type.type(:mount).provider(:parsed), :unless => Puppet.features.microsoft_windows? do
6
6
 
7
- describe provider_class, :unless => Puppet.features.microsoft_windows? do
7
+ let :vfstab_sample do
8
+ "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-"
9
+ end
8
10
 
9
- before :each do
10
- @mount_class = Puppet::Type.type(:mount)
11
- @provider = @mount_class.provider(:parsed)
11
+ let :fstab_sample do
12
+ "/dev/vg00/lv01\t/spare \t \t ext3 defaults\t1 2"
12
13
  end
13
14
 
14
15
  # LAK:FIXME I can't mock Facter because this test happens at parse-time.
15
16
  it "should default to /etc/vfstab on Solaris" do
16
17
  pending "This test only works on Solaris" unless Facter.value(:osfamily) == 'Solaris'
17
- Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/vfstab'
18
+ described_class.default_target.should == '/etc/vfstab'
18
19
  end
19
20
 
20
21
  it "should default to /etc/fstab on anything else" do
21
22
  pending "This test does not work on Solaris" if Facter.value(:osfamily) == 'Solaris'
22
- Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/fstab'
23
+ described_class.default_target.should == '/etc/fstab'
23
24
  end
24
25
 
25
26
  describe "when parsing a line" do
26
-
27
27
  it "should not crash on incomplete lines in fstab" do
28
- parse = @provider.parse <<-FSTAB
28
+ parse = described_class.parse <<-FSTAB
29
29
  /dev/incomplete
30
30
  /dev/device name
31
31
  FSTAB
32
- lambda{ @provider.to_line(parse[0]) }.should_not raise_error
32
+ expect { described_class.to_line(parse[0]) }.to_not raise_error
33
33
  end
34
34
 
35
35
  # it_should_behave_like "all parsedfile providers",
36
36
  # provider_class, my_fixtures('*.fstab')
37
37
 
38
38
  describe "on Solaris", :if => Facter.value(:osfamily) == 'Solaris' do
39
-
40
- before :each do
41
- @example_line = "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-"
42
- end
43
-
44
39
  it "should extract device from the first field" do
45
- @provider.parse_line(@example_line)[:device].should == '/dev/dsk/c0d0s0'
40
+ described_class.parse_line(vfstab_sample)[:device].should == '/dev/dsk/c0d0s0'
46
41
  end
47
42
 
48
43
  it "should extract blockdevice from second field" do
49
- @provider.parse_line(@example_line)[:blockdevice].should == "/dev/rdsk/c0d0s0"
44
+ described_class.parse_line(vfstab_sample)[:blockdevice].should == "/dev/rdsk/c0d0s0"
50
45
  end
51
46
 
52
47
  it "should extract name from third field" do
53
- @provider.parse_line(@example_line)[:name].should == "/"
48
+ described_class.parse_line(vfstab_sample)[:name].should == "/"
54
49
  end
55
50
 
56
51
  it "should extract fstype from fourth field" do
57
- @provider.parse_line(@example_line)[:fstype].should == "ufs"
52
+ described_class.parse_line(vfstab_sample)[:fstype].should == "ufs"
58
53
  end
59
54
 
60
55
  it "should extract pass from fifth field" do
61
- @provider.parse_line(@example_line)[:pass].should == "1"
56
+ described_class.parse_line(vfstab_sample)[:pass].should == "1"
62
57
  end
63
58
 
64
59
  it "should extract atboot from sixth field" do
65
- @provider.parse_line(@example_line)[:atboot].should == "no"
60
+ described_class.parse_line(vfstab_sample)[:atboot].should == "no"
66
61
  end
67
62
 
68
63
  it "should extract options from seventh field" do
69
- @provider.parse_line(@example_line)[:options].should == "-"
64
+ described_class.parse_line(vfstab_sample)[:options].should == "-"
70
65
  end
71
-
72
66
  end
73
67
 
74
68
  describe "on other platforms than Solaris", :if => Facter.value(:osfamily) != 'Solaris' do
75
-
76
- before :each do
77
- @example_line = "/dev/vg00/lv01\t/spare \t \t ext3 defaults\t1 2"
78
- end
79
-
80
69
  it "should extract device from the first field" do
81
- @provider.parse_line(@example_line)[:device].should == '/dev/vg00/lv01'
70
+ described_class.parse_line(fstab_sample)[:device].should == '/dev/vg00/lv01'
82
71
  end
83
72
 
84
73
  it "should extract name from second field" do
85
- @provider.parse_line(@example_line)[:name].should == "/spare"
74
+ described_class.parse_line(fstab_sample)[:name].should == "/spare"
86
75
  end
87
76
 
88
77
  it "should extract fstype from third field" do
89
- @provider.parse_line(@example_line)[:fstype].should == "ext3"
78
+ described_class.parse_line(fstab_sample)[:fstype].should == "ext3"
90
79
  end
91
80
 
92
81
  it "should extract options from fourth field" do
93
- @provider.parse_line(@example_line)[:options].should == "defaults"
82
+ described_class.parse_line(fstab_sample)[:options].should == "defaults"
94
83
  end
95
84
 
96
85
  it "should extract dump from fifth field" do
97
- @provider.parse_line(@example_line)[:dump].should == "1"
86
+ described_class.parse_line(fstab_sample)[:dump].should == "1"
98
87
  end
99
88
 
100
89
  it "should extract options from sixth field" do
101
- @provider.parse_line(@example_line)[:pass].should == "2"
90
+ described_class.parse_line(fstab_sample)[:pass].should == "2"
102
91
  end
103
-
104
92
  end
105
93
 
106
94
  end
@@ -108,8 +96,8 @@ FSTAB
108
96
  describe "mountinstances" do
109
97
  it "should get name from mountoutput found on Solaris" do
110
98
  Facter.stubs(:value).with(:osfamily).returns 'Solaris'
111
- @provider.stubs(:mountcmd).returns(File.read(my_fixture('solaris.mount')))
112
- mounts = @provider.mountinstances
99
+ described_class.stubs(:mountcmd).returns(File.read(my_fixture('solaris.mount')))
100
+ mounts = described_class.mountinstances
113
101
  mounts.size.should == 6
114
102
  mounts[0].should == { :name => '/', :mounted => :yes }
115
103
  mounts[1].should == { :name => '/proc', :mounted => :yes }
@@ -121,8 +109,8 @@ FSTAB
121
109
 
122
110
  it "should get name from mountoutput found on HP-UX" do
123
111
  Facter.stubs(:value).with(:osfamily).returns 'HP-UX'
124
- @provider.stubs(:mountcmd).returns(File.read(my_fixture('hpux.mount')))
125
- mounts = @provider.mountinstances
112
+ described_class.stubs(:mountcmd).returns(File.read(my_fixture('hpux.mount')))
113
+ mounts = described_class.mountinstances
126
114
  mounts.size.should == 17
127
115
  mounts[0].should == { :name => '/', :mounted => :yes }
128
116
  mounts[1].should == { :name => '/devices', :mounted => :yes }
@@ -145,8 +133,8 @@ FSTAB
145
133
 
146
134
  it "should get name from mountoutput found on Darwin" do
147
135
  Facter.stubs(:value).with(:osfamily).returns 'Darwin'
148
- @provider.stubs(:mountcmd).returns(File.read(my_fixture('darwin.mount')))
149
- mounts = @provider.mountinstances
136
+ described_class.stubs(:mountcmd).returns(File.read(my_fixture('darwin.mount')))
137
+ mounts = described_class.mountinstances
150
138
  mounts.size.should == 6
151
139
  mounts[0].should == { :name => '/', :mounted => :yes }
152
140
  mounts[1].should == { :name => '/dev', :mounted => :yes }
@@ -158,8 +146,8 @@ FSTAB
158
146
 
159
147
  it "should get name from mountoutput found on Linux" do
160
148
  Facter.stubs(:value).with(:osfamily).returns 'Gentoo'
161
- @provider.stubs(:mountcmd).returns(File.read(my_fixture('linux.mount')))
162
- mounts = @provider.mountinstances
149
+ described_class.stubs(:mountcmd).returns(File.read(my_fixture('linux.mount')))
150
+ mounts = described_class.mountinstances
163
151
  mounts[0].should == { :name => '/', :mounted => :yes }
164
152
  mounts[1].should == { :name => '/lib64/rc/init.d', :mounted => :yes }
165
153
  mounts[2].should == { :name => '/sys', :mounted => :yes }
@@ -169,8 +157,8 @@ FSTAB
169
157
 
170
158
  it "should get name from mountoutput found on AIX" do
171
159
  Facter.stubs(:value).with(:osfamily).returns 'AIX'
172
- @provider.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount')))
173
- mounts = @provider.mountinstances
160
+ described_class.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount')))
161
+ mounts = described_class.mountinstances
174
162
  mounts[0].should == { :name => '/', :mounted => :yes }
175
163
  mounts[1].should == { :name => '/tmp', :mounted => :yes }
176
164
  mounts[2].should == { :name => '/home', :mounted => :yes }
@@ -179,8 +167,8 @@ FSTAB
179
167
  end
180
168
 
181
169
  it "should raise an error if a line is not understandable" do
182
- @provider.stubs(:mountcmd).returns("bazinga!")
183
- lambda { @provider.mountinstances }.should raise_error Puppet::Error
170
+ described_class.stubs(:mountcmd).returns("bazinga!")
171
+ expect { described_class.mountinstances }.to raise_error Puppet::Error, 'Could not understand line bazinga! from mount output'
184
172
  end
185
173
 
186
174
  end
@@ -203,7 +191,7 @@ FSTAB
203
191
  # Stub the mount output to our fixture.
204
192
  begin
205
193
  mount = my_fixture(platform + '.mount')
206
- @provider.stubs(:mountcmd).returns File.read(mount)
194
+ described_class.stubs(:mountcmd).returns File.read(mount)
207
195
  rescue
208
196
  pending "is #{platform}.mount missing at this point?"
209
197
  end
@@ -211,8 +199,8 @@ FSTAB
211
199
  # Note: we have to stub default_target before creating resources
212
200
  # because it is used by Puppet::Type::Mount.new to populate the
213
201
  # :target property.
214
- @provider.stubs(:default_target).returns fstab
215
- @retrieve = @provider.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}}
202
+ described_class.stubs(:default_target).returns fstab
203
+ @retrieve = described_class.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}}
216
204
  end
217
205
 
218
206
  # Following mountpoint are present in all fstabs/mountoutputs
@@ -246,7 +234,7 @@ FSTAB
246
234
  # Stub the mount output to our fixture.
247
235
  begin
248
236
  mount = my_fixture(platform + '.mount')
249
- @provider.stubs(:mountcmd).returns File.read(mount)
237
+ described_class.stubs(:mountcmd).returns File.read(mount)
250
238
  rescue
251
239
  pending "is #{platform}.mount missing at this point?"
252
240
  end
@@ -254,7 +242,7 @@ FSTAB
254
242
  # Note: we have to stub default_target before creating resources
255
243
  # because it is used by Puppet::Type::Mount.new to populate the
256
244
  # :target property.
257
- @provider.stubs(:default_target).returns fstab
245
+ described_class.stubs(:default_target).returns fstab
258
246
 
259
247
  @res_ghost = Puppet::Type::Mount.new(:name => '/ghost') # in no fake fstab
260
248
  @res_mounted = Puppet::Type::Mount.new(:name => '/') # in every fake fstab
@@ -270,24 +258,24 @@ FSTAB
270
258
 
271
259
  it "should set :ensure to :unmounted if found in fstab but not mounted" do
272
260
  pending("Solaris:Unable to stub Operating System Fact at runtime", :if => Facter.value(:osfamily) == "Solaris")
273
- @provider.prefetch(@resource_hash)
261
+ described_class.prefetch(@resource_hash)
274
262
  @res_unmounted.provider.get(:ensure).should == :unmounted
275
263
  end
276
264
 
277
265
  it "should set :ensure to :ghost if not found in fstab but mounted" do
278
266
  pending("Solaris:Unable to stub Operating System Fact at runtime", :if => Facter.value(:osfamily) == "Solaris")
279
- @provider.prefetch(@resource_hash)
267
+ described_class.prefetch(@resource_hash)
280
268
  @res_ghost.provider.get(:ensure).should == :ghost
281
269
  end
282
270
 
283
271
  it "should set :ensure to :mounted if found in fstab and mounted" do
284
272
  pending("Solaris:Unable to stub Operating System Fact at runtime", :if => Facter.value(:osfamily) == "Solaris")
285
- @provider.prefetch(@resource_hash)
273
+ described_class.prefetch(@resource_hash)
286
274
  @res_mounted.provider.get(:ensure).should == :mounted
287
275
  end
288
276
 
289
277
  it "should set :ensure to :absent if not found in fstab and not mounted" do
290
- @provider.prefetch(@resource_hash)
278
+ described_class.prefetch(@resource_hash)
291
279
  @res_absent.provider.get(:ensure).should == :absent
292
280
  end
293
281
  end
@@ -29,9 +29,18 @@ describe Puppet::Provider::Mount do
29
29
  @mounter.mount
30
30
  end
31
31
 
32
- it "should add the options following '-o' if they exist and are not set to :absent" do
32
+ it "should add the options following '-o' on MacOS if they exist and are not set to :absent" do
33
+ Facter.expects(:value).with(:kernel).returns 'Darwin'
33
34
  @mounter.stubs(:options).returns("ro")
34
- @mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
35
+ @mounter.expects(:mountcmd).with '-o', 'ro', '/'
36
+
37
+ @mounter.mount
38
+ end
39
+
40
+ it "should not explicitly pass mount options on systems other than MacOS" do
41
+ Facter.expects(:value).with(:kernel).returns 'HP-UX'
42
+ @mounter.stubs(:options).returns("ro")
43
+ @mounter.expects(:mountcmd).with '/'
35
44
 
36
45
  @mounter.mount
37
46
  end
@@ -55,3 +55,11 @@ describe Puppet::Provider::Naginator do
55
55
  @class.should_not be_skip_record("foo")
56
56
  end
57
57
  end
58
+
59
+ describe Nagios::Base do
60
+ it "should not turn set parameters into arrays #17871" do
61
+ obj = Nagios::Base.create('host')
62
+ obj.host_name = "my_hostname"
63
+ obj.host_name.should == "my_hostname"
64
+ end
65
+ end
@@ -8,7 +8,11 @@ describe provider do
8
8
  @resource = stub 'resource', :[] => "asdf"
9
9
  @provider = provider.new(@resource)
10
10
 
11
- @fakeresult = "install ok installed asdf 1.0\n"
11
+ @fakeresult = <<-EOF
12
+ install ok installed asdf 1.0 "asdf summary
13
+ asdf multiline description
14
+ with multiple lines
15
+ EOF
12
16
  end
13
17
 
14
18
  it "should be versionable" do
@@ -10,13 +10,17 @@ describe Puppet::Type.type(:package).provider(:aptitude) do
10
10
  it { should be_versionable }
11
11
 
12
12
  context "when retrieving ensure" do
13
- { :absent => "deinstall ok config-files faff 1.2.3-1\n",
14
- "1.2.3-1" => "install ok installed faff 1.2.3-1\n",
13
+ before do
14
+ described_class.stubs(:command).with(:dpkgquery).returns 'myquery'
15
+ end
16
+
17
+ { :absent => "deinstall ok config-files faff 1.2.3-1 :DESC: faff summary\n:DESC:\n",
18
+ "1.2.3-1" => "install ok installed faff 1.2.3-1 :DESC: faff summary\n:DESC:\n",
15
19
  }.each do |expect, output|
16
20
  it "should detect #{expect} packages" do
17
- pkg.provider.expects(:dpkgquery).
18
- with('-W', '--showformat', '${Status} ${Package} ${Version}\n', 'faff').
19
- returns(output)
21
+ Puppet::Util::Execution.expects(:execpipe).
22
+ with(['myquery', '-W', '--showformat', "'${Status} ${Package} ${Version} :DESC: ${Description}\\n:DESC:\\n'", 'faff']).
23
+ yields(StringIO.new(output))
20
24
 
21
25
  pkg.property(:ensure).retrieve.should == expect
22
26
  end
@@ -19,7 +19,7 @@ describe Puppet::Type.type(:package).provider(:aptrpm) do
19
19
  def rpm
20
20
  pkg.provider.expects(:rpm).
21
21
  with('-q', 'faff', '--nosignature', '--nodigest', '--qf',
22
- "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n")
22
+ "'%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH} :DESC: %{SUMMARY}\\n'")
23
23
  end
24
24
 
25
25
  it "should report absent packages" do
@@ -28,7 +28,7 @@ describe Puppet::Type.type(:package).provider(:aptrpm) do
28
28
  end
29
29
 
30
30
  it "should report present packages correctly" do
31
- rpm.returns("faff-1.2.3-1 0 1.2.3-1 5 i686\n")
31
+ rpm.returns("faff-1.2.3-1 0 1.2.3-1 5 i686 :DESC: faff desc\n")
32
32
  pkg.property(:ensure).retrieve.should == "1.2.3-1-5"
33
33
  end
34
34
  end
@@ -2,226 +2,401 @@
2
2
  require 'spec_helper'
3
3
  require 'stringio'
4
4
 
5
- provider = Puppet::Type.type(:package).provider(:dpkg)
5
+ provider_class = Puppet::Type.type(:package).provider(:dpkg)
6
+
7
+ describe provider_class do
8
+ let(:bash_version) { '4.2-5ubuntu3' }
9
+ let(:bash_installed_output) do <<-EOS
10
+ install ok installed bash #{bash_version} :DESC: GNU Bourne Again SHell
11
+ Bash is an sh-compatible command language interpreter that executes
12
+ commands read from the standard input or from a file. Bash also
13
+ incorporates useful features from the Korn and C shells (ksh and csh).
14
+ .
15
+ Bash is ultimately intended to be a conformant implementation of the
16
+ IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).
17
+ .
18
+ The Programmable Completion Code, by Ian Macdonald, is now found in
19
+ the bash-completion package.
20
+ :DESC:
21
+ EOS
22
+ end
23
+ let(:bash_installed_io) { StringIO.new(bash_installed_output) }
24
+
25
+ let(:vim_installed_output) do <<-EOS
26
+ install ok installed vim 2:7.3.547-6ubuntu5 :DESC: Vi IMproved - enhanced vi editor
27
+ Vim is an almost compatible version of the UNIX editor Vi.
28
+ .
29
+ Many new features have been added: multi level undo, syntax
30
+ highlighting, command line history, on-line help, filename
31
+ completion, block operations, folding, Unicode support, etc.
32
+ .
33
+ This package contains a version of vim compiled with a rather
34
+ standard set of features. This package does not provide a GUI
35
+ version of Vim. See the other vim-* packages if you need more
36
+ (or less).
37
+ :DESC:
38
+ EOS
39
+ end
6
40
 
7
- describe provider do
8
- before do
9
- @resource = stub 'resource', :[] => "asdf"
10
- @provider = provider.new(@resource)
11
- @provider.expects(:execute).never # forbid "manual" executions
41
+ let(:all_installed_io) { StringIO.new([bash_installed_output, vim_installed_output].join) }
42
+ let(:args) { ['myquery', '-W', '--showformat', %Q{'${Status} ${Package} ${Version} :DESC: ${Description}\\n:DESC:\\n'}] }
43
+ let(:resource_name) { 'package' }
44
+ let(:resource) { stub 'resource', :[] => resource_name }
45
+ let(:provider) { provider_class.new(resource) }
12
46
 
13
- @fakeresult = "install ok installed asdf 1.0\n"
47
+ before do
48
+ provider_class.stubs(:command).with(:dpkgquery).returns 'myquery'
14
49
  end
15
50
 
16
51
  it "should have documentation" do
17
- provider.doc.should be_instance_of(String)
52
+ provider_class.doc.should be_instance_of(String)
18
53
  end
19
54
 
20
55
  describe "when listing all instances" do
21
- before do
22
- provider.stubs(:command).with(:dpkgquery).returns "myquery"
23
- end
24
56
 
25
57
  it "should use dpkg-query" do
26
- provider.expects(:command).with(:dpkgquery).returns "myquery"
27
- Puppet::Util::Execution.expects(:execpipe).with("myquery -W --showformat '${Status} ${Package} ${Version}\\n'").yields StringIO.new(@fakeresult)
58
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields bash_installed_io
28
59
 
29
- provider.instances
60
+ provider_class.instances
30
61
  end
31
62
 
32
- it "should create and return an instance with each parsed line from dpkg-query" do
33
- pipe = mock 'pipe'
34
- pipe.expects(:each).never
35
- pipe.expects(:each_line).yields @fakeresult
36
- Puppet::Util::Execution.expects(:execpipe).yields pipe
63
+ it "should create and return an instance for a single dpkg-query entry" do
64
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields bash_installed_io
37
65
 
38
- asdf = mock 'pkg1'
39
- provider.expects(:new).with(:ensure => "1.0", :error => "ok", :desired => "install", :name => "asdf", :status => "installed", :provider => :dpkg).returns asdf
66
+ installed = mock 'bash'
67
+ provider_class.expects(:new).with(:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :status => "installed", :description => "GNU Bourne Again SHell", :provider => :dpkg).returns installed
40
68
 
41
- provider.instances.should == [asdf]
69
+ provider_class.instances.should == [installed]
70
+ end
71
+
72
+ it "should parse multiple dpkg-query multi-line entries in the output" do
73
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields all_installed_io
74
+
75
+ bash = mock 'bash'
76
+ provider_class.expects(:new).with(:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :status => "installed", :description => "GNU Bourne Again SHell", :provider => :dpkg).returns bash
77
+ vim = mock 'vim'
78
+ provider_class.expects(:new).with(:ensure => "2:7.3.547-6ubuntu5", :error => "ok", :desired => "install", :name => "vim", :status => "installed", :description => "Vi IMproved - enhanced vi editor", :provider => :dpkg).returns vim
79
+
80
+ provider_class.instances.should == [bash, vim]
42
81
  end
43
82
 
44
83
  it "should warn on and ignore any lines it does not understand" do
45
- pipe = mock 'pipe'
46
- pipe.expects(:each).never
47
- pipe.expects(:each_line).yields "foobar"
48
- Puppet::Util::Execution.expects(:execpipe).yields pipe
84
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields StringIO.new('foobar')
49
85
 
50
86
  Puppet.expects(:warning)
51
- provider.expects(:new).never
87
+ provider_class.expects(:new).never
88
+
89
+ provider_class.instances.should == []
90
+ end
91
+
92
+ it "should not warn on extra multiline description lines which we are ignoring" do
93
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields all_installed_io
52
94
 
53
- provider.instances.should == []
95
+ Puppet.expects(:warning).never
96
+ provider_class.instances
97
+ end
98
+
99
+ it "should warn if encounters bad lines between good entries without failing" do
100
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields StringIO.new([bash_installed_output, "foobar\n", vim_installed_output].join)
101
+
102
+ Puppet.expects(:warning)
103
+
104
+ bash = mock 'bash'
105
+ vim = mock 'vim'
106
+ provider_class.expects(:new).twice.returns(bash, vim)
107
+
108
+ provider_class.instances.should == [bash, vim]
109
+ end
110
+
111
+ it "should warn on a broken entry while still parsing a good one" do
112
+ Puppet::Util::Execution.expects(:execpipe).with(args).yields StringIO.new([
113
+ bash_installed_output,
114
+ %Q{install ok installed broken 1.0 this shouldn't be here :DESC: broken description\n extra description\n:DESC:\n},
115
+ vim_installed_output,
116
+ ].join)
117
+
118
+ Puppet.expects(:warning).times(3)
119
+
120
+ bash = mock('bash')
121
+ vim = mock('vim')
122
+ saved = mock('saved')
123
+ provider_class.expects(:new).twice.returns(bash, vim)
124
+
125
+ provider_class.instances.should == [bash, vim]
54
126
  end
55
127
  end
56
128
 
57
129
  describe "when querying the current state" do
58
- it "should use dpkg-query" do
59
- @provider.expects(:dpkgquery).with("-W", "--showformat",'${Status} ${Package} ${Version}\\n', "asdf").returns @fakeresult
130
+ let(:query_args) { args.push(resource_name) }
60
131
 
61
- @provider.query
132
+ before do
133
+ provider.expects(:execute).never # forbid "manual" executions
134
+ end
135
+
136
+ # @return [StringIO] of bash dpkg-query output with :search string replaced
137
+ # by :replace string.
138
+ def replace_in_bash_output(search, replace)
139
+ StringIO.new(bash_installed_output.gsub(search, replace))
140
+ end
141
+
142
+ it "should use exec-pipe" do
143
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields bash_installed_io
144
+
145
+ provider.query
62
146
  end
63
147
 
64
148
  it "should consider the package purged if dpkg-query fails" do
65
- @provider.expects(:dpkgquery).raises Puppet::ExecutionFailure.new("eh")
149
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).raises Puppet::ExecutionFailure.new("eh")
66
150
 
67
- @provider.query[:ensure].should == :purged
151
+ provider.query[:ensure].should == :purged
68
152
  end
69
153
 
70
- it "should return a hash of the found status with the desired state, error state, status, name, and 'ensure'" do
71
- @provider.expects(:dpkgquery).returns @fakeresult
154
+ it "should return a hash of the found package status for an installed package" do
155
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields bash_installed_io
72
156
 
73
- @provider.query.should == {:ensure => "1.0", :error => "ok", :desired => "install", :name => "asdf", :status => "installed", :provider => :dpkg}
157
+ provider.query.should == {:ensure => "4.2-5ubuntu3", :error => "ok", :desired => "install", :name => "bash", :status => "installed", :provider => :dpkg, :description => "GNU Bourne Again SHell"}
74
158
  end
75
159
 
76
160
  it "should consider the package absent if the dpkg-query result cannot be interpreted" do
77
- @provider.expects(:dpkgquery).returns "somebaddata"
161
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields StringIO.new("somebaddata")
78
162
 
79
- @provider.query[:ensure].should == :absent
163
+ provider.query[:ensure].should == :absent
80
164
  end
81
165
 
82
166
  it "should fail if an error is discovered" do
83
- @provider.expects(:dpkgquery).returns @fakeresult.sub("ok", "error")
167
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("ok", "error")
84
168
 
85
- lambda { @provider.query }.should raise_error(Puppet::Error)
169
+ lambda { provider.query }.should raise_error(Puppet::Error)
86
170
  end
87
171
 
88
172
  it "should consider the package purged if it is marked 'not-installed'" do
89
- @provider.expects(:dpkgquery).returns @fakeresult.sub("installed", "not-installed")
173
+ not_installed_bash = bash_installed_output.gsub("installed", "not-installed")
174
+ not_installed_bash.gsub!(bash_version, "")
175
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields StringIO.new(not_installed_bash)
90
176
 
91
- @provider.query[:ensure].should == :purged
177
+ provider.query[:ensure].should == :purged
92
178
  end
93
179
 
94
180
  it "should consider the package absent if it is marked 'config-files'" do
95
- @provider.expects(:dpkgquery).returns @fakeresult.sub("installed", "config-files")
96
- @provider.query[:ensure].should == :absent
181
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("installed", "config-files")
182
+ provider.query[:ensure].should == :absent
97
183
  end
98
184
 
99
185
  it "should consider the package absent if it is marked 'half-installed'" do
100
- @provider.expects(:dpkgquery).returns @fakeresult.sub("installed", "half-installed")
101
- @provider.query[:ensure].should == :absent
186
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("installed", "half-installed")
187
+ provider.query[:ensure].should == :absent
102
188
  end
103
189
 
104
190
  it "should consider the package absent if it is marked 'unpacked'" do
105
- @provider.expects(:dpkgquery).returns @fakeresult.sub("installed", "unpacked")
106
- @provider.query[:ensure].should == :absent
191
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("installed", "unpacked")
192
+ provider.query[:ensure].should == :absent
107
193
  end
108
194
 
109
195
  it "should consider the package absent if it is marked 'half-configured'" do
110
- @provider.expects(:dpkgquery).returns @fakeresult.sub("installed", "half-configured")
111
- @provider.query[:ensure].should == :absent
196
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("installed", "half-configured")
197
+ provider.query[:ensure].should == :absent
112
198
  end
113
199
 
114
200
  it "should consider the package held if its state is 'hold'" do
115
- @provider.expects(:dpkgquery).returns @fakeresult.sub("install", "hold")
116
- @provider.query[:ensure].should == :held
201
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields replace_in_bash_output("install", "hold")
202
+ provider.query[:ensure].should == :held
203
+ end
204
+ end
205
+
206
+ describe "parsing tests" do
207
+ let(:resource_name) { 'name' }
208
+ let(:package_hash) do
209
+ {
210
+ :desired => 'desired',
211
+ :error => 'ok',
212
+ :status => 'status',
213
+ :name => resource_name,
214
+ :ensure => 'ensure',
215
+ :description => 'summary text',
216
+ :provider => :dpkg,
217
+ }
218
+ end
219
+ let(:query_args) { args.push(resource_name) }
220
+
221
+ it "warns about excess lines if encounters a delimiter in description but does not fail" do
222
+ broken_description = <<-EOS
223
+ desired ok status name ensure :DESC: summary text
224
+ more description
225
+ :DESC:
226
+ 1 whoops ^^ should not happen, because dpkg-query is supposed to prefix description lines with
227
+ 2 whitespace. So we should see three warnings for these four additional lines when we try
228
+ 3 and process next-pkg (vv the :DESC: is line number 4)
229
+ :DESC:
230
+ desired ok status next-pkg ensure :DESC: next summary
231
+ :DESC:
232
+ EOS
233
+ Puppet.expects(:warning).times(4)
234
+
235
+ pipe = StringIO.new(broken_description)
236
+ provider_class.parse_multi_line(pipe).should == package_hash
237
+
238
+ next_package = package_hash.merge(:name => 'next-pkg', :description => 'next summary')
239
+
240
+ hash = provider_class.parse_multi_line(pipe) until hash # warn about bad lines
241
+ hash.should == next_package
242
+ end
243
+
244
+ def parser_test(dpkg_output_string, gold_hash)
245
+ pipe = StringIO.new(dpkg_output_string)
246
+ Puppet::Util::Execution.expects(:execpipe).with(query_args).yields pipe
247
+ Puppet.expects(:warning).never
248
+
249
+ provider.query.should == gold_hash
250
+ end
251
+
252
+ it "should parse properly even if delimiter is in version" do
253
+ version_delimiter = <<-EOS
254
+ desired ok status name 1.2.3-:DESC: :DESC: summary text
255
+ more description
256
+ :DESC:
257
+ EOS
258
+ parser_test(version_delimiter, package_hash.merge(:ensure => '1.2.3-:DESC:'))
259
+ end
260
+
261
+ it "should parse properly even if delimiter is name" do
262
+ name_delimiter = <<-EOS
263
+ desired ok status :DESC: ensure :DESC: summary text
264
+ more description
265
+ :DESC:
266
+ EOS
267
+ parser_test(name_delimiter, package_hash.merge(:name => ':DESC:'))
268
+ end
269
+
270
+ it "should parse properly even if optional ensure field is missing" do
271
+ no_ensure = <<-EOS
272
+ desired ok status name :DESC: summary text
273
+ more description and note^ two spaces surround the hole where 'ensure' field would be...
274
+ :DESC:
275
+ EOS
276
+ parser_test(no_ensure, package_hash.merge(:ensure => ''))
277
+ end
278
+
279
+ it "should parse properly even if extra delimiter is in summary" do
280
+ extra_description_delimiter = <<-EOS
281
+ desired ok status name ensure :DESC: summary text
282
+ :DESC: should be completely ignored because of leading space which dpkg-query should ensure
283
+ :DESC:
284
+ EOS
285
+ parser_test(extra_description_delimiter, package_hash)
286
+ end
287
+
288
+ it "should parse properly even if package description is completely missing" do
289
+ no_description = "desired ok status name ensure :DESC: \n:DESC:"
290
+ parser_test(no_description, package_hash.merge(:description => ''))
117
291
  end
118
292
  end
119
293
 
120
294
  it "should be able to install" do
121
- @provider.should respond_to(:install)
295
+ provider.should respond_to(:install)
122
296
  end
123
297
 
124
298
  describe "when installing" do
125
299
  before do
126
- @resource.stubs(:[]).with(:source).returns "mypkg"
300
+ resource.stubs(:[]).with(:source).returns "mypkg"
127
301
  end
128
302
 
129
303
  it "should fail to install if no source is specified in the resource" do
130
- @resource.expects(:[]).with(:source).returns nil
304
+ resource.expects(:[]).with(:source).returns nil
131
305
 
132
- lambda { @provider.install }.should raise_error(ArgumentError)
306
+ lambda { provider.install }.should raise_error(ArgumentError)
133
307
  end
134
308
 
135
309
  it "should use 'dpkg -i' to install the package" do
136
- @resource.expects(:[]).with(:source).returns "mypackagefile"
137
- @provider.expects(:unhold)
138
- @provider.expects(:dpkg).with { |*command| command[-1] == "mypackagefile" and command[-2] == "-i" }
310
+ resource.expects(:[]).with(:source).returns "mypackagefile"
311
+ provider.expects(:unhold)
312
+ provider.expects(:dpkg).with { |*command| command[-1] == "mypackagefile" and command[-2] == "-i" }
139
313
 
140
- @provider.install
314
+ provider.install
141
315
  end
142
316
 
143
317
  it "should keep old config files if told to do so" do
144
- @resource.expects(:[]).with(:configfiles).returns :keep
145
- @provider.expects(:unhold)
146
- @provider.expects(:dpkg).with { |*command| command[0] == "--force-confold" }
318
+ resource.expects(:[]).with(:configfiles).returns :keep
319
+ provider.expects(:unhold)
320
+ provider.expects(:dpkg).with { |*command| command[0] == "--force-confold" }
147
321
 
148
- @provider.install
322
+ provider.install
149
323
  end
150
324
 
151
325
  it "should replace old config files if told to do so" do
152
- @resource.expects(:[]).with(:configfiles).returns :replace
153
- @provider.expects(:unhold)
154
- @provider.expects(:dpkg).with { |*command| command[0] == "--force-confnew" }
326
+ resource.expects(:[]).with(:configfiles).returns :replace
327
+ provider.expects(:unhold)
328
+ provider.expects(:dpkg).with { |*command| command[0] == "--force-confnew" }
155
329
 
156
- @provider.install
330
+ provider.install
157
331
  end
158
332
 
159
333
  it "should ensure any hold is removed" do
160
- @provider.expects(:unhold).once
161
- @provider.expects(:dpkg)
162
- @provider.install
334
+ provider.expects(:unhold).once
335
+ provider.expects(:dpkg)
336
+ provider.install
163
337
  end
164
338
  end
165
339
 
166
340
  describe "when holding or unholding" do
341
+ let(:tempfile) { stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file" }
342
+
167
343
  before do
168
- @tempfile = stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file"
169
- @tempfile.stubs(:write)
170
- Tempfile.stubs(:new).returns @tempfile
344
+ tempfile.stubs(:write)
345
+ Tempfile.stubs(:new).returns tempfile
171
346
  end
172
347
 
173
348
  it "should install first if holding" do
174
- @provider.stubs(:execute)
175
- @provider.expects(:install).once
176
- @provider.hold
349
+ provider.stubs(:execute)
350
+ provider.expects(:install).once
351
+ provider.hold
177
352
  end
178
353
 
179
354
  it "should execute dpkg --set-selections when holding" do
180
- @provider.stubs(:install)
181
- @provider.expects(:execute).with([:dpkg, '--set-selections'], {:failonfail => false, :combine => false, :stdinfile => @tempfile.path}).once
182
- @provider.hold
355
+ provider.stubs(:install)
356
+ provider.expects(:execute).with([:dpkg, '--set-selections'], {:failonfail => false, :combine => false, :stdinfile => tempfile.path}).once
357
+ provider.hold
183
358
  end
184
359
 
185
360
  it "should execute dpkg --set-selections when unholding" do
186
- @provider.stubs(:install)
187
- @provider.expects(:execute).with([:dpkg, '--set-selections'], {:failonfail => false, :combine => false, :stdinfile => @tempfile.path}).once
188
- @provider.hold
361
+ provider.stubs(:install)
362
+ provider.expects(:execute).with([:dpkg, '--set-selections'], {:failonfail => false, :combine => false, :stdinfile => tempfile.path}).once
363
+ provider.hold
189
364
  end
190
365
  end
191
366
 
192
367
  it "should use :install to update" do
193
- @provider.expects(:install)
194
- @provider.update
368
+ provider.expects(:install)
369
+ provider.update
195
370
  end
196
371
 
197
372
  describe "when determining latest available version" do
198
373
  it "should return the version found by dpkg-deb" do
199
- @resource.expects(:[]).with(:source).returns "myfile"
200
- @provider.expects(:dpkg_deb).with { |*command| command[-1] == "myfile" }.returns "asdf\t1.0"
201
- @provider.latest.should == "1.0"
374
+ resource.expects(:[]).with(:source).returns "myfile"
375
+ provider.expects(:dpkg_deb).with { |*command| command[-1] == "myfile" }.returns "package\t1.0"
376
+ provider.latest.should == "1.0"
202
377
  end
203
378
 
204
379
  it "should warn if the package file contains a different package" do
205
- @provider.expects(:dpkg_deb).returns("foo\tversion")
206
- @provider.expects(:warning)
207
- @provider.latest
380
+ provider.expects(:dpkg_deb).returns("foo\tversion")
381
+ provider.expects(:warning)
382
+ provider.latest
208
383
  end
209
384
 
210
385
  it "should cope with names containing ++" do
211
- @resource = stub 'resource', :[] => "asdf++"
212
- @provider = provider.new(@resource)
213
- @provider.expects(:dpkg_deb).returns "asdf++\t1.0"
214
- @provider.latest.should == "1.0"
386
+ resource = stub 'resource', :[] => "package++"
387
+ provider = provider_class.new(resource)
388
+ provider.expects(:dpkg_deb).returns "package++\t1.0"
389
+ provider.latest.should == "1.0"
215
390
  end
216
391
  end
217
392
 
218
393
  it "should use 'dpkg -r' to uninstall" do
219
- @provider.expects(:dpkg).with("-r", "asdf")
220
- @provider.uninstall
394
+ provider.expects(:dpkg).with("-r", resource_name)
395
+ provider.uninstall
221
396
  end
222
397
 
223
398
  it "should use 'dpkg --purge' to purge" do
224
- @provider.expects(:dpkg).with("--purge", "asdf")
225
- @provider.purge
399
+ provider.expects(:dpkg).with("--purge", resource_name)
400
+ provider.purge
226
401
  end
227
402
  end