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
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'matchers/include_in_order'
3
+ require 'puppet_spec/compiler'
4
+ require 'puppet/indirector/catalog/compiler'
5
+
6
+ describe "Transmission of the catalog to the agent" do
7
+ include PuppetSpec::Compiler
8
+
9
+ it "preserves the order in which the resources are added to the catalog" do
10
+ resources_in_declaration_order = ["Class[First]",
11
+ "Second[position]",
12
+ "Class[Third]",
13
+ "Fourth[position]"]
14
+
15
+ master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
16
+ define fourth() { }
17
+ class third { }
18
+
19
+ define second() {
20
+ fourth { "position": }
21
+ }
22
+
23
+ class first {
24
+ second { "position": }
25
+ class { "third": }
26
+ }
27
+
28
+ include first
29
+ EOM
30
+
31
+ expect(resources_in(master_catalog)).
32
+ to include_in_order(*resources_in_declaration_order)
33
+ expect(resources_in(agent_catalog)).
34
+ to include_in_order(*resources_in_declaration_order)
35
+ end
36
+
37
+ it "does not contain unrealized, virtual resources" do
38
+ virtual_resources = ["Unrealized[unreal]", "Class[Unreal]"]
39
+
40
+ master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
41
+ class unreal { }
42
+ define unrealized() { }
43
+
44
+ class real {
45
+ @unrealized { "unreal": }
46
+ @class { "unreal": }
47
+ }
48
+
49
+ include real
50
+ EOM
51
+
52
+ expect(resources_in(master_catalog)).to_not include(*virtual_resources)
53
+ expect(resources_in(agent_catalog)).to_not include(*virtual_resources)
54
+ end
55
+
56
+ it "does not contain unrealized, exported resources" do
57
+ exported_resources = ["Unrealized[unreal]", "Class[Unreal]"]
58
+
59
+ master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
60
+ class unreal { }
61
+ define unrealized() { }
62
+
63
+ class real {
64
+ @@unrealized { "unreal": }
65
+ @@class { "unreal": }
66
+ }
67
+
68
+ include real
69
+ EOM
70
+
71
+ expect(resources_in(master_catalog)).to_not include(*exported_resources)
72
+ expect(resources_in(agent_catalog)).to_not include(*exported_resources)
73
+ end
74
+
75
+ def master_and_agent_catalogs_for(manifest)
76
+ master_catalog = Puppet::Resource::Catalog::Compiler.new.filter(compile_to_catalog(manifest))
77
+ agent_catalog = Puppet::Resource::Catalog.convert_from(:pson, master_catalog.render(:pson))
78
+
79
+ [master_catalog, agent_catalog]
80
+ end
81
+
82
+ def resources_in(catalog)
83
+ catalog.resources.map(&:ref)
84
+ end
85
+ end
@@ -160,6 +160,17 @@ describe Puppet::Type.type(:cron).provider(:crontab), '(integration)', :unless =
160
160
  run_in_catalog(resource)
161
161
  expect_output('modify_entry')
162
162
  end
163
+ it "should change a special schedule to numeric if requested" do
164
+ resource = Puppet::Type.type(:cron).new(
165
+ :name => 'My daily failure',
166
+ :special => 'absent',
167
+ :command => '/bin/false',
168
+ :target => crontab_user1,
169
+ :user => crontab_user1
170
+ )
171
+ run_in_catalog(resource)
172
+ expect_output('unspecialized')
173
+ end
163
174
  it "should not try to move an entry from one file to another" do
164
175
  # force the parsedfile provider to also parse user1's crontab
165
176
  random_resource = Puppet::Type.type(:cron).new(
@@ -20,6 +20,7 @@ describe "mount provider (integration)", :unless => Puppet.features.microsoft_wi
20
20
  @current_options = "local"
21
21
  @current_device = "/dev/disk1s1"
22
22
  Puppet::Type.type(:mount).defaultprovider.stubs(:default_target).returns(@fake_fstab)
23
+ Facter.stubs(:value).with(:kernel).returns('Darwin')
23
24
  Facter.stubs(:value).with(:operatingsystem).returns('Darwin')
24
25
  Facter.stubs(:value).with(:osfamily).returns('Darwin')
25
26
  Puppet::Util::ExecutionStub.set do |command, options|
@@ -33,7 +33,7 @@ describe Puppet::Transaction do
33
33
 
34
34
  resource.expects(:eval_generate).returns([child_resource])
35
35
 
36
- transaction = Puppet::Transaction.new(catalog)
36
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
37
37
 
38
38
  resource.expects(:retrieve).raises "this is a failure"
39
39
  resource.stubs(:err)
@@ -49,7 +49,7 @@ describe Puppet::Transaction do
49
49
  resource.virtual = true
50
50
  catalog.add_resource resource
51
51
 
52
- transaction = Puppet::Transaction.new(catalog)
52
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
53
53
 
54
54
  resource.expects(:evaluate).never
55
55
 
@@ -74,7 +74,7 @@ describe Puppet::Transaction do
74
74
  resource.virtual = true
75
75
  catalog.add_resource resource
76
76
 
77
- transaction = Puppet::Transaction.new(catalog)
77
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
78
78
 
79
79
  resource.expects(:evaluate).never
80
80
 
@@ -86,7 +86,7 @@ describe Puppet::Transaction do
86
86
  resource = Puppet::Type.type(:interface).new :name => "FastEthernet 0/1"
87
87
  catalog.add_resource resource
88
88
 
89
- transaction = Puppet::Transaction.new(catalog)
89
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
90
90
  transaction.for_network_device = false
91
91
 
92
92
  transaction.expects(:apply).never.with(resource, nil)
@@ -100,7 +100,7 @@ describe Puppet::Transaction do
100
100
  resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
101
101
  catalog.add_resource resource
102
102
 
103
- transaction = Puppet::Transaction.new(catalog)
103
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
104
104
  transaction.for_network_device = true
105
105
 
106
106
  transaction.expects(:apply).never.with(resource, nil)
@@ -114,7 +114,7 @@ describe Puppet::Transaction do
114
114
  resource = Puppet::Type.type(:interface).new :name => "FastEthernet 0/1"
115
115
  catalog.add_resource resource
116
116
 
117
- transaction = Puppet::Transaction.new(catalog)
117
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
118
118
  transaction.for_network_device = true
119
119
 
120
120
  transaction.expects(:apply).with(resource, nil)
@@ -128,7 +128,7 @@ describe Puppet::Transaction do
128
128
  resource = Puppet::Type.type(:schedule).new :name => "test"
129
129
  catalog.add_resource resource
130
130
 
131
- transaction = Puppet::Transaction.new(catalog)
131
+ transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
132
132
  transaction.for_network_device = true
133
133
 
134
134
  transaction.expects(:apply).with(resource, nil)
@@ -341,6 +341,6 @@ describe Puppet::Transaction do
341
341
 
342
342
  trans = catalog.apply
343
343
 
344
- trans.resource_harness.should be_scheduled(trans.resource_status(resource), resource)
344
+ trans.resource_harness.should be_scheduled(resource)
345
345
  end
346
346
  end
@@ -454,7 +454,7 @@ describe Puppet::Type.type(:file) do
454
454
  catalog.apply
455
455
 
456
456
  File.readlink(link).should == dest2
457
- Find.find(bucket[:path]) { |f| File.file?(f) }.should be_nil
457
+ File.exist?(bucket[:path]).should be_false
458
458
  end
459
459
 
460
460
  it "should backup directories to the local filesystem by copying the whole directory" do
@@ -10,23 +10,27 @@ describe Puppet::Settings do
10
10
  { :noop => {:default => false, :desc => "noop"} }
11
11
  end
12
12
 
13
+ def define_settings(section, settings_hash)
14
+ settings.define_settings(section, minimal_default_settings.update(settings_hash))
15
+ end
16
+
17
+ let(:settings) { Puppet::Settings.new }
18
+
13
19
  it "should be able to make needed directories" do
14
- settings = Puppet::Settings.new
15
- settings.define_settings :main, minimal_default_settings.update(
16
- :maindir => {
17
- :default => tmpfile("main"),
18
- :type => :directory,
19
- :desc => "a",
20
- }
20
+ define_settings(:main,
21
+ :maindir => {
22
+ :default => tmpfile("main"),
23
+ :type => :directory,
24
+ :desc => "a",
25
+ }
21
26
  )
22
27
  settings.use(:main)
23
28
 
24
- File.should be_directory(settings[:maindir])
29
+ expect(File.directory?(settings[:maindir])).to be_true
25
30
  end
26
31
 
27
32
  it "should make its directories with the correct modes" do
28
- settings = Puppet::Settings.new
29
- settings.define_settings :main, minimal_default_settings.update(
33
+ define_settings(:main,
30
34
  :maindir => {
31
35
  :default => tmpfile("main"),
32
36
  :type => :directory,
@@ -37,6 +41,49 @@ describe Puppet::Settings do
37
41
 
38
42
  settings.use(:main)
39
43
 
40
- (File.stat(settings[:maindir]).mode & 007777).should == (Puppet.features.microsoft_windows? ? 0755 : 0750)
44
+ expect(File.stat(settings[:maindir]).mode & 007777).to eq(Puppet.features.microsoft_windows? ? 0755 : 0750)
45
+ end
46
+
47
+ it "reparses configuration if configuration file is touched", :if => !Puppet.features.microsoft_windows? do
48
+ config = tmpfile("config")
49
+ define_settings(:main,
50
+ :config => {
51
+ :type => :file,
52
+ :default => config,
53
+ :desc => "a"
54
+ },
55
+ :environment => {
56
+ :default => 'dingos',
57
+ :desc => 'test',
58
+ }
59
+ )
60
+
61
+ Puppet[:filetimeout] = '1s'
62
+
63
+ File.open(config, 'w') do |file|
64
+ file.puts <<-EOF
65
+ [main]
66
+ environment=toast
67
+ EOF
68
+ end
69
+
70
+ settings.initialize_global_settings
71
+ expect(settings[:environment]).to eq('toast')
72
+
73
+ # First reparse establishes WatchedFiles
74
+ settings.reparse_config_files
75
+
76
+ sleep 1
77
+
78
+ File.open(config, 'w') do |file|
79
+ file.puts <<-EOF
80
+ [main]
81
+ environment=bacon
82
+ EOF
83
+ end
84
+
85
+ # Second reparse if later than filetimeout, reparses if changed
86
+ settings.reparse_config_files
87
+ expect(settings[:environment]).to eq('bacon')
41
88
  end
42
89
  end
@@ -0,0 +1,21 @@
1
+ RSpec::Matchers.define :include_in_order do |*expected|
2
+ include RSpec::Matchers::Pretty
3
+
4
+ match do |actual|
5
+ elements = expected.dup
6
+ actual.each do |elt|
7
+ if elt == elements.first
8
+ elements.shift
9
+ end
10
+ end
11
+ elements.empty?
12
+ end
13
+
14
+ def failure_message_for_should
15
+ "expected #{@actual.inspect} to include#{expected_to_sentence} in order"
16
+ end
17
+
18
+ def failure_message_for_should_not
19
+ "expected #{@actual.inspect} not to include#{expected_to_sentence} in order"
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'matchers/include_in_order'
3
+
4
+ describe "Matching whether elements are included in order" do
5
+ context "an empty array" do
6
+ it "is included in an empty array" do
7
+ expect([]).to include_in_order()
8
+ end
9
+
10
+ it "is included in a non-empty array" do
11
+ expect([1]).to include_in_order()
12
+ end
13
+ end
14
+
15
+ it "[1,2,3] is included in [0,1,2,3,4]" do
16
+ expect([0,1,2,3,4]).to include_in_order(1,2,3)
17
+ end
18
+
19
+ it "[2,1] is not included in order in [1,2]" do
20
+ expect([1,2]).not_to include_in_order(2,1)
21
+ end
22
+
23
+ it "[2,4,6] is included in order in [1,2,3,4,5,6]" do
24
+ expect([1,2,3,4,5,6]).to include_in_order(2,4,6)
25
+ end
26
+
27
+ it "overlapping ordered array is not included" do
28
+ expect([1,2,3]).not_to include_in_order(2,3,4)
29
+ end
30
+ end
@@ -0,0 +1,48 @@
1
+ module RelationshipGraphMatchers
2
+ class EnforceOrderWithEdge
3
+ def initialize(before, after)
4
+ @before = before
5
+ @after = after
6
+ end
7
+
8
+ def matches?(actual_graph)
9
+ @actual_graph = actual_graph
10
+
11
+ @reverse_edge = actual_graph.edge?(
12
+ vertex_called(actual_graph, @after),
13
+ vertex_called(actual_graph, @before))
14
+
15
+ @forward_edge = actual_graph.edge?(
16
+ vertex_called(actual_graph, @before),
17
+ vertex_called(actual_graph, @after))
18
+
19
+ @forward_edge && !@reverse_edge
20
+ end
21
+
22
+ def failure_message_for_should
23
+ "expect #{@actual_graph.to_dot_graph} to only contain an edge from #{@before} to #{@after} but #{[forward_failure_message, reverse_failure_message].compact.join(' and ')}"
24
+ end
25
+
26
+ def forward_failure_message
27
+ if !@forward_edge
28
+ "did not contain an edge from #{@before} to #{@after}"
29
+ end
30
+ end
31
+
32
+ def reverse_failure_message
33
+ if @reverse_edge
34
+ "contained an edge from #{@after} to #{@before}"
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def vertex_called(graph, name)
41
+ graph.vertices.find { |v| v.ref =~ /#{Regexp.escape(name)}/ }
42
+ end
43
+ end
44
+
45
+ def enforce_order_with_edge(before, after)
46
+ EnforceOrderWithEdge.new(before, after)
47
+ end
48
+ end
@@ -3,4 +3,28 @@ module PuppetSpec::Compiler
3
3
  Puppet[:code] = string
4
4
  Puppet::Parser::Compiler.compile(node)
5
5
  end
6
+
7
+ def compile_to_ral(manifest)
8
+ catalog = compile_to_catalog(manifest)
9
+ ral = catalog.to_ral
10
+ ral.finalize
11
+ ral
12
+ end
13
+
14
+ def compile_to_relationship_graph(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
15
+ ral = compile_to_ral(manifest)
16
+ graph = Puppet::Graph::RelationshipGraph.new(prioritizer)
17
+ graph.populate_from(ral)
18
+ graph
19
+ end
20
+
21
+ def apply_compiled_manifest(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
22
+ transaction = Puppet::Transaction.new(compile_to_ral(manifest),
23
+ Puppet::Transaction::Report.new("apply"),
24
+ prioritizer)
25
+ transaction.evaluate
26
+ transaction.report.finalize_report
27
+
28
+ transaction
29
+ end
6
30
  end
@@ -0,0 +1,16 @@
1
+ module PuppetSpec::Pops
2
+ extend RSpec::Matchers::DSL
3
+
4
+ # Checks if an Acceptor has a specific issue in its list of diagnostics
5
+ matcher :have_issue do |expected|
6
+ match do |actual|
7
+ actual.diagnostics.index { |i| i.issue == expected } != nil
8
+ end
9
+ failure_message_for_should do |actual|
10
+ "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}"
11
+ end
12
+ failure_message_for_should_not do |actual|
13
+ "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}"
14
+ end
15
+ end
16
+ end
@@ -33,7 +33,6 @@ require 'puppet_spec/fixtures'
33
33
  require 'puppet_spec/matchers'
34
34
  require 'puppet_spec/database'
35
35
  require 'monkey_patches/alias_should_to_must'
36
- require 'monkey_patches/publicize_methods'
37
36
  require 'puppet/test/test_helper'
38
37
 
39
38
  Pathname.glob("#{dir}/shared_contexts/*.rb") do |file|
@@ -11,18 +11,28 @@ describe Puppet::Application::Agent do
11
11
 
12
12
  before :each do
13
13
  @puppetd = Puppet::Application[:agent]
14
- @puppetd.stubs(:puts)
15
- @daemon = stub_everything 'daemon'
14
+
15
+ @daemon = Puppet::Daemon.new(nil)
16
+ @daemon.stubs(:daemonize)
17
+ @daemon.stubs(:start)
18
+ @daemon.stubs(:stop)
16
19
  Puppet::Daemon.stubs(:new).returns(@daemon)
17
20
  Puppet[:daemonize] = false
21
+
18
22
  @agent = stub_everything 'agent'
19
23
  Puppet::Agent.stubs(:new).returns(@agent)
24
+
20
25
  @puppetd.preinit
21
26
  Puppet::Util::Log.stubs(:newdestination)
22
27
 
28
+ @ssl_host = stub_everything 'ssl host'
29
+ Puppet::SSL::Host.stubs(:new).returns(@ssl_host)
30
+
23
31
  Puppet::Node.indirection.stubs(:terminus_class=)
24
32
  Puppet::Node.indirection.stubs(:cache_class=)
25
33
  Puppet::Node::Facts.indirection.stubs(:terminus_class=)
34
+
35
+ $stderr.expects(:puts).never
26
36
  end
27
37
 
28
38
  it "should operate in agent run_mode" do
@@ -94,75 +104,80 @@ describe Puppet::Application::Agent do
94
104
  @puppetd.command_line.stubs(:args).returns([])
95
105
  end
96
106
 
97
- [:centrallogging, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
107
+ [:enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
98
108
  it "should declare handle_#{option} method" do
99
109
  @puppetd.should respond_to("handle_#{option}".to_sym)
100
110
  end
101
111
 
102
112
  it "should store argument value when calling handle_#{option}" do
103
- @puppetd.options.expects(:[]=).with(option, 'arg')
104
113
  @puppetd.send("handle_#{option}".to_sym, 'arg')
114
+
115
+ @puppetd.options[option].should == 'arg'
105
116
  end
106
117
  end
107
118
 
108
119
  describe "when handling --disable" do
109
- it "should declare handle_disable method" do
110
- @puppetd.should respond_to(:handle_disable)
111
- end
112
-
113
120
  it "should set disable to true" do
114
- @puppetd.options.stubs(:[]=)
115
- @puppetd.options.expects(:[]=).with(:disable, true)
116
121
  @puppetd.handle_disable('')
122
+
123
+ @puppetd.options[:disable].should == true
117
124
  end
118
125
 
119
126
  it "should store disable message" do
120
- @puppetd.options.stubs(:[]=)
121
- @puppetd.options.expects(:[]=).with(:disable_message, "message")
122
127
  @puppetd.handle_disable('message')
128
+
129
+ @puppetd.options[:disable_message].should == 'message'
123
130
  end
124
131
  end
125
132
 
126
133
  it "should set client to false with --no-client" do
127
134
  @puppetd.handle_no_client(nil)
135
+
128
136
  @puppetd.options[:client].should be_false
129
137
  end
130
138
 
131
139
  it "should set waitforcert to 0 with --onetime and if --waitforcert wasn't given" do
140
+ @agent.stubs(:run).returns(2)
132
141
  Puppet[:onetime] = true
133
- Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(0)
134
- @puppetd.setup_host
142
+
143
+ @ssl_host.expects(:wait_for_cert).with(0)
144
+
145
+ expect { execute_agent }.to exit_with 0
135
146
  end
136
147
 
137
148
  it "should use supplied waitforcert when --onetime is specified" do
149
+ @agent.stubs(:run).returns(2)
138
150
  Puppet[:onetime] = true
139
151
  @puppetd.handle_waitforcert(60)
140
- Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(60)
141
- @puppetd.setup_host
152
+
153
+ @ssl_host.expects(:wait_for_cert).with(60)
154
+
155
+ expect { execute_agent }.to exit_with 0
142
156
  end
143
157
 
144
158
  it "should use a default value for waitforcert when --onetime and --waitforcert are not specified" do
145
- Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(120)
146
- @puppetd.setup_host
159
+ @ssl_host.expects(:wait_for_cert).with(120)
160
+
161
+ execute_agent
147
162
  end
148
163
 
149
164
  it "should use the waitforcert setting when checking for a signed certificate" do
150
165
  Puppet[:waitforcert] = 10
151
- Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(10)
152
- @puppetd.setup_host
166
+ @ssl_host.expects(:wait_for_cert).with(10)
167
+
168
+ execute_agent
153
169
  end
154
170
 
155
171
  it "should set the log destination with --logdest" do
156
- @puppetd.options.stubs(:[]=).with { |opt,val| opt == :setdest }
157
172
  Puppet::Log.expects(:newdestination).with("console")
158
173
 
159
174
  @puppetd.handle_logdest("console")
160
175
  end
161
176
 
162
177
  it "should put the setdest options to true" do
163
- @puppetd.options.expects(:[]=).with(:setdest,true)
164
-
165
178
  @puppetd.handle_logdest("console")
179
+
180
+ @puppetd.options[:setdest].should == true
166
181
  end
167
182
 
168
183
  it "should parse the log destination from the command line" do
@@ -174,50 +189,37 @@ describe Puppet::Application::Agent do
174
189
  end
175
190
 
176
191
  it "should store the waitforcert options with --waitforcert" do
177
- @puppetd.options.expects(:[]=).with(:waitforcert,42)
178
-
179
192
  @puppetd.handle_waitforcert("42")
180
- end
181
193
 
182
- it "should set args[:Port] with --port" do
183
- @puppetd.handle_port("42")
184
- @puppetd.args[:Port].should == "42"
194
+ @puppetd.options[:waitforcert].should == 42
185
195
  end
186
-
187
196
  end
188
197
 
189
198
  describe "during setup" do
190
199
  before :each do
191
- @puppetd.options.stubs(:[])
192
200
  Puppet.stubs(:info)
193
201
  FileTest.stubs(:exists?).returns(true)
194
202
  Puppet[:libdir] = "/dev/null/lib"
195
- Puppet::SSL::Host.stubs(:ca_location=)
196
203
  Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
197
204
  Puppet::Transaction::Report.indirection.stubs(:cache_class=)
198
205
  Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
199
206
  Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
200
207
  Puppet::Node::Facts.indirection.stubs(:terminus_class=)
201
- @host = stub_everything 'host'
202
- Puppet::SSL::Host.stubs(:new).returns(@host)
203
208
  Puppet.stubs(:settraps)
204
209
  end
205
210
 
206
211
  describe "with --test" do
207
- before :each do
208
- #Puppet.settings.stubs(:handlearg)
209
- @puppetd.options.stubs(:[]=)
210
- end
211
-
212
212
  it "should call setup_test" do
213
- @puppetd.options.stubs(:[]).with(:test).returns(true)
213
+ @puppetd.options[:test] = true
214
214
  @puppetd.expects(:setup_test)
215
+
215
216
  @puppetd.setup
216
217
  end
217
218
 
218
219
  it "should set options[:verbose] to true" do
219
- @puppetd.options.expects(:[]=).with(:verbose,true)
220
220
  @puppetd.setup_test
221
+
222
+ @puppetd.options[:verbose].should == true
221
223
  end
222
224
  it "should set options[:onetime] to true" do
223
225
  Puppet[:onetime] = false
@@ -225,8 +227,9 @@ describe Puppet::Application::Agent do
225
227
  Puppet[:onetime].should == true
226
228
  end
227
229
  it "should set options[:detailed_exitcodes] to true" do
228
- @puppetd.options.expects(:[]=).with(:detailed_exitcodes,true)
229
230
  @puppetd.setup_test
231
+
232
+ @puppetd.options[:detailed_exitcodes].should == true
230
233
  end
231
234
  end
232
235
 
@@ -241,29 +244,30 @@ describe Puppet::Application::Agent do
241
244
  end
242
245
 
243
246
  it "should set log level to debug if --debug was passed" do
244
- @puppetd.options.stubs(:[]).with(:debug).returns(true)
247
+ @puppetd.options[:debug] = true
245
248
  @puppetd.setup_logs
246
249
  Puppet::Util::Log.level.should == :debug
247
250
  end
248
251
 
249
252
  it "should set log level to info if --verbose was passed" do
250
- @puppetd.options.stubs(:[]).with(:verbose).returns(true)
253
+ @puppetd.options[:verbose] = true
251
254
  @puppetd.setup_logs
252
255
  Puppet::Util::Log.level.should == :info
253
256
  end
254
257
 
255
258
  [:verbose, :debug].each do |level|
256
259
  it "should set console as the log destination with level #{level}" do
257
- @puppetd.options.stubs(:[]).with(level).returns(true)
260
+ @puppetd.options[level] = true
258
261
 
259
- Puppet::Util::Log.expects(:newdestination).with(:console)
262
+ Puppet::Util::Log.expects(:newdestination).at_least_once
263
+ Puppet::Util::Log.expects(:newdestination).with(:console).once
260
264
 
261
265
  @puppetd.setup_logs
262
266
  end
263
267
  end
264
268
 
265
269
  it "should set a default log destination if no --logdest" do
266
- @puppetd.options.stubs(:[]).with(:setdest).returns(false)
270
+ @puppetd.options[:setdest] = false
267
271
 
268
272
  Puppet::Util::Log.expects(:setup_default)
269
273
 
@@ -275,7 +279,7 @@ describe Puppet::Application::Agent do
275
279
  it "should print puppet config if asked to in Puppet config" do
276
280
  Puppet[:configprint] = "pluginsync"
277
281
  Puppet.settings.expects(:print_configs).returns true
278
- expect { @puppetd.setup }.to exit_with 0
282
+ expect { execute_agent }.to exit_with 0
279
283
  end
280
284
 
281
285
  it "should exit after printing puppet config if asked to in Puppet config" do
@@ -283,17 +287,7 @@ describe Puppet::Application::Agent do
283
287
  Puppet[:modulepath] = path
284
288
  Puppet[:configprint] = "modulepath"
285
289
  Puppet::Settings.any_instance.expects(:puts).with(path)
286
- expect { @puppetd.setup }.to exit_with 0
287
- end
288
-
289
- it "should set a central log destination with --centrallogs" do
290
- @puppetd.options.stubs(:[]).with(:centrallogs).returns(true)
291
- Puppet[:server] = "puppet.reductivelabs.com"
292
- Puppet::Util::Log.stubs(:setup_default)
293
-
294
- Puppet::Util::Log.expects(:newdestination).with("puppet.reductivelabs.com")
295
-
296
- @puppetd.setup
290
+ expect { execute_agent }.to exit_with 0
297
291
  end
298
292
 
299
293
  it "should use :main, :puppetd, and :ssl" do
@@ -309,7 +303,7 @@ describe Puppet::Application::Agent do
309
303
  end
310
304
 
311
305
  it "should install a none ca location in fingerprint mode" do
312
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
306
+ @puppetd.options[:fingerprint] = true
313
307
  Puppet::SSL::Host.expects(:ca_location=).with(:none)
314
308
 
315
309
  @puppetd.setup
@@ -373,7 +367,7 @@ describe Puppet::Application::Agent do
373
367
 
374
368
  [:enable, :disable].each do |action|
375
369
  it "should delegate to enable_disable_client if we #{action} the agent" do
376
- @puppetd.options.stubs(:[]).with(action).returns(true)
370
+ @puppetd.options[action] = true
377
371
  @puppetd.expects(:enable_disable_client).with(@agent)
378
372
 
379
373
  @puppetd.setup
@@ -383,41 +377,43 @@ describe Puppet::Application::Agent do
383
377
  describe "when enabling or disabling agent" do
384
378
  [:enable, :disable].each do |action|
385
379
  it "should call client.#{action}" do
386
- @puppetd.options.stubs(:[]).with(action).returns(true)
380
+ @puppetd.options[action] = true
387
381
  @agent.expects(action)
388
- expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
382
+ expect { execute_agent }.to exit_with 0
389
383
  end
390
384
  end
391
385
 
392
386
  it "should pass the disable message when disabling" do
393
- @puppetd.options.stubs(:[]).with(:disable).returns(true)
394
- @puppetd.options.stubs(:[]).with(:disable_message).returns("message")
387
+ @puppetd.options[:disable] = true
388
+ @puppetd.options[:disable_message] = "message"
395
389
  @agent.expects(:disable).with("message")
396
- expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
390
+
391
+ expect { execute_agent }.to exit_with 0
397
392
  end
398
393
 
399
394
  it "should pass the default disable message when disabling without a message" do
400
- @puppetd.options.stubs(:[]).with(:disable).returns(true)
401
- @puppetd.options.stubs(:[]).with(:disable_message).returns(nil)
395
+ @puppetd.options[:disable] = true
396
+ @puppetd.options[:disable_message] = nil
402
397
  @agent.expects(:disable).with("reason not specified")
403
- expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
404
- end
405
398
 
406
- it "should finally exit" do
407
- expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
399
+ expect { execute_agent }.to exit_with 0
408
400
  end
409
401
  end
410
402
 
411
403
  it "should inform the daemon about our agent if :client is set to 'true'" do
412
- @puppetd.options.expects(:[]).with(:client).returns true
413
- @daemon.expects(:agent=).with(@agent)
414
- @puppetd.setup
404
+ @puppetd.options[:client] = true
405
+
406
+ execute_agent
407
+
408
+ @daemon.agent.should == @agent
415
409
  end
416
410
 
417
411
  it "should not inform the daemon about our agent if :client is set to 'false'" do
418
412
  @puppetd.options[:client] = false
419
- @daemon.expects(:agent=).never
420
- @puppetd.setup
413
+
414
+ execute_agent
415
+
416
+ @daemon.agent.should be_nil
421
417
  end
422
418
 
423
419
  it "should daemonize if needed" do
@@ -426,66 +422,72 @@ describe Puppet::Application::Agent do
426
422
 
427
423
  @daemon.expects(:daemonize)
428
424
 
429
- @puppetd.setup
425
+ execute_agent
430
426
  end
431
427
 
432
428
  it "should wait for a certificate" do
433
- @puppetd.options.stubs(:[]).with(:waitforcert).returns(123)
434
- @host.expects(:wait_for_cert).with(123)
429
+ @puppetd.options[:waitforcert] = 123
430
+ @ssl_host.expects(:wait_for_cert).with(123)
435
431
 
436
- @puppetd.setup
432
+ execute_agent
437
433
  end
438
434
 
439
435
  it "should not wait for a certificate in fingerprint mode" do
440
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
441
- @puppetd.options.stubs(:[]).with(:waitforcert).returns(123)
442
- @host.expects(:wait_for_cert).never
443
-
444
- @puppetd.setup
445
- end
436
+ @puppetd.options[:fingerprint] = true
437
+ @puppetd.options[:waitforcert] = 123
438
+ @puppetd.options[:digest] = 'MD5'
446
439
 
447
- it "should setup listen if told to and not onetime" do
448
- Puppet[:listen] = true
449
- @puppetd.options.stubs(:[]).with(:onetime).returns(false)
440
+ certificate = mock 'certificate'
441
+ certificate.stubs(:digest).with('MD5').returns('ABCDE')
442
+ @ssl_host.stubs(:certificate).returns(certificate)
450
443
 
451
- @puppetd.expects(:setup_listen)
444
+ @ssl_host.expects(:wait_for_cert).never
445
+ @puppetd.expects(:puts).with('ABCDE')
452
446
 
453
- @puppetd.setup
447
+ execute_agent
454
448
  end
455
449
 
456
450
  describe "when setting up listen" do
457
451
  before :each do
458
452
  FileTest.stubs(:exists?).with('auth').returns(true)
459
453
  File.stubs(:exist?).returns(true)
460
- @puppetd.options.stubs(:[]).with(:serve).returns([])
454
+ @puppetd.options[:serve] = []
461
455
  @server = stub_everything 'server'
462
456
  Puppet::Network::Server.stubs(:new).returns(@server)
463
457
  end
464
458
 
465
459
 
466
460
  it "should exit if no authorization file" do
461
+ Puppet[:listen] = true
467
462
  Puppet.stubs(:err)
468
463
  FileTest.stubs(:exists?).with(Puppet[:rest_authconfig]).returns(false)
469
- expect { @puppetd.setup_listen }.to exit_with 14
464
+
465
+ expect do
466
+ execute_agent
467
+ end.to exit_with 14
470
468
  end
471
469
 
472
470
  it "should use puppet default port" do
473
471
  Puppet[:puppetport] = 32768
472
+ Puppet[:listen] = true
474
473
 
475
474
  Puppet::Network::Server.expects(:new).with(anything, 32768)
476
475
 
477
- @puppetd.setup_listen
476
+ execute_agent
478
477
  end
479
-
478
+
480
479
  it "should issue a warning that listen is deprecated" do
480
+ Puppet[:listen] = true
481
+
481
482
  Puppet.expects(:warning).with() { |msg| msg =~ /kick is deprecated/ }
482
- @puppetd.setup_listen
483
+
484
+ execute_agent
483
485
  end
484
486
  end
485
487
 
486
488
  describe "when setting up for fingerprint" do
487
489
  before(:each) do
488
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
490
+ @puppetd.options[:fingerprint] = true
489
491
  end
490
492
 
491
493
  it "should not setup as an agent" do
@@ -502,11 +504,6 @@ describe Puppet::Application::Agent do
502
504
  @daemon.expects(:daemonize).never
503
505
  @puppetd.setup
504
506
  end
505
-
506
- it "should setup our certificate host" do
507
- @puppetd.expects(:setup_host)
508
- @puppetd.setup
509
- end
510
507
  end
511
508
 
512
509
  describe "when configuring agent for catalog run" do
@@ -526,114 +523,112 @@ describe Puppet::Application::Agent do
526
523
 
527
524
  describe "when running" do
528
525
  before :each do
529
- @puppetd.agent = @agent
530
- @puppetd.daemon = @daemon
531
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(false)
526
+ @puppetd.options[:fingerprint] = false
532
527
  end
533
528
 
534
529
  it "should dispatch to fingerprint if --fingerprint is used" do
535
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
530
+ @puppetd.options[:fingerprint] = true
536
531
 
537
532
  @puppetd.stubs(:fingerprint)
538
- @puppetd.run_command
533
+
534
+ execute_agent
539
535
  end
540
536
 
541
537
  it "should dispatch to onetime if --onetime is used" do
542
- @puppetd.options.stubs(:[]).with(:onetime).returns(true)
538
+ @puppetd.options[:onetime] = true
543
539
 
544
540
  @puppetd.stubs(:onetime)
545
- @puppetd.run_command
541
+
542
+ execute_agent
546
543
  end
547
544
 
548
545
  it "should dispatch to main if --onetime and --fingerprint are not used" do
549
- @puppetd.options.stubs(:[]).with(:onetime).returns(false)
546
+ @puppetd.options[:onetime] = false
550
547
 
551
548
  @puppetd.stubs(:main)
552
- @puppetd.run_command
549
+
550
+ execute_agent
553
551
  end
554
552
 
555
553
  describe "with --onetime" do
556
554
 
557
555
  before :each do
558
556
  @agent.stubs(:run).returns(:report)
559
- @puppetd.options.stubs(:[]).with(:client).returns(:client)
560
- @puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(false)
557
+ Puppet[:onetime] = true
558
+ @puppetd.options[:client] = :client
559
+ @puppetd.options[:detailed_exitcodes] = false
561
560
  Puppet.stubs(:newservice)
562
561
  end
563
562
 
564
563
  it "should exit if no defined --client" do
565
- $stderr.stubs(:puts)
566
- @puppetd.options.stubs(:[]).with(:client).returns(nil)
567
- expect { @puppetd.onetime }.to exit_with 43
564
+ @puppetd.options[:client] = nil
565
+
566
+ Puppet.expects(:err).with('onetime is specified but there is no client')
567
+
568
+ expect { execute_agent }.to exit_with 43
568
569
  end
569
570
 
570
571
  it "should setup traps" do
571
572
  @daemon.expects(:set_signal_traps)
572
- expect { @puppetd.onetime }.to exit_with 0
573
+
574
+ expect { execute_agent }.to exit_with 0
573
575
  end
574
576
 
575
577
  it "should let the agent run" do
576
578
  @agent.expects(:run).returns(:report)
577
- expect { @puppetd.onetime }.to exit_with 0
578
- end
579
579
 
580
- it "should finish by exiting with 0 error code" do
581
- expect { @puppetd.onetime }.to exit_with 0
580
+ expect { execute_agent }.to exit_with 0
582
581
  end
583
582
 
584
583
  it "should stop the daemon" do
585
584
  @daemon.expects(:stop).with(:exit => false)
586
- expect { @puppetd.onetime }.to exit_with 0
585
+
586
+ expect { execute_agent }.to exit_with 0
587
587
  end
588
588
 
589
589
  describe "and --detailed-exitcodes" do
590
590
  before :each do
591
- @puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
591
+ @puppetd.options[:detailed_exitcodes] = true
592
592
  end
593
593
 
594
594
  it "should exit with agent computed exit status" do
595
595
  Puppet[:noop] = false
596
596
  @agent.stubs(:run).returns(666)
597
597
 
598
- expect { @puppetd.onetime }.to exit_with 666
598
+ expect { execute_agent }.to exit_with 666
599
599
  end
600
600
 
601
601
  it "should exit with the agent's exit status, even if --noop is set." do
602
602
  Puppet[:noop] = true
603
603
  @agent.stubs(:run).returns(666)
604
604
 
605
- expect { @puppetd.onetime }.to exit_with 666
605
+ expect { execute_agent }.to exit_with 666
606
606
  end
607
607
  end
608
608
  end
609
609
 
610
610
  describe "with --fingerprint" do
611
611
  before :each do
612
- @cert = stub_everything 'cert'
613
- @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
614
- @puppetd.options.stubs(:[]).with(:digest).returns(:MD5)
615
- @host = stub_everything 'host'
616
- @puppetd.stubs(:host).returns(@host)
612
+ @cert = mock 'cert'
613
+ @puppetd.options[:fingerprint] = true
614
+ @puppetd.options[:digest] = :MD5
617
615
  end
618
616
 
619
617
  it "should fingerprint the certificate if it exists" do
620
- @host.expects(:certificate).returns(@cert)
621
- @cert.expects(:digest).with('MD5').returns "fingerprint"
622
- @puppetd.fingerprint
623
- end
618
+ @ssl_host.stubs(:certificate).returns(@cert)
619
+ @cert.stubs(:digest).with('MD5').returns "fingerprint"
620
+
621
+ @puppetd.expects(:puts).with "fingerprint"
624
622
 
625
- it "should fingerprint the certificate request if no certificate have been signed" do
626
- @host.expects(:certificate).returns(nil)
627
- @host.expects(:certificate_request).returns(@cert)
628
- @cert.expects(:digest).with('MD5').returns "fingerprint"
629
623
  @puppetd.fingerprint
630
624
  end
631
625
 
632
- it "should display the fingerprint" do
633
- @host.stubs(:certificate).returns(@cert)
634
- @cert.stubs(:digest).with('MD5').returns("DIGEST")
626
+ it "should fingerprint the certificate request if no certificate have been signed" do
627
+ @ssl_host.stubs(:certificate).returns(nil)
628
+ @ssl_host.stubs(:certificate_request).returns(@cert)
629
+ @cert.stubs(:digest).with('MD5').returns "fingerprint"
635
630
 
636
- @puppetd.expects(:puts).with "DIGEST"
631
+ @puppetd.expects(:puts).with "fingerprint"
637
632
 
638
633
  @puppetd.fingerprint
639
634
  end
@@ -642,14 +637,19 @@ describe Puppet::Application::Agent do
642
637
  describe "without --onetime and --fingerprint" do
643
638
  before :each do
644
639
  Puppet.stubs(:notice)
645
- @puppetd.options.stubs(:[]).with(:client)
640
+ @puppetd.options[:client] = nil
646
641
  end
647
642
 
648
643
  it "should start our daemon" do
649
644
  @daemon.expects(:start)
650
645
 
651
- @puppetd.main
646
+ execute_agent
652
647
  end
653
648
  end
654
649
  end
650
+
651
+ def execute_agent
652
+ @puppetd.setup
653
+ @puppetd.run_command
654
+ end
655
655
  end