puppet 6.16.0-x64-mingw32 → 7.0.0-x64-mingw32

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

Potentially problematic release.


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

Files changed (645) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/Gemfile.lock +31 -33
  4. data/README.md +4 -5
  5. data/Rakefile +4 -12
  6. data/conf/fileserver.conf +5 -10
  7. data/ext/build_defaults.yaml +1 -1
  8. data/ext/osx/file_mapping.yaml +0 -5
  9. data/ext/project_data.yaml +1 -14
  10. data/ext/redhat/puppet.spec.erb +0 -1
  11. data/ext/windows/service/daemon.rb +6 -5
  12. data/install.rb +21 -17
  13. data/lib/puppet.rb +11 -20
  14. data/lib/puppet/agent.rb +2 -2
  15. data/lib/puppet/agent/locker.rb +0 -7
  16. data/lib/puppet/application.rb +172 -98
  17. data/lib/puppet/application/agent.rb +22 -6
  18. data/lib/puppet/application/apply.rb +18 -20
  19. data/lib/puppet/application/device.rb +100 -104
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/application/filebucket.rb +15 -11
  22. data/lib/puppet/application/lookup.rb +16 -4
  23. data/lib/puppet/application/ssl.rb +1 -1
  24. data/lib/puppet/configurer.rb +66 -31
  25. data/lib/puppet/configurer/downloader.rb +31 -10
  26. data/lib/puppet/configurer/plugin_handler.rb +21 -19
  27. data/lib/puppet/confine.rb +2 -2
  28. data/lib/puppet/confine/any.rb +1 -1
  29. data/lib/puppet/defaults.rb +166 -169
  30. data/lib/puppet/environments.rb +41 -15
  31. data/lib/puppet/face/catalog.rb +1 -1
  32. data/lib/puppet/face/config.rb +56 -16
  33. data/lib/puppet/face/epp.rb +12 -2
  34. data/lib/puppet/face/facts.rb +66 -6
  35. data/lib/puppet/face/help.rb +1 -1
  36. data/lib/puppet/face/node.rb +3 -3
  37. data/lib/puppet/face/node/clean.rb +2 -2
  38. data/lib/puppet/face/plugin.rb +5 -8
  39. data/lib/puppet/feature/base.rb +1 -1
  40. data/lib/puppet/ffi/windows.rb +12 -0
  41. data/lib/puppet/ffi/windows/api_types.rb +311 -0
  42. data/lib/puppet/ffi/windows/constants.rb +404 -0
  43. data/lib/puppet/ffi/windows/functions.rb +628 -0
  44. data/lib/puppet/ffi/windows/structs.rb +338 -0
  45. data/lib/puppet/file_bucket/dipper.rb +1 -1
  46. data/lib/puppet/file_serving/configuration.rb +0 -5
  47. data/lib/puppet/file_serving/configuration/parser.rb +3 -32
  48. data/lib/puppet/file_serving/http_metadata.rb +13 -1
  49. data/lib/puppet/file_serving/metadata.rb +4 -1
  50. data/lib/puppet/file_serving/mount.rb +1 -2
  51. data/lib/puppet/file_serving/mount/locales.rb +1 -2
  52. data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
  53. data/lib/puppet/file_serving/mount/plugins.rb +1 -2
  54. data/lib/puppet/file_serving/terminus_selector.rb +7 -8
  55. data/lib/puppet/file_system/file_impl.rb +4 -4
  56. data/lib/puppet/file_system/uniquefile.rb +8 -16
  57. data/lib/puppet/forge.rb +1 -1
  58. data/lib/puppet/forge/cache.rb +1 -1
  59. data/lib/puppet/forge/repository.rb +3 -8
  60. data/lib/puppet/functions/epp.rb +1 -0
  61. data/lib/puppet/functions/inline_epp.rb +1 -0
  62. data/lib/puppet/functions/lstrip.rb +4 -4
  63. data/lib/puppet/functions/new.rb +8 -3
  64. data/lib/puppet/functions/reverse_each.rb +1 -1
  65. data/lib/puppet/functions/rstrip.rb +4 -4
  66. data/lib/puppet/functions/step.rb +1 -1
  67. data/lib/puppet/functions/strip.rb +4 -4
  68. data/lib/puppet/generate/models/type/type.rb +4 -1
  69. data/lib/puppet/gettext/config.rb +5 -5
  70. data/lib/puppet/gettext/module_translations.rb +4 -4
  71. data/lib/puppet/http.rb +23 -13
  72. data/lib/puppet/http/client.rb +170 -115
  73. data/lib/puppet/{network/resolver.rb → http/dns.rb} +2 -2
  74. data/lib/puppet/http/errors.rb +16 -0
  75. data/lib/puppet/http/external_client.rb +5 -7
  76. data/lib/puppet/{network/http → http}/factory.rb +8 -11
  77. data/lib/puppet/{network/http → http}/pool.rb +61 -26
  78. data/lib/puppet/{network/http/session.rb → http/pool_entry.rb} +2 -3
  79. data/lib/puppet/http/proxy.rb +137 -0
  80. data/lib/puppet/http/redirector.rb +13 -19
  81. data/lib/puppet/http/resolver.rb +10 -23
  82. data/lib/puppet/http/resolver/server_list.rb +23 -45
  83. data/lib/puppet/http/resolver/settings.rb +7 -10
  84. data/lib/puppet/http/resolver/srv.rb +11 -15
  85. data/lib/puppet/http/response.rb +49 -48
  86. data/lib/puppet/http/response_converter.rb +24 -0
  87. data/lib/puppet/http/response_net_http.rb +42 -0
  88. data/lib/puppet/http/retry_after_handler.rb +4 -13
  89. data/lib/puppet/http/service.rb +15 -27
  90. data/lib/puppet/http/service/ca.rb +11 -22
  91. data/lib/puppet/http/service/compiler.rb +23 -70
  92. data/lib/puppet/http/service/file_server.rb +19 -28
  93. data/lib/puppet/http/service/puppetserver.rb +53 -0
  94. data/lib/puppet/http/service/report.rb +8 -10
  95. data/lib/puppet/http/session.rb +16 -24
  96. data/lib/puppet/{network/http → http}/site.rb +1 -2
  97. data/lib/puppet/indirector.rb +1 -1
  98. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  99. data/lib/puppet/indirector/catalog/rest.rb +2 -4
  100. data/lib/puppet/indirector/exec.rb +1 -1
  101. data/lib/puppet/indirector/fact_search.rb +60 -0
  102. data/lib/puppet/indirector/facts/facter.rb +27 -6
  103. data/lib/puppet/indirector/facts/json.rb +27 -0
  104. data/lib/puppet/indirector/facts/rest.rb +3 -22
  105. data/lib/puppet/indirector/facts/yaml.rb +4 -59
  106. data/lib/puppet/indirector/file_bucket_file/rest.rb +3 -9
  107. data/lib/puppet/indirector/file_content/rest.rb +3 -7
  108. data/lib/puppet/indirector/file_metadata/http.rb +25 -5
  109. data/lib/puppet/indirector/file_metadata/rest.rb +5 -11
  110. data/lib/puppet/indirector/file_server.rb +1 -8
  111. data/lib/puppet/indirector/generic_http.rb +0 -11
  112. data/lib/puppet/indirector/hiera.rb +4 -0
  113. data/lib/puppet/indirector/indirection.rb +1 -1
  114. data/lib/puppet/indirector/json.rb +5 -1
  115. data/lib/puppet/indirector/msgpack.rb +1 -1
  116. data/lib/puppet/indirector/node/json.rb +8 -0
  117. data/lib/puppet/indirector/node/rest.rb +2 -4
  118. data/lib/puppet/indirector/report/json.rb +34 -0
  119. data/lib/puppet/indirector/report/processor.rb +2 -2
  120. data/lib/puppet/indirector/report/rest.rb +3 -8
  121. data/lib/puppet/indirector/request.rb +2 -103
  122. data/lib/puppet/indirector/rest.rb +12 -263
  123. data/lib/puppet/indirector/yaml.rb +1 -1
  124. data/lib/puppet/module.rb +1 -2
  125. data/lib/puppet/module_tool/applications.rb +0 -1
  126. data/lib/puppet/network/authconfig.rb +2 -96
  127. data/lib/puppet/network/authorization.rb +13 -35
  128. data/lib/puppet/network/format_support.rb +2 -2
  129. data/lib/puppet/network/formats.rb +2 -1
  130. data/lib/puppet/network/http.rb +3 -3
  131. data/lib/puppet/network/http/api/indirected_routes.rb +3 -21
  132. data/lib/puppet/network/http/api/master/v3.rb +11 -13
  133. data/lib/puppet/network/http/api/master/v3/environments.rb +0 -1
  134. data/lib/puppet/network/http/connection.rb +247 -316
  135. data/lib/puppet/network/http/handler.rb +0 -1
  136. data/lib/puppet/network/http/route.rb +2 -2
  137. data/lib/puppet/network/http_pool.rb +16 -34
  138. data/lib/puppet/node.rb +1 -30
  139. data/lib/puppet/node/environment.rb +12 -5
  140. data/lib/puppet/node/facts.rb +17 -0
  141. data/lib/puppet/pal/json_catalog_encoder.rb +4 -0
  142. data/lib/puppet/pal/pal_impl.rb +93 -14
  143. data/lib/puppet/parameter.rb +1 -1
  144. data/lib/puppet/parser/ast/leaf.rb +5 -5
  145. data/lib/puppet/parser/ast/pops_bridge.rb +0 -42
  146. data/lib/puppet/parser/compiler.rb +1 -199
  147. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +14 -39
  148. data/lib/puppet/parser/functions.rb +21 -17
  149. data/lib/puppet/parser/functions/create_resources.rb +11 -7
  150. data/lib/puppet/parser/resource.rb +3 -71
  151. data/lib/puppet/parser/resource/param.rb +6 -0
  152. data/lib/puppet/parser/type_loader.rb +2 -2
  153. data/lib/puppet/pops/adaptable.rb +7 -13
  154. data/lib/puppet/pops/adapters.rb +8 -4
  155. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  156. data/lib/puppet/pops/evaluator/evaluator_impl.rb +27 -13
  157. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  158. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +3 -3
  159. data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -1
  160. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -8
  161. data/lib/puppet/pops/loader/runtime3_type_loader.rb +4 -2
  162. data/lib/puppet/pops/loaders.rb +18 -11
  163. data/lib/puppet/pops/lookup/context.rb +1 -1
  164. data/lib/puppet/pops/lookup/hiera_config.rb +14 -1
  165. data/lib/puppet/pops/model/ast.pp +0 -42
  166. data/lib/puppet/pops/model/ast.rb +0 -290
  167. data/lib/puppet/pops/model/factory.rb +0 -45
  168. data/lib/puppet/pops/model/model_label_provider.rb +0 -5
  169. data/lib/puppet/pops/model/model_tree_dumper.rb +0 -22
  170. data/lib/puppet/pops/model/pn_transformer.rb +0 -16
  171. data/lib/puppet/pops/parser/egrammar.ra +0 -56
  172. data/lib/puppet/pops/parser/eparser.rb +1520 -1712
  173. data/lib/puppet/pops/parser/lexer2.rb +4 -4
  174. data/lib/puppet/pops/parser/parser_support.rb +0 -5
  175. data/lib/puppet/pops/resource/resource_type_impl.rb +2 -22
  176. data/lib/puppet/pops/types/iterable.rb +34 -8
  177. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  178. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  179. data/lib/puppet/pops/types/type_calculator.rb +0 -7
  180. data/lib/puppet/pops/types/type_parser.rb +0 -4
  181. data/lib/puppet/pops/types/types.rb +0 -1
  182. data/lib/puppet/pops/validation/checker4_0.rb +28 -42
  183. data/lib/puppet/pops/validation/tasks_checker.rb +0 -12
  184. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  185. data/lib/puppet/provider.rb +0 -13
  186. data/lib/puppet/provider/file/windows.rb +1 -1
  187. data/lib/puppet/provider/nameservice.rb +0 -18
  188. data/lib/puppet/provider/package/apt.rb +34 -0
  189. data/lib/puppet/provider/package/aptitude.rb +1 -1
  190. data/lib/puppet/provider/package/dpkg.rb +1 -11
  191. data/lib/puppet/provider/package/gem.rb +27 -5
  192. data/lib/puppet/provider/package/pip.rb +0 -1
  193. data/lib/puppet/provider/package/pip2.rb +17 -0
  194. data/lib/puppet/provider/package/pkg.rb +0 -4
  195. data/lib/puppet/provider/package/portage.rb +1 -1
  196. data/lib/puppet/provider/package/puppet_gem.rb +6 -4
  197. data/lib/puppet/provider/package/puppetserver_gem.rb +180 -0
  198. data/lib/puppet/provider/package/yum.rb +2 -1
  199. data/lib/puppet/provider/package/zypper.rb +3 -0
  200. data/lib/puppet/provider/service/smf.rb +191 -73
  201. data/lib/puppet/provider/service/windows.rb +23 -7
  202. data/lib/puppet/provider/user/aix.rb +1 -1
  203. data/lib/puppet/provider/user/directoryservice.rb +0 -10
  204. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  205. data/lib/puppet/provider/user/useradd.rb +11 -4
  206. data/lib/puppet/provider/user/windows_adsi.rb +18 -1
  207. data/lib/puppet/reference/configuration.rb +2 -0
  208. data/lib/puppet/reference/indirection.rb +1 -1
  209. data/lib/puppet/reports/http.rb +2 -0
  210. data/lib/puppet/resource.rb +3 -90
  211. data/lib/puppet/resource/catalog.rb +1 -14
  212. data/lib/puppet/resource/type.rb +5 -112
  213. data/lib/puppet/resource/type_collection.rb +3 -48
  214. data/lib/puppet/runtime.rb +1 -2
  215. data/lib/puppet/settings.rb +84 -35
  216. data/lib/puppet/settings/base_setting.rb +26 -2
  217. data/lib/puppet/settings/integer_setting.rb +17 -0
  218. data/lib/puppet/settings/port_setting.rb +15 -0
  219. data/lib/puppet/settings/priority_setting.rb +5 -4
  220. data/lib/puppet/ssl.rb +10 -6
  221. data/lib/puppet/ssl/base.rb +3 -5
  222. data/lib/puppet/ssl/certificate.rb +0 -6
  223. data/lib/puppet/ssl/certificate_request.rb +1 -12
  224. data/lib/puppet/ssl/certificate_signer.rb +6 -0
  225. data/lib/puppet/ssl/oids.rb +3 -1
  226. data/lib/puppet/ssl/ssl_context.rb +2 -2
  227. data/lib/puppet/ssl/ssl_provider.rb +37 -1
  228. data/lib/puppet/ssl/state_machine.rb +3 -1
  229. data/lib/puppet/ssl/verifier.rb +2 -0
  230. data/lib/puppet/test/test_helper.rb +19 -16
  231. data/lib/puppet/transaction.rb +3 -9
  232. data/lib/puppet/transaction/persistence.rb +1 -1
  233. data/lib/puppet/transaction/report.rb +10 -8
  234. data/lib/puppet/trusted_external.rb +29 -1
  235. data/lib/puppet/type.rb +9 -77
  236. data/lib/puppet/type/file.rb +45 -22
  237. data/lib/puppet/type/file/checksum.rb +5 -5
  238. data/lib/puppet/type/file/source.rb +33 -13
  239. data/lib/puppet/type/filebucket.rb +4 -4
  240. data/lib/puppet/type/notify.rb +2 -2
  241. data/lib/puppet/type/package.rb +5 -13
  242. data/lib/puppet/type/service.rb +53 -0
  243. data/lib/puppet/type/user.rb +18 -3
  244. data/lib/puppet/util.rb +41 -3
  245. data/lib/puppet/util/autoload.rb +9 -7
  246. data/lib/puppet/util/character_encoding.rb +9 -5
  247. data/lib/puppet/util/checksums.rb +19 -4
  248. data/lib/puppet/util/execution.rb +2 -13
  249. data/lib/puppet/util/fileparsing.rb +2 -2
  250. data/lib/puppet/util/http_proxy.rb +2 -215
  251. data/lib/puppet/util/monkey_patches.rb +0 -46
  252. data/lib/puppet/util/provider_features.rb +1 -1
  253. data/lib/puppet/util/rdoc.rb +0 -7
  254. data/lib/puppet/util/reference.rb +1 -1
  255. data/lib/puppet/util/retry_action.rb +1 -1
  256. data/lib/puppet/util/rubygems.rb +5 -1
  257. data/lib/puppet/util/run_mode.rb +14 -2
  258. data/lib/puppet/util/windows.rb +3 -7
  259. data/lib/puppet/util/windows/daemon.rb +360 -0
  260. data/lib/puppet/util/windows/error.rb +1 -0
  261. data/lib/puppet/util/windows/eventlog.rb +5 -15
  262. data/lib/puppet/util/windows/file.rb +8 -242
  263. data/lib/puppet/util/windows/monkey_patches/process.rb +414 -0
  264. data/lib/puppet/util/windows/principal.rb +8 -6
  265. data/lib/puppet/util/windows/process.rb +4 -226
  266. data/lib/puppet/util/windows/registry.rb +11 -11
  267. data/lib/puppet/util/windows/security.rb +4 -4
  268. data/lib/puppet/util/windows/service.rb +52 -486
  269. data/lib/puppet/util/windows/string.rb +12 -13
  270. data/lib/puppet/util/windows/user.rb +242 -8
  271. data/lib/puppet/util/yaml.rb +0 -22
  272. data/lib/puppet/vendor/require_vendored.rb +0 -1
  273. data/lib/puppet/version.rb +1 -1
  274. data/lib/puppet/x509.rb +5 -1
  275. data/lib/puppet/x509/cert_provider.rb +29 -1
  276. data/locales/puppet.pot +713 -1380
  277. data/man/man5/puppet.conf.5 +84 -98
  278. data/man/man8/puppet-agent.8 +7 -4
  279. data/man/man8/puppet-apply.8 +1 -1
  280. data/man/man8/puppet-catalog.8 +1 -1
  281. data/man/man8/puppet-config.8 +6 -6
  282. data/man/man8/puppet-describe.8 +1 -1
  283. data/man/man8/puppet-device.8 +1 -1
  284. data/man/man8/puppet-doc.8 +1 -1
  285. data/man/man8/puppet-epp.8 +1 -1
  286. data/man/man8/puppet-facts.8 +55 -9
  287. data/man/man8/puppet-filebucket.8 +6 -6
  288. data/man/man8/puppet-generate.8 +1 -1
  289. data/man/man8/puppet-help.8 +1 -1
  290. data/man/man8/puppet-lookup.8 +2 -2
  291. data/man/man8/puppet-module.8 +1 -58
  292. data/man/man8/puppet-node.8 +7 -4
  293. data/man/man8/puppet-parser.8 +1 -1
  294. data/man/man8/puppet-plugin.8 +1 -1
  295. data/man/man8/puppet-report.8 +4 -1
  296. data/man/man8/puppet-resource.8 +1 -1
  297. data/man/man8/puppet-script.8 +1 -1
  298. data/man/man8/puppet-ssl.8 +1 -1
  299. data/man/man8/puppet.8 +2 -2
  300. data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/provider/applytest/applytest.rb +2 -0
  301. data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/type/applytest.rb +25 -0
  302. data/spec/fixtures/unit/forge/bacula-releases.json +128 -0
  303. data/spec/fixtures/unit/forge/bacula.tar.gz +0 -0
  304. data/spec/fixtures/unit/provider/package/puppetserver_gem/gem-list-local-packages +30 -0
  305. data/spec/fixtures/unit/provider/service/smf/{svcs.out → svcs_instances.out} +0 -0
  306. data/spec/integration/application/agent_spec.rb +157 -59
  307. data/spec/integration/application/apply_spec.rb +150 -150
  308. data/spec/integration/application/doc_spec.rb +16 -6
  309. data/spec/integration/application/filebucket_spec.rb +78 -29
  310. data/spec/integration/application/help_spec.rb +44 -0
  311. data/spec/integration/application/lookup_spec.rb +13 -0
  312. data/spec/integration/application/module_spec.rb +68 -0
  313. data/spec/integration/application/plugin_spec.rb +76 -4
  314. data/spec/integration/configurer_spec.rb +14 -0
  315. data/spec/integration/data_binding_spec.rb +82 -0
  316. data/spec/integration/defaults_spec.rb +33 -5
  317. data/spec/integration/directory_environments_spec.rb +17 -17
  318. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  319. data/spec/integration/indirector/facts/facter_spec.rb +8 -6
  320. data/spec/integration/network/http_pool_spec.rb +29 -30
  321. data/spec/integration/node/environment_spec.rb +1 -1
  322. data/spec/integration/parser/catalog_spec.rb +0 -38
  323. data/spec/integration/parser/compiler_spec.rb +11 -0
  324. data/spec/integration/parser/node_spec.rb +0 -9
  325. data/spec/integration/parser/pcore_resource_spec.rb +0 -37
  326. data/spec/integration/type/file_spec.rb +6 -5
  327. data/spec/integration/util/execution_spec.rb +22 -0
  328. data/spec/integration/util/windows/adsi_spec.rb +2 -2
  329. data/spec/integration/util/windows/monkey_patches/process_spec.rb +231 -0
  330. data/spec/integration/util/windows/process_spec.rb +26 -32
  331. data/spec/integration/util/windows/registry_spec.rb +7 -7
  332. data/spec/integration/util/windows/security_spec.rb +1 -1
  333. data/spec/integration/util/windows/user_spec.rb +47 -5
  334. data/spec/integration/util_spec.rb +7 -33
  335. data/spec/lib/puppet_spec/matchers.rb +0 -80
  336. data/spec/lib/puppet_spec/puppetserver.rb +9 -1
  337. data/spec/lib/puppet_spec/settings.rb +7 -1
  338. data/spec/shared_contexts/types_setup.rb +2 -0
  339. data/spec/spec_helper.rb +2 -0
  340. data/spec/unit/agent_spec.rb +0 -2
  341. data/spec/unit/application/agent_spec.rb +3 -4
  342. data/spec/unit/application/config_spec.rb +224 -4
  343. data/spec/unit/application/doc_spec.rb +2 -2
  344. data/spec/unit/application/face_base_spec.rb +6 -4
  345. data/spec/unit/application/facts_spec.rb +74 -8
  346. data/spec/unit/application/filebucket_spec.rb +41 -39
  347. data/spec/unit/application/resource_spec.rb +3 -1
  348. data/spec/unit/application/ssl_spec.rb +17 -4
  349. data/spec/unit/application_spec.rb +9 -4
  350. data/spec/unit/certificate_factory_spec.rb +1 -1
  351. data/spec/unit/configurer/downloader_spec.rb +14 -0
  352. data/spec/unit/configurer/fact_handler_spec.rb +4 -4
  353. data/spec/unit/configurer/plugin_handler_spec.rb +56 -18
  354. data/spec/unit/configurer_spec.rb +96 -44
  355. data/spec/unit/confine_spec.rb +2 -1
  356. data/spec/unit/context/trusted_information_spec.rb +12 -10
  357. data/spec/unit/defaults_spec.rb +77 -28
  358. data/spec/unit/environments_spec.rb +96 -32
  359. data/spec/unit/face/config_spec.rb +65 -12
  360. data/spec/unit/face/facts_spec.rb +4 -0
  361. data/spec/unit/face/node_spec.rb +2 -2
  362. data/spec/unit/face/plugin_spec.rb +73 -33
  363. data/spec/unit/file_bucket/file_spec.rb +1 -1
  364. data/spec/unit/file_serving/configuration/parser_spec.rb +14 -18
  365. data/spec/unit/file_serving/configuration_spec.rb +6 -12
  366. data/spec/unit/file_serving/http_metadata_spec.rb +37 -14
  367. data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
  368. data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
  369. data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
  370. data/spec/unit/file_serving/terminus_selector_spec.rb +45 -26
  371. data/spec/unit/file_system/uniquefile_spec.rb +18 -0
  372. data/spec/unit/file_system_spec.rb +1 -2
  373. data/spec/unit/functions/camelcase_spec.rb +1 -1
  374. data/spec/unit/functions/capitalize_spec.rb +1 -1
  375. data/spec/unit/functions/downcase_spec.rb +1 -1
  376. data/spec/unit/functions/inline_epp_spec.rb +26 -1
  377. data/spec/unit/functions/upcase_spec.rb +1 -1
  378. data/spec/unit/http/client_spec.rb +71 -17
  379. data/spec/unit/{network/resolver_spec.rb → http/dns_spec.rb} +3 -3
  380. data/spec/unit/http/external_client_spec.rb +4 -4
  381. data/spec/unit/{network/http → http}/factory_spec.rb +5 -11
  382. data/spec/unit/{network/http/session_spec.rb → http/pool_entry_spec.rb} +3 -3
  383. data/spec/unit/{network/http → http}/pool_spec.rb +12 -17
  384. data/spec/unit/{util/http_proxy_spec.rb → http/proxy_spec.rb} +2 -69
  385. data/spec/unit/http/resolver_spec.rb +34 -15
  386. data/spec/unit/http/response_spec.rb +6 -0
  387. data/spec/unit/http/service/ca_spec.rb +2 -3
  388. data/spec/unit/http/service/compiler_spec.rb +51 -65
  389. data/spec/unit/http/service/file_server_spec.rb +5 -6
  390. data/spec/unit/http/service/puppetserver_spec.rb +112 -0
  391. data/spec/unit/http/service/report_spec.rb +2 -3
  392. data/spec/unit/http/service_spec.rb +1 -3
  393. data/spec/unit/http/session_spec.rb +24 -35
  394. data/spec/unit/{network/http → http}/site_spec.rb +3 -3
  395. data/spec/unit/indirector/catalog/json_spec.rb +1 -1
  396. data/spec/unit/indirector/catalog/rest_spec.rb +1 -1
  397. data/spec/unit/indirector/facts/facter_spec.rb +97 -0
  398. data/spec/unit/indirector/facts/json_spec.rb +255 -0
  399. data/spec/unit/indirector/facts/rest_spec.rb +1 -1
  400. data/spec/unit/indirector/file_bucket_file/file_spec.rb +5 -3
  401. data/spec/unit/indirector/file_content/rest_spec.rb +0 -4
  402. data/spec/unit/indirector/file_metadata/http_spec.rb +27 -0
  403. data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -4
  404. data/spec/unit/indirector/file_server_spec.rb +1 -15
  405. data/spec/unit/indirector/json_spec.rb +8 -8
  406. data/spec/unit/indirector/msgpack_spec.rb +8 -8
  407. data/spec/unit/indirector/node/json_spec.rb +33 -0
  408. data/spec/unit/indirector/node/rest_spec.rb +1 -1
  409. data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
  410. data/spec/unit/indirector/report/rest_spec.rb +2 -17
  411. data/spec/unit/indirector/report/yaml_spec.rb +72 -8
  412. data/spec/unit/indirector/request_spec.rb +3 -267
  413. data/spec/unit/indirector/rest_spec.rb +98 -752
  414. data/spec/unit/indirector/yaml_spec.rb +7 -7
  415. data/spec/unit/interface_spec.rb +3 -3
  416. data/spec/unit/module_tool/tar/mini_spec.rb +20 -0
  417. data/spec/unit/network/authconfig_spec.rb +2 -132
  418. data/spec/unit/network/authorization_spec.rb +2 -55
  419. data/spec/unit/network/format_support_spec.rb +3 -2
  420. data/spec/unit/network/formats_spec.rb +4 -4
  421. data/spec/unit/network/http/api/indirected_routes_spec.rb +3 -98
  422. data/spec/unit/network/http/api/master/v3/environments_spec.rb +12 -23
  423. data/spec/unit/network/http/api/master/v3_spec.rb +28 -7
  424. data/spec/unit/network/http/api_spec.rb +10 -0
  425. data/spec/unit/network/http/connection_spec.rb +61 -73
  426. data/spec/unit/network/http/handler_spec.rb +0 -6
  427. data/spec/unit/network/http_pool_spec.rb +0 -4
  428. data/spec/unit/node/environment_spec.rb +51 -22
  429. data/spec/unit/node_spec.rb +2 -54
  430. data/spec/unit/parser/ast/block_expression_spec.rb +1 -1
  431. data/spec/unit/parser/functions/create_resources_spec.rb +2 -20
  432. data/spec/unit/parser/scope_spec.rb +1 -1
  433. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +19 -8
  434. data/spec/unit/pops/loaders/loaders_spec.rb +77 -22
  435. data/spec/unit/pops/lookup/lookup_spec.rb +25 -0
  436. data/spec/unit/pops/parser/parse_application_spec.rb +4 -22
  437. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +0 -1
  438. data/spec/unit/pops/parser/parse_capabilities_spec.rb +8 -21
  439. data/spec/unit/pops/parser/parse_site_spec.rb +20 -24
  440. data/spec/unit/pops/resource/resource_type_impl_spec.rb +0 -71
  441. data/spec/unit/pops/serialization/to_from_hr_spec.rb +1 -1
  442. data/spec/unit/pops/types/type_calculator_spec.rb +7 -17
  443. data/spec/unit/pops/types/type_factory_spec.rb +1 -1
  444. data/spec/unit/pops/validator/validator_spec.rb +61 -46
  445. data/spec/unit/pops/visitor_spec.rb +1 -1
  446. data/spec/unit/provider/exec_spec.rb +4 -3
  447. data/spec/unit/provider/nameservice_spec.rb +0 -57
  448. data/spec/unit/provider/package/apt_spec.rb +77 -0
  449. data/spec/unit/provider/package/aptitude_spec.rb +1 -0
  450. data/spec/unit/provider/package/dpkg_spec.rb +22 -55
  451. data/spec/unit/provider/package/gem_spec.rb +32 -0
  452. data/spec/unit/provider/package/openbsd_spec.rb +2 -0
  453. data/spec/unit/provider/package/pip2_spec.rb +36 -0
  454. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -2
  455. data/spec/unit/provider/package/puppetserver_gem_spec.rb +137 -0
  456. data/spec/unit/provider/package/yum_spec.rb +31 -0
  457. data/spec/unit/provider/package/zypper_spec.rb +14 -0
  458. data/spec/unit/provider/service/base_spec.rb +2 -4
  459. data/spec/unit/provider/service/bsd_spec.rb +5 -1
  460. data/spec/unit/provider/service/daemontools_spec.rb +1 -1
  461. data/spec/unit/provider/service/debian_spec.rb +3 -5
  462. data/spec/unit/provider/service/freebsd_spec.rb +1 -1
  463. data/spec/unit/provider/service/gentoo_spec.rb +4 -5
  464. data/spec/unit/provider/service/init_spec.rb +45 -5
  465. data/spec/unit/provider/service/launchd_spec.rb +5 -6
  466. data/spec/unit/provider/service/openrc_spec.rb +4 -5
  467. data/spec/unit/provider/service/openwrt_spec.rb +1 -1
  468. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  469. data/spec/unit/provider/service/runit_spec.rb +2 -1
  470. data/spec/unit/provider/service/smf_spec.rb +402 -166
  471. data/spec/unit/provider/service/src_spec.rb +3 -5
  472. data/spec/unit/provider/service/systemd_spec.rb +3 -6
  473. data/spec/unit/provider/service/upstart_spec.rb +4 -5
  474. data/spec/unit/provider/service/windows_spec.rb +50 -15
  475. data/spec/unit/provider/user/openbsd_spec.rb +1 -0
  476. data/spec/unit/provider/user/useradd_spec.rb +22 -16
  477. data/spec/unit/provider/user/windows_adsi_spec.rb +82 -0
  478. data/spec/unit/provider_spec.rb +0 -12
  479. data/spec/unit/puppet_pal_2pec.rb +40 -0
  480. data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
  481. data/spec/unit/reports/store_spec.rb +17 -13
  482. data/spec/unit/resource/type_collection_spec.rb +2 -22
  483. data/spec/unit/resource_spec.rb +3 -59
  484. data/spec/unit/settings/http_extra_headers_spec.rb +2 -4
  485. data/spec/unit/settings/integer_setting_spec.rb +42 -0
  486. data/spec/unit/settings/port_setting_spec.rb +31 -0
  487. data/spec/unit/settings/priority_setting_spec.rb +4 -4
  488. data/spec/unit/settings_spec.rb +586 -239
  489. data/spec/unit/ssl/base_spec.rb +36 -3
  490. data/spec/unit/ssl/certificate_request_spec.rb +15 -45
  491. data/spec/unit/ssl/certificate_spec.rb +2 -11
  492. data/spec/unit/ssl/ssl_provider_spec.rb +78 -49
  493. data/spec/unit/ssl/state_machine_spec.rb +0 -1
  494. data/spec/unit/ssl/verifier_spec.rb +0 -21
  495. data/spec/unit/test/test_helper_spec.rb +17 -0
  496. data/spec/unit/transaction/persistence_spec.rb +15 -0
  497. data/spec/unit/transaction/report_spec.rb +3 -3
  498. data/spec/unit/transaction/resource_harness_spec.rb +2 -2
  499. data/spec/unit/transaction_spec.rb +45 -79
  500. data/spec/unit/type/file/checksum_spec.rb +6 -6
  501. data/spec/unit/type/file/content_spec.rb +1 -1
  502. data/spec/unit/type/file/ensure_spec.rb +1 -1
  503. data/spec/unit/type/file/mode_spec.rb +1 -1
  504. data/spec/unit/type/file/source_spec.rb +4 -5
  505. data/spec/unit/type/file_spec.rb +134 -102
  506. data/spec/unit/type/filebucket_spec.rb +1 -1
  507. data/spec/unit/type/package_spec.rb +1 -1
  508. data/spec/unit/type/service_spec.rb +209 -0
  509. data/spec/unit/type/user_spec.rb +31 -2
  510. data/spec/unit/type_spec.rb +70 -0
  511. data/spec/unit/util/backups_spec.rb +0 -2
  512. data/spec/unit/util/character_encoding_spec.rb +4 -4
  513. data/spec/unit/util/checksums_spec.rb +16 -0
  514. data/spec/unit/util/command_line_spec.rb +11 -6
  515. data/spec/unit/util/execution_spec.rb +0 -29
  516. data/spec/unit/util/monkey_patches_spec.rb +0 -6
  517. data/spec/unit/util/rubygems_spec.rb +2 -2
  518. data/spec/unit/util/run_mode_spec.rb +27 -127
  519. data/spec/unit/util/windows/api_types_spec.rb +104 -40
  520. data/spec/unit/util/windows/service_spec.rb +4 -4
  521. data/spec/unit/util/windows/string_spec.rb +1 -3
  522. data/spec/unit/util/yaml_spec.rb +0 -54
  523. data/spec/unit/util_spec.rb +3 -21
  524. data/spec/unit/x509/cert_provider_spec.rb +1 -1
  525. metadata +76 -270
  526. data/conf/auth.conf +0 -150
  527. data/lib/puppet/application/cert.rb +0 -76
  528. data/lib/puppet/application/key.rb +0 -4
  529. data/lib/puppet/application/man.rb +0 -4
  530. data/lib/puppet/application/status.rb +0 -4
  531. data/lib/puppet/face/key.rb +0 -16
  532. data/lib/puppet/face/man.rb +0 -145
  533. data/lib/puppet/face/module/build.rb +0 -14
  534. data/lib/puppet/face/module/generate.rb +0 -14
  535. data/lib/puppet/face/module/search.rb +0 -103
  536. data/lib/puppet/face/status.rb +0 -51
  537. data/lib/puppet/indirector/certificate/file.rb +0 -9
  538. data/lib/puppet/indirector/certificate/rest.rb +0 -18
  539. data/lib/puppet/indirector/certificate_request/file.rb +0 -9
  540. data/lib/puppet/indirector/certificate_request/memory.rb +0 -7
  541. data/lib/puppet/indirector/certificate_request/rest.rb +0 -11
  542. data/lib/puppet/indirector/file_content/http.rb +0 -22
  543. data/lib/puppet/indirector/key/file.rb +0 -46
  544. data/lib/puppet/indirector/key/memory.rb +0 -7
  545. data/lib/puppet/indirector/ssl_file.rb +0 -162
  546. data/lib/puppet/indirector/status.rb +0 -3
  547. data/lib/puppet/indirector/status/local.rb +0 -12
  548. data/lib/puppet/indirector/status/rest.rb +0 -27
  549. data/lib/puppet/module_tool/applications/searcher.rb +0 -29
  550. data/lib/puppet/network/auth_config_parser.rb +0 -90
  551. data/lib/puppet/network/authstore.rb +0 -283
  552. data/lib/puppet/network/http/api/master/v3/authorization.rb +0 -18
  553. data/lib/puppet/network/http/api/master/v3/environment.rb +0 -85
  554. data/lib/puppet/network/http/base_pool.rb +0 -36
  555. data/lib/puppet/network/http/compression.rb +0 -127
  556. data/lib/puppet/network/http/connection_adapter.rb +0 -182
  557. data/lib/puppet/network/http/nocache_pool.rb +0 -28
  558. data/lib/puppet/network/rest_controller.rb +0 -2
  559. data/lib/puppet/network/rights.rb +0 -210
  560. data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +0 -64
  561. data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +0 -20
  562. data/lib/puppet/parser/environment_compiler.rb +0 -199
  563. data/lib/puppet/pops/types/enumeration.rb +0 -16
  564. data/lib/puppet/resource/capability_finder.rb +0 -154
  565. data/lib/puppet/rest/errors.rb +0 -15
  566. data/lib/puppet/rest/response.rb +0 -35
  567. data/lib/puppet/rest/route.rb +0 -85
  568. data/lib/puppet/rest/routes.rb +0 -135
  569. data/lib/puppet/ssl/host.rb +0 -505
  570. data/lib/puppet/ssl/key.rb +0 -61
  571. data/lib/puppet/ssl/validator.rb +0 -61
  572. data/lib/puppet/ssl/validator/default_validator.rb +0 -209
  573. data/lib/puppet/ssl/validator/no_validator.rb +0 -22
  574. data/lib/puppet/ssl/verifier_adapter.rb +0 -58
  575. data/lib/puppet/status.rb +0 -40
  576. data/lib/puppet/util/connection.rb +0 -88
  577. data/lib/puppet/util/ssl.rb +0 -83
  578. data/lib/puppet/util/windows/api_types.rb +0 -282
  579. data/lib/puppet/vendor/load_pathspec.rb +0 -1
  580. data/lib/puppet/vendor/pathspec/CHANGELOG.md +0 -2
  581. data/lib/puppet/vendor/pathspec/LICENSE +0 -201
  582. data/lib/puppet/vendor/pathspec/PUPPET_README.md +0 -6
  583. data/lib/puppet/vendor/pathspec/README.md +0 -53
  584. data/lib/puppet/vendor/pathspec/lib/pathspec.rb +0 -122
  585. data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +0 -275
  586. data/lib/puppet/vendor/pathspec/lib/pathspec/regexspec.rb +0 -17
  587. data/lib/puppet/vendor/pathspec/lib/pathspec/spec.rb +0 -14
  588. data/man/man8/puppet-key.8 +0 -126
  589. data/man/man8/puppet-man.8 +0 -76
  590. data/man/man8/puppet-status.8 +0 -108
  591. data/spec/integration/faces/config_spec.rb +0 -91
  592. data/spec/integration/faces/documentation_spec.rb +0 -57
  593. data/spec/integration/file_bucket/file_spec.rb +0 -50
  594. data/spec/integration/file_serving/content_spec.rb +0 -7
  595. data/spec/integration/file_serving/fileset_spec.rb +0 -12
  596. data/spec/integration/file_serving/metadata_spec.rb +0 -8
  597. data/spec/integration/file_serving/terminus_helper_spec.rb +0 -20
  598. data/spec/integration/file_system/uniquefile_spec.rb +0 -26
  599. data/spec/integration/module_tool/forge_spec.rb +0 -51
  600. data/spec/integration/module_tool/tar/mini_spec.rb +0 -28
  601. data/spec/integration/network/authconfig_spec.rb +0 -256
  602. data/spec/integration/provider/service/init_spec.rb +0 -48
  603. data/spec/integration/provider/service/systemd_spec.rb +0 -25
  604. data/spec/integration/provider/service/windows_spec.rb +0 -50
  605. data/spec/integration/reference/providers_spec.rb +0 -21
  606. data/spec/integration/reports_spec.rb +0 -13
  607. data/spec/integration/ssl/certificate_request_spec.rb +0 -44
  608. data/spec/integration/ssl/host_spec.rb +0 -72
  609. data/spec/integration/ssl/key_spec.rb +0 -99
  610. data/spec/integration/test/test_helper_spec.rb +0 -31
  611. data/spec/shared_behaviours/file_serving_model.rb +0 -51
  612. data/spec/unit/capability_spec.rb +0 -414
  613. data/spec/unit/face/catalog_spec.rb +0 -6
  614. data/spec/unit/face/key_spec.rb +0 -9
  615. data/spec/unit/face/man_spec.rb +0 -25
  616. data/spec/unit/face/module/search_spec.rb +0 -231
  617. data/spec/unit/face/module_spec.rb +0 -3
  618. data/spec/unit/face/status_spec.rb +0 -9
  619. data/spec/unit/indirector/certificate/file_spec.rb +0 -14
  620. data/spec/unit/indirector/certificate/rest_spec.rb +0 -61
  621. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -14
  622. data/spec/unit/indirector/certificate_request/rest_spec.rb +0 -25
  623. data/spec/unit/indirector/key/file_spec.rb +0 -79
  624. data/spec/unit/indirector/ssl_file_spec.rb +0 -305
  625. data/spec/unit/indirector/status/local_spec.rb +0 -10
  626. data/spec/unit/indirector/status/rest_spec.rb +0 -50
  627. data/spec/unit/man_spec.rb +0 -31
  628. data/spec/unit/module_tool/applications/searcher_spec.rb +0 -38
  629. data/spec/unit/network/auth_config_parser_spec.rb +0 -115
  630. data/spec/unit/network/authstore_spec.rb +0 -422
  631. data/spec/unit/network/http/api/master/v3/authorization_spec.rb +0 -57
  632. data/spec/unit/network/http/api/master/v3/environment_spec.rb +0 -185
  633. data/spec/unit/network/http/compression_spec.rb +0 -240
  634. data/spec/unit/network/http/nocache_pool_spec.rb +0 -64
  635. data/spec/unit/network/http_spec.rb +0 -9
  636. data/spec/unit/network/rights_spec.rb +0 -439
  637. data/spec/unit/parser/environment_compiler_spec.rb +0 -723
  638. data/spec/unit/pops/types/enumeration_spec.rb +0 -51
  639. data/spec/unit/resource/capability_finder_spec.rb +0 -143
  640. data/spec/unit/rest/route_spec.rb +0 -132
  641. data/spec/unit/ssl/host_spec.rb +0 -650
  642. data/spec/unit/ssl/key_spec.rb +0 -173
  643. data/spec/unit/ssl/validator_spec.rb +0 -278
  644. data/spec/unit/status_spec.rb +0 -45
  645. data/spec/unit/util/ssl_spec.rb +0 -91
@@ -6,53 +6,57 @@ require 'pathname'
6
6
  require 'tempfile'
7
7
  require 'fileutils'
8
8
 
9
- processor = Puppet::Reports.report(:store)
10
-
11
- describe processor do
9
+ describe Puppet::Reports.report(:store) do
12
10
  describe "#process" do
13
11
  include PuppetSpec::Files
12
+
14
13
  before :each do
15
14
  Puppet[:reportdir] = File.join(tmpdir('reports'), 'reports')
16
- @report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor
15
+ end
16
+
17
+ let(:report) do
18
+ report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml'))
19
+ report.extend(described_class)
20
+ report
17
21
  end
18
22
 
19
23
  it "should create a report directory for the client if one doesn't exist" do
20
- @report.process
24
+ report.process
21
25
 
22
- expect(File).to be_directory(File.join(Puppet[:reportdir], @report.host))
26
+ expect(File).to be_directory(File.join(Puppet[:reportdir], report.host))
23
27
  end
24
28
 
25
29
  it "should write the report to the file in YAML" do
26
30
  allow(Time).to receive(:now).and_return(Time.utc(2011,01,06,12,00,00))
27
- @report.process
31
+ report.process
28
32
 
29
- expect(File.read(File.join(Puppet[:reportdir], @report.host, "201101061200.yaml"))).to eq(@report.to_yaml)
33
+ expect(File.read(File.join(Puppet[:reportdir], report.host, "201101061200.yaml"))).to eq(report.to_yaml)
30
34
  end
31
35
 
32
36
  it "rejects invalid hostnames" do
33
- @report.host = ".."
37
+ report.host = ".."
34
38
  expect(Puppet::FileSystem).not_to receive(:exist?)
35
- expect { @report.process }.to raise_error(ArgumentError, /Invalid node/)
39
+ expect { report.process }.to raise_error(ArgumentError, /Invalid node/)
36
40
  end
37
41
  end
38
42
 
39
43
  describe "::destroy" do
40
44
  it "rejects invalid hostnames" do
41
45
  expect(Puppet::FileSystem).not_to receive(:unlink)
42
- expect { processor.destroy("..") }.to raise_error(ArgumentError, /Invalid node/)
46
+ expect { described_class.destroy("..") }.to raise_error(ArgumentError, /Invalid node/)
43
47
  end
44
48
  end
45
49
 
46
50
  describe "::validate_host" do
47
51
  ['..', 'hello/', '/hello', 'he/llo', 'hello/..', '.'].each do |node|
48
52
  it "rejects #{node.inspect}" do
49
- expect { processor.validate_host(node) }.to raise_error(ArgumentError, /Invalid node/)
53
+ expect { described_class.validate_host(node) }.to raise_error(ArgumentError, /Invalid node/)
50
54
  end
51
55
  end
52
56
 
53
57
  ['.hello', 'hello.', '..hi', 'hi..'].each do |node|
54
58
  it "accepts #{node.inspect}" do
55
- processor.validate_host(node)
59
+ described_class.validate_host(node)
56
60
  end
57
61
  end
58
62
  end
@@ -75,18 +75,16 @@ describe Puppet::Resource::TypeCollection do
75
75
  end.to raise_error(Puppet::ParseError, /cannot be redefined/)
76
76
  end
77
77
 
78
- it "should remove all nodes, classes, definitions, and applications when cleared" do
78
+ it "should remove all nodes, classes and definitions when cleared" do
79
79
  loader = Puppet::Resource::TypeCollection.new(environment)
80
80
  loader.add Puppet::Resource::Type.new(:hostclass, "class")
81
81
  loader.add Puppet::Resource::Type.new(:definition, "define")
82
82
  loader.add Puppet::Resource::Type.new(:node, "node")
83
- loader.add Puppet::Resource::Type.new(:application, "application")
84
83
 
85
84
  loader.clear
86
85
  expect(loader.hostclass("class")).to be_nil
87
86
  expect(loader.definition("define")).to be_nil
88
87
  expect(loader.node("node")).to be_nil
89
- expect(loader.node("application")).to be_nil
90
88
  end
91
89
 
92
90
  describe "when looking up names" do
@@ -155,7 +153,7 @@ describe Puppet::Resource::TypeCollection do
155
153
  end
156
154
  end
157
155
 
158
- KINDS = %w{hostclass node definition application}
156
+ KINDS = %w{hostclass node definition}
159
157
  KINDS.each do |data|
160
158
  describe "behavior of add for #{data}" do
161
159
 
@@ -178,24 +176,6 @@ describe Puppet::Resource::TypeCollection do
178
176
  it "should return nil when asked for a #{data} that has not been added" do
179
177
  expect(Puppet::Resource::TypeCollection.new(environment).send(data, "foo")).to be_nil
180
178
  end
181
-
182
- if data != "node"
183
- it "should fail if an application with the same name is added" do
184
- loader = Puppet::Resource::TypeCollection.new(environment)
185
- instance = Puppet::Resource::Type.new(data, "foo")
186
- application = Puppet::Resource::Type.new(:application, "foo")
187
- loader.add(instance)
188
- expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
189
- end
190
-
191
- it "should fail if there is an application with the same name" do
192
- loader = Puppet::Resource::TypeCollection.new(environment)
193
- application = Puppet::Resource::Type.new(:application, "foo")
194
- instance = Puppet::Resource::Type.new(data, "foo")
195
- loader.add(instance)
196
- expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
197
- end
198
- end
199
179
  end
200
180
  end
201
181
 
@@ -283,40 +283,7 @@ describe Puppet::Resource do
283
283
  let(:scope) { Puppet::Parser::Scope.new(compiler) }
284
284
 
285
285
  def ast_leaf(value)
286
- Puppet::Parser::AST::Leaf.new({:value => value})
287
- end
288
-
289
- it "should fail when asked to set default values and it is not a parser resource" do
290
- environment.known_resource_types.add(
291
- Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("default")})
292
- )
293
- resource = Puppet::Resource.new("default_param", "name", :environment => environment)
294
- expect { resource.set_default_parameters(scope) }.to raise_error(Puppet::DevError)
295
- end
296
-
297
- it "should evaluate and set any default values when no value is provided" do
298
- environment.known_resource_types.add(
299
- Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("a_default_value")})
300
- )
301
- resource = Puppet::Parser::Resource.new("default_param", "name", :scope => scope)
302
- resource.set_default_parameters(scope)
303
- expect(resource["a"]).to eq("a_default_value")
304
- end
305
-
306
- it "should skip attributes with no default value" do
307
- environment.known_resource_types.add(
308
- Puppet::Resource::Type.new(:definition, "no_default_param", :arguments => {"a" => ast_leaf("a_default_value")})
309
- )
310
- resource = Puppet::Parser::Resource.new("no_default_param", "name", :scope => scope)
311
- expect { resource.set_default_parameters(scope) }.not_to raise_error
312
- end
313
-
314
- it "should return the list of default parameters set" do
315
- environment.known_resource_types.add(
316
- Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("a_default_value")})
317
- )
318
- resource = Puppet::Parser::Resource.new("default_param", "name", :scope => scope)
319
- expect(resource.set_default_parameters(scope)).to eq(["a"])
286
+ Puppet::Parser::AST::Leaf.new(value: value)
320
287
  end
321
288
 
322
289
  describe "when the resource type is :hostclass" do
@@ -389,7 +356,7 @@ describe Puppet::Resource do
389
356
  context "when a value is provided" do
390
357
  let(:port_parameter) do
391
358
  Puppet::Parser::Resource::Param.new(
392
- { :name => 'port', :value => '8080' }
359
+ name: 'port', value: '8080'
393
360
  )
394
361
  end
395
362
 
@@ -405,7 +372,6 @@ describe Puppet::Resource do
405
372
 
406
373
  it "should use the value provided" do
407
374
  expect(Puppet::DataBinding.indirection).not_to receive(:find)
408
- expect(resource.set_default_parameters(scope)).to eq([])
409
375
  expect(resource[:port]).to eq('8080')
410
376
  end
411
377
 
@@ -414,7 +380,7 @@ describe Puppet::Resource do
414
380
  expect_lookup('apache::port', returns: '443')
415
381
 
416
382
  rs = Puppet::Parser::Resource.new("class", "apache", :scope => scope,
417
- :parameters => [Puppet::Parser::Resource::Param.new({ :name => 'port', :value => nil })])
383
+ :parameters => [Puppet::Parser::Resource::Param.new(name: 'port', value: nil)])
418
384
 
419
385
  rs.resource_type.set_resource_parameters(rs, scope)
420
386
  expect(rs[:port]).to eq('443')
@@ -447,28 +413,6 @@ describe Puppet::Resource do
447
413
  end
448
414
  end
449
415
 
450
- describe "when validating all required parameters are present" do
451
- it "should be able to validate that all required parameters are present" do
452
- environment.known_resource_types.add(
453
- Puppet::Resource::Type.new(:definition, "required_param", :arguments => {"a" => nil})
454
- )
455
- expect { Puppet::Resource.new("required_param", "name", :environment => environment).validate_complete }.to raise_error(Puppet::ParseError)
456
- end
457
-
458
- it "should not fail when all required parameters are present" do
459
- environment.known_resource_types.add(
460
- Puppet::Resource::Type.new(:definition, "no_required_param")
461
- )
462
- resource = Puppet::Resource.new("no_required_param", "name", :environment => environment)
463
- resource["a"] = "meh"
464
- expect { resource.validate_complete }.not_to raise_error
465
- end
466
-
467
- it "should not validate against builtin types" do
468
- expect { Puppet::Resource.new("file", "/bar").validate_complete }.not_to raise_error
469
- end
470
- end
471
-
472
416
  describe "when referring to a resource with name canonicalization" do
473
417
  it "should canonicalize its own name" do
474
418
  res = Puppet::Resource.new("file", "/path/")
@@ -46,18 +46,16 @@ describe Puppet::Settings::HttpExtraHeadersSetting do
46
46
  end
47
47
 
48
48
  describe 'raises an error when' do
49
-
50
- # Ruby 2.3 reports the class of these objects as Fixnum, whereas later ruby versions report them as Integer
51
49
  it 'is given an unexpected object type' do
52
50
  expect {
53
51
  subject.munge(65)
54
- }.to raise_error(ArgumentError, /^Expected an Array, String, or Hash, got a (Integer|Fixnum)/)
52
+ }.to raise_error(ArgumentError, /^Expected an Array, String, or Hash, got a Integer/)
55
53
  end
56
54
 
57
55
  it 'is given an array of unexpected object types' do
58
56
  expect {
59
57
  subject.munge([65, 82])
60
- }.to raise_error(ArgumentError, /^Expected an Array or String, got a (Integer|Fixnum)/)
58
+ }.to raise_error(ArgumentError, /^Expected an Array or String, got a Integer/)
61
59
  end
62
60
  end
63
61
  end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ require 'puppet/settings'
4
+ require 'puppet/settings/integer_setting'
5
+
6
+ describe Puppet::Settings::IntegerSetting do
7
+ let(:setting) { described_class.new(:settings => double('settings'), :desc => "test") }
8
+
9
+ it "is of type :integer" do
10
+ expect(setting.type).to eq(:integer)
11
+ end
12
+
13
+ describe "when munging the setting" do
14
+ it "returns the same value if given a positive integer" do
15
+ expect(setting.munge(5)).to eq(5)
16
+ end
17
+
18
+ it "returns the same value if given a negative integer" do
19
+ expect(setting.munge(-25)).to eq(-25)
20
+ end
21
+
22
+ it "returns an integer if given a valid integer as string" do
23
+ expect(setting.munge('12')).to eq(12)
24
+ end
25
+
26
+ it "returns an integer if given a valid negative integer as string" do
27
+ expect(setting.munge('-12')).to eq(-12)
28
+ end
29
+
30
+ it "returns an integer if given a valid positive integer as string" do
31
+ expect(setting.munge('+12')).to eq(12)
32
+ end
33
+
34
+ it "raises if given an invalid value" do
35
+ expect { setting.munge('a5') }.to raise_error(Puppet::Settings::ValidationError)
36
+ end
37
+
38
+ it "raises if given nil" do
39
+ expect { setting.munge(nil) }.to raise_error(Puppet::Settings::ValidationError)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ require 'puppet/settings'
4
+ require 'puppet/settings/port_setting'
5
+
6
+ describe Puppet::Settings::PortSetting do
7
+ let(:setting) { described_class.new(:settings => double('settings'), :desc => "test") }
8
+
9
+ it "is of type :port" do
10
+ expect(setting.type).to eq(:port)
11
+ end
12
+
13
+ describe "when munging the setting" do
14
+ it "returns the same value if given a valid port as integer" do
15
+ expect(setting.munge(5)).to eq(5)
16
+ end
17
+
18
+ it "returns an integer if given valid port as string" do
19
+ expect(setting.munge('12')).to eq(12)
20
+ end
21
+
22
+ it "raises if given a negative port number" do
23
+ expect { setting.munge('-5') }.to raise_error(Puppet::Settings::ValidationError)
24
+ end
25
+
26
+ it "raises if the port number is too high" do
27
+ expect { setting.munge(65536) }.to raise_error(Puppet::Settings::ValidationError)
28
+ end
29
+
30
+ end
31
+ end
@@ -52,10 +52,10 @@ describe Puppet::Settings::PrioritySetting do
52
52
  describe "on a Windows-like platform it", :if => Puppet::Util::Platform.windows? do
53
53
  it "parses high, normal, low, and idle priorities" do
54
54
  {
55
- 'high' => Puppet::Util::Windows::Process::HIGH_PRIORITY_CLASS,
56
- 'normal' => Puppet::Util::Windows::Process::NORMAL_PRIORITY_CLASS,
57
- 'low' => Puppet::Util::Windows::Process::BELOW_NORMAL_PRIORITY_CLASS,
58
- 'idle' => Puppet::Util::Windows::Process::IDLE_PRIORITY_CLASS
55
+ 'high' => Puppet::FFI::Windows::Constants::HIGH_PRIORITY_CLASS,
56
+ 'normal' => Puppet::FFI::Windows::Constants::NORMAL_PRIORITY_CLASS,
57
+ 'low' => Puppet::FFI::Windows::Constants::BELOW_NORMAL_PRIORITY_CLASS,
58
+ 'idle' => Puppet::FFI::Windows::Constants::IDLE_PRIORITY_CLASS
59
59
  }.each do |value, converted_value|
60
60
  expect(setting.munge(value)).to eq(converted_value)
61
61
  end
@@ -9,7 +9,7 @@ describe Puppet::Settings do
9
9
  include Matchers::Resource
10
10
 
11
11
  let(:main_config_file_default_location) do
12
- File.join(Puppet::Util::RunMode[:master].conf_dir, "puppet.conf")
12
+ File.join(Puppet::Util::RunMode[:server].conf_dir, "puppet.conf")
13
13
  end
14
14
 
15
15
  let(:user_config_file_default_location) do
@@ -87,16 +87,7 @@ describe Puppet::Settings do
87
87
  end
88
88
  end
89
89
 
90
-
91
90
  describe "when initializing application defaults do" do
92
- let(:default_values) do
93
- values = {}
94
- PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
95
- values[key] = 'default value'
96
- end
97
- values
98
- end
99
-
100
91
  before do
101
92
  @settings = Puppet::Settings.new
102
93
  @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
@@ -104,7 +95,7 @@ describe Puppet::Settings do
104
95
 
105
96
  it "should fail if the app defaults hash is missing any required values" do
106
97
  expect {
107
- @settings.initialize_app_defaults(default_values.reject { |key, _| key == :confdir })
98
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.reject { |key, _| key == :confdir })
108
99
  }.to raise_error(Puppet::Settings::SettingsError)
109
100
  end
110
101
 
@@ -112,16 +103,16 @@ describe Puppet::Settings do
112
103
  # case behaviors / uses. However, until that time... we need to make sure that our private run_mode=
113
104
  # setter method gets properly called during app initialization.
114
105
  it "sets the preferred run mode when initializing the app defaults" do
115
- @settings.initialize_app_defaults(default_values.merge(:run_mode => :master))
106
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
116
107
 
117
- expect(@settings.preferred_run_mode).to eq(:master)
108
+ expect(@settings.preferred_run_mode).to eq(:server)
118
109
  end
119
110
 
120
111
  it "creates ancestor directories for all required app settings" do
121
112
  # initialize_app_defaults is called in spec_helper, before we even
122
113
  # get here, but call it here to make it explicit what we're trying
123
114
  # to do.
124
- @settings.initialize_app_defaults(default_values)
115
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
125
116
 
126
117
  Puppet::Settings::REQUIRED_APP_SETTINGS.each do |key|
127
118
  expect(File).to exist(File.dirname(Puppet[key]))
@@ -148,6 +139,7 @@ describe Puppet::Settings do
148
139
  end.to_not raise_error
149
140
  end
150
141
  end
142
+
151
143
  describe "if no interpolation error" do
152
144
  it "should not raise an error" do
153
145
  hook_values = []
@@ -177,6 +169,7 @@ describe Puppet::Settings do
177
169
  @settings.send(:call_hooks_deferred_to_application_initialization, options)
178
170
  end.to raise_error(Puppet::Settings::InterpolationError)
179
171
  end
172
+
180
173
  it "should contain the setting name in error message" do
181
174
  hook_values = []
182
175
  @settings.define_settings(
@@ -193,6 +186,7 @@ describe Puppet::Settings do
193
186
  end.to raise_error(Puppet::Settings::InterpolationError, /badhook/)
194
187
  end
195
188
  end
189
+
196
190
  describe "if no interpolation error" do
197
191
  it "should not raise an error" do
198
192
  hook_values = []
@@ -326,7 +320,7 @@ describe Puppet::Settings do
326
320
  end
327
321
 
328
322
  it "should identify configured settings from the specified run mode" do
329
- user_config_text = "[master]\nmyval = foo"
323
+ user_config_text = "[server]\nmyval = foo"
330
324
 
331
325
  allow(Puppet.features).to receive(:root?).and_return(false)
332
326
  expect(Puppet::FileSystem).to receive(:exist?).
@@ -337,7 +331,7 @@ describe Puppet::Settings do
337
331
  and_return(user_config_text).ordered
338
332
 
339
333
  @settings.send(:parse_config_files)
340
- expect(@settings.set_by_config?(:myval, nil, :master)).to be_truthy
334
+ expect(@settings.set_by_config?(:myval, nil, :server)).to be_truthy
341
335
  end
342
336
 
343
337
  it "should not identify configured settings from an unspecified run mode" do
@@ -382,7 +376,7 @@ describe Puppet::Settings do
382
376
 
383
377
  it "should clear the cache when the preferred_run_mode is changed" do
384
378
  expect(@settings).to receive(:flush_cache)
385
- @settings.preferred_run_mode = :master
379
+ @settings.preferred_run_mode = :server
386
380
  end
387
381
 
388
382
  it "should not clear other values when setting getopt-specific values" do
@@ -397,122 +391,320 @@ describe Puppet::Settings do
397
391
  end
398
392
 
399
393
  describe "call_hook" do
394
+ let(:config_file) { tmpfile('config') }
395
+
396
+ before :each do
397
+ # We can't specify the config file to read from using `Puppet[:config] =`
398
+ # or pass it as an arg to Puppet.initialize_global_settings, because
399
+ # both of those will set the value on the `Puppet.settings` instance
400
+ # which is different from the `@settings` instance created in the test.
401
+ # Instead, we define a `:config` setting and set its default value to
402
+ # the `config_file` temp file, and then access the `config_file` within
403
+ # each test.
404
+ @settings.define_settings(:main, :config => { :type => :file, :desc => "config file", :default => config_file })
405
+ end
406
+
400
407
  Puppet::Settings::StringSetting.available_call_hook_values.each do |val|
401
408
  describe "when :#{val}" do
402
409
  describe "and definition invalid" do
403
410
  it "should raise error if no hook defined" do
404
411
  expect do
405
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => val})
412
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val})
406
413
  end.to raise_error(ArgumentError, /no :hook/)
407
414
  end
415
+
408
416
  it "should include the setting name in the error message" do
409
417
  expect do
410
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => val})
411
- end.to raise_error(ArgumentError, /for :hooker/)
418
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val})
419
+ end.to raise_error(ArgumentError, /for :setting/)
412
420
  end
413
421
  end
422
+
414
423
  describe "and definition valid" do
415
424
  before(:each) do
416
425
  hook_values = []
417
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => val, :hook => lambda { |v| hook_values << v }})
426
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val, :hook => lambda { |v| hook_values << v }})
418
427
  end
419
428
 
420
429
  it "should call the hook when value written" do
421
- expect(@settings.setting(:hooker)).to receive(:handle).with("something").once
422
- @settings[:hooker] = "something"
430
+ expect(@settings.setting(:setting)).to receive(:handle).with("something").once
431
+ @settings[:setting] = "something"
423
432
  end
424
433
  end
425
434
  end
426
435
  end
427
436
 
428
437
  it "should have a default value of :on_write_only" do
429
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
430
- expect(@settings.setting(:hooker).call_hook).to eq(:on_write_only)
438
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
439
+ expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
431
440
  end
432
441
 
433
442
  describe "when nil" do
434
443
  it "should generate a warning" do
435
444
  expect(Puppet).to receive(:warning)
436
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
445
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
437
446
  end
447
+
438
448
  it "should use default" do
439
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
440
- expect(@settings.setting(:hooker).call_hook).to eq(:on_write_only)
449
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
450
+ expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
441
451
  end
442
452
  end
443
453
 
444
454
  describe "when invalid" do
445
455
  it "should raise an error" do
446
456
  expect do
447
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => :foo, :hook => lambda { |v| hook_values << v }})
457
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => :foo, :hook => lambda { |v| hook_values << v }})
448
458
  end.to raise_error(ArgumentError, /invalid.*call_hook/i)
449
459
  end
450
460
  end
451
461
 
462
+ describe "when :on_write_only" do
463
+ it "returns its hook type" do
464
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |_| }})
465
+
466
+ expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
467
+ end
468
+
469
+ it "should not call the hook at definition" do
470
+ hook_values = []
471
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
472
+
473
+ expect(hook_values).to eq(%w[])
474
+ end
475
+
476
+ it "calls the hook when initializing global defaults with the value from the `main` section" do
477
+ hook_values = []
478
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
479
+
480
+ File.write(config_file, <<~END)
481
+ [main]
482
+ setting=in_main
483
+ END
484
+ @settings.initialize_global_settings
485
+
486
+ expect(@settings[:setting]).to eq('in_main')
487
+ expect(hook_values).to eq(%w[in_main])
488
+ end
489
+
490
+ it "doesn't call the hook when initializing app defaults" do
491
+ hook_values = []
492
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
493
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
494
+
495
+ File.write(config_file, <<~END)
496
+ [main]
497
+ setting=in_main
498
+ [agent]
499
+ setting=in_agent
500
+ END
501
+ @settings.initialize_global_settings
502
+
503
+ hook_values.clear
504
+
505
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
506
+
507
+ expect(@settings[:setting]).to eq('in_main')
508
+ expect(hook_values).to eq(%w[])
509
+ end
510
+
511
+ it "doesn't call the hook with value from a section that matches the run_mode" do
512
+ hook_values = []
513
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
514
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
515
+
516
+ File.write(config_file, <<~END)
517
+ [main]
518
+ setting=in_main
519
+ [agent]
520
+ setting=in_agent
521
+ END
522
+ @settings.initialize_global_settings
523
+
524
+ hook_values.clear
525
+
526
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
527
+
528
+ expect(@settings[:setting]).to eq('in_agent')
529
+ expect(hook_values).to eq(%w[])
530
+ end
531
+ end
532
+
452
533
  describe "when :on_define_and_write" do
453
- it "should call the hook at definition" do
534
+ it "returns its hook type" do
535
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |_| }})
536
+
537
+ expect(@settings.setting(:setting).call_hook).to eq(:on_define_and_write)
538
+ end
539
+
540
+ it "should call the hook at definition with the default value" do
541
+ hook_values = []
542
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
543
+
544
+ expect(hook_values).to eq(%w[yay])
545
+ end
546
+
547
+ it "calls the hook when initializing global defaults with the value from the `main` section" do
548
+ hook_values = []
549
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
550
+
551
+ File.write(config_file, <<~END)
552
+ [main]
553
+ setting=in_main
554
+ END
555
+ @settings.initialize_global_settings
556
+
557
+ expect(@settings[:setting]).to eq('in_main')
558
+ expect(hook_values).to eq(%w[yay in_main])
559
+ end
560
+
561
+ it "doesn't call the hook when initializing app defaults" do
562
+ hook_values = []
563
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
564
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
565
+
566
+ File.write(config_file, <<~END)
567
+ [main]
568
+ setting=in_main
569
+ [agent]
570
+ setting=in_agent
571
+ END
572
+ @settings.initialize_global_settings
573
+
574
+ hook_values.clear
575
+
576
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
577
+
578
+ expect(@settings[:setting]).to eq('in_main')
579
+ expect(hook_values).to eq([])
580
+ end
581
+
582
+ it "doesn't call the hook with value from a section that matches the run_mode" do
454
583
  hook_values = []
455
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
456
- expect(@settings.setting(:hooker).call_hook).to eq(:on_define_and_write)
457
- expect(hook_values).to eq(%w{yay})
584
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
585
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
586
+
587
+ File.write(config_file, <<~END)
588
+ [main]
589
+ setting=in_main
590
+ [agent]
591
+ setting=in_agent
592
+ END
593
+
594
+ @settings.initialize_global_settings
595
+
596
+ hook_values.clear
597
+
598
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
599
+
600
+ # The correct value is returned
601
+ expect(@settings[:setting]).to eq('in_agent')
602
+
603
+ # but the hook is never called, seems like a bug!
604
+ expect(hook_values).to eq([])
458
605
  end
459
606
  end
460
607
 
461
608
  describe "when :on_initialize_and_write" do
462
- before(:each) do
463
- @hook_values = []
464
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| @hook_values << v }})
609
+ it "returns its hook type" do
610
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |_| }})
611
+
612
+ expect(@settings.setting(:setting).call_hook).to eq(:on_initialize_and_write)
465
613
  end
466
614
 
467
615
  it "should not call the hook at definition" do
468
- expect(@hook_values).to eq([])
469
- expect(@hook_values).not_to eq(%w{yay})
616
+ hook_values = []
617
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
618
+ expect(hook_values).to eq([])
470
619
  end
471
620
 
472
- it "should call the hook at initialization" do
473
- app_defaults = {}
474
- Puppet::Settings::REQUIRED_APP_SETTINGS.each do |key|
475
- app_defaults[key] = "foo"
476
- end
477
- app_defaults[:run_mode] = :user
621
+ it "calls the hook when initializing global defaults with the value from the `main` section" do
622
+ hook_values = []
623
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
624
+
625
+ File.write(config_file, <<~END)
626
+ [main]
627
+ setting=in_main
628
+ END
629
+ @settings.initialize_global_settings
630
+
631
+ expect(@settings[:setting]).to eq('in_main')
632
+ expect(hook_values).to eq(%w[in_main])
633
+ end
634
+
635
+ it "calls the hook when initializing app defaults" do
636
+ hook_values = []
478
637
  @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
638
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
479
639
 
480
- expect(@settings.setting(:hooker)).to receive(:handle).with("yay").once
640
+ File.write(config_file, <<~END)
641
+ [main]
642
+ setting=in_main
643
+ [agent]
644
+ setting=in_agent
645
+ END
646
+ @settings.initialize_global_settings
481
647
 
482
- @settings.initialize_app_defaults app_defaults
648
+ hook_values.clear
649
+
650
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
651
+
652
+ expect(@settings[:setting]).to eq('in_main')
653
+ expect(hook_values).to eq(%w[in_main])
654
+ end
655
+
656
+ it "calls the hook with the overridden value from a section that matches the run_mode" do
657
+ hook_values = []
658
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
659
+ @settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
660
+
661
+ File.write(config_file, <<~END)
662
+ [main]
663
+ setting=in_main
664
+ [agent]
665
+ setting=in_agent
666
+ END
667
+ @settings.initialize_global_settings
668
+
669
+ hook_values.clear
670
+
671
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
672
+
673
+ expect(@settings[:setting]).to eq('in_agent')
674
+ expect(hook_values).to eq(%w[in_agent])
483
675
  end
484
676
  end
485
677
  end
486
678
 
487
679
  it "should call passed blocks when values are set" do
488
680
  values = []
489
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
681
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
490
682
  expect(values).to eq([])
491
683
 
492
- @settings[:hooker] = "something"
684
+ @settings[:setting] = "something"
493
685
  expect(values).to eq(%w{something})
494
686
  end
495
687
 
496
688
  it "should call passed blocks when values are set via the command line" do
497
689
  values = []
498
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
690
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
499
691
  expect(values).to eq([])
500
692
 
501
- @settings.handlearg("--hooker", "yay")
693
+ @settings.handlearg("--setting", "yay")
502
694
 
503
695
  expect(values).to eq(%w{yay})
504
696
  end
505
697
 
506
698
  it "should provide an option to call passed blocks during definition" do
507
699
  values = []
508
- @settings.define_settings(:section, :hooker => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
700
+ @settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
509
701
  expect(values).to eq(%w{yay})
510
702
  end
511
703
 
512
704
  it "should pass the fully interpolated value to the hook when called on definition" do
513
705
  values = []
514
706
  @settings.define_settings(:section, :one => { :default => "test", :desc => "a" })
515
- @settings.define_settings(:section, :hooker => {:default => "$one/yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
707
+ @settings.define_settings(:section, :setting => {:default => "$one/yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
516
708
  expect(values).to eq(%w{test/yay})
517
709
  end
518
710
 
@@ -561,12 +753,8 @@ describe Puppet::Settings do
561
753
  end
562
754
 
563
755
  it "setting a value to nil causes it to return to its default" do
564
- default_values = { :one => "skipped value" }
565
- [:logdir, :confdir, :codedir, :vardir].each do |key|
566
- default_values[key] = 'default value'
567
- end
568
756
  @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
569
- @settings.initialize_app_defaults(default_values)
757
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:one => "skipped value"))
570
758
  @settings[:one] = "value will disappear"
571
759
 
572
760
  @settings[:one] = nil
@@ -627,13 +815,14 @@ describe Puppet::Settings do
627
815
  end
628
816
 
629
817
  describe "when choosing which value to return" do
818
+ let(:config_file) { tmpfile('settings') }
819
+
630
820
  before do
631
821
  @settings = Puppet::Settings.new
632
822
  @settings.define_settings :section,
633
- :config => { :type => :file, :default => "/my/file", :desc => "a" },
823
+ :config => { :type => :file, :default => config_file, :desc => "a" },
634
824
  :one => { :default => "ONE", :desc => "a" },
635
825
  :two => { :default => "TWO", :desc => "b" }
636
- allow(Puppet::FileSystem).to receive(:exist?).and_return(true)
637
826
  @settings.preferred_run_mode = :agent
638
827
  end
639
828
 
@@ -642,26 +831,44 @@ describe Puppet::Settings do
642
831
  end
643
832
 
644
833
  it "should return values set on the cli before values set in the configuration file" do
645
- text = "[main]\none = fileval\n"
646
- allow(@settings).to receive(:read_file).and_return(text)
834
+ File.write(config_file, "[main]\none = fileval\n")
647
835
  @settings.handlearg("--one", "clival")
648
- @settings.send(:parse_config_files)
836
+ @settings.initialize_global_settings
649
837
 
650
838
  expect(@settings[:one]).to eq("clival")
651
839
  end
652
840
 
653
841
  it "should return values set in the mode-specific section before values set in the main section" do
654
- text = "[main]\none = mainval\n[agent]\none = modeval\n"
655
- allow(@settings).to receive(:read_file).and_return(text)
656
- @settings.send(:parse_config_files)
842
+ File.write(config_file, "[main]\none = mainval\n[agent]\none = modeval\n")
843
+ @settings.initialize_global_settings
657
844
 
658
845
  expect(@settings[:one]).to eq("modeval")
659
846
  end
660
847
 
848
+ [:master, :server].each do |run_mode|
849
+ describe "when run mode is '#{run_mode}'" do
850
+ before(:each) { @settings.preferred_run_mode = run_mode }
851
+
852
+ it "returns values set in the 'master' section if the 'server' section does not exist" do
853
+ File.write(config_file, "[main]\none = mainval\n[master]\none = modeval\n")
854
+ @settings.initialize_global_settings
855
+
856
+ expect(@settings[:one]).to eq("modeval")
857
+ end
858
+
859
+ it "prioritizes values set in the 'server' section if set" do
860
+ File.write(config_file, "[main]\none = mainval\n[server]\none = serverval\n[master]\none = masterval\n")
861
+ @settings.initialize_global_settings
862
+
863
+ expect(@settings[:one]).to eq("serverval")
864
+ end
865
+ end
866
+ end
867
+
661
868
  it "should not return values outside of its search path" do
662
- text = "[other]\none = oval\n"
663
- allow(@settings).to receive(:read_file).and_return(text)
664
- @settings.send(:parse_config_files)
869
+ File.write(config_file, "[other]\none = oval\n")
870
+ @settings.initialize_global_settings
871
+
665
872
  expect(@settings[:one]).to eq("ONE")
666
873
  end
667
874
 
@@ -683,7 +890,7 @@ describe Puppet::Settings do
683
890
  expect(Puppet::FileSystem).to receive(:exist?).with(main_config_file_default_location).and_return(false)
684
891
  expect(Puppet::FileSystem).not_to receive(:exist?).with(user_config_file_default_location)
685
892
 
686
- @settings.send(:parse_config_files)
893
+ @settings.initialize_global_settings
687
894
  end
688
895
  end
689
896
 
@@ -693,7 +900,7 @@ describe Puppet::Settings do
693
900
 
694
901
  expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
695
902
 
696
- @settings.send(:parse_config_files)
903
+ @settings.initialize_global_settings
697
904
  end
698
905
  end
699
906
 
@@ -702,7 +909,7 @@ describe Puppet::Settings do
702
909
  expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(true)
703
910
  expect(@settings).to receive(:read_file).and_raise('Permission denied')
704
911
 
705
- expect{ @settings.send(:parse_config_files) }.to raise_error(RuntimeError, /Could not load #{user_config_file_default_location}: Permission denied/)
912
+ expect{ @settings.initialize_global_settings }.to raise_error(RuntimeError, /Could not load #{user_config_file_default_location}: Permission denied/)
706
913
  end
707
914
 
708
915
  it "does not fail if the file is not readable and when `require_config` is false" do
@@ -712,7 +919,7 @@ describe Puppet::Settings do
712
919
  expect(@settings).not_to receive(:parse_config)
713
920
  expect(Puppet).to receive(:log_exception)
714
921
 
715
- expect{ @settings.send(:parse_config_files, false) }.not_to raise_error
922
+ expect{ @settings.initialize_global_settings([], false) }.not_to raise_error
716
923
  end
717
924
 
718
925
  it "reads the file if it is readable" do
@@ -720,7 +927,7 @@ describe Puppet::Settings do
720
927
  expect(@settings).to receive(:read_file).and_return('server = host.string')
721
928
  expect(@settings).to receive(:parse_config)
722
929
 
723
- @settings.send(:parse_config_files)
930
+ @settings.initialize_global_settings
724
931
  end
725
932
  end
726
933
 
@@ -729,7 +936,7 @@ describe Puppet::Settings do
729
936
  expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
730
937
  expect(@settings).not_to receive(:parse_config)
731
938
 
732
- @settings.send(:parse_config_files)
939
+ @settings.initialize_global_settings
733
940
  end
734
941
  end
735
942
  end
@@ -739,43 +946,41 @@ describe Puppet::Settings do
739
946
  @settings = Puppet::Settings.new
740
947
  allow(@settings).to receive(:service_user_available?).and_return(true)
741
948
  allow(@settings).to receive(:service_group_available?).and_return(true)
742
- @file = make_absolute("/some/file")
743
- @userconfig = make_absolute("/test/userconfigfile")
949
+ @file = tmpfile("somefile")
744
950
  @settings.define_settings :section, :user => { :default => "suser", :desc => "doc" }, :group => { :default => "sgroup", :desc => "doc" }
745
951
  @settings.define_settings :section,
746
952
  :config => { :type => :file, :default => @file, :desc => "eh" },
747
953
  :one => { :default => "ONE", :desc => "a" },
748
954
  :two => { :default => "$one TWO", :desc => "b" },
749
955
  :three => { :default => "$one $two THREE", :desc => "c" }
750
- allow(@settings).to receive(:user_config_file).and_return(@userconfig)
751
- allow(Puppet::FileSystem).to receive(:exist?).with(@file).and_return(true)
752
- allow(Puppet::FileSystem).to receive(:exist?).with(@userconfig).and_return(false)
956
+
957
+ userconfig = tmpfile("userconfig")
958
+ allow(@settings).to receive(:user_config_file).and_return(userconfig)
753
959
  end
754
960
 
755
961
  it "should not ignore the report setting" do
756
962
  @settings.define_settings :section, :report => { :default => "false", :desc => "a" }
757
- # This is needed in order to make sure we pass on windows
758
- myfile = File.expand_path(@file)
759
- @settings[:config] = myfile
760
- text = <<-CONF
963
+ File.write(@file, <<~CONF)
761
964
  [puppetd]
762
- report=true
965
+ report=true
763
966
  CONF
764
- expect(Puppet::FileSystem).to receive(:exist?).with(myfile).and_return(true)
765
- expect(@settings).to receive(:read_file).and_return(text)
766
- @settings.send(:parse_config_files)
967
+
968
+ @settings.initialize_global_settings
969
+
767
970
  expect(@settings[:report]).to be_truthy
768
971
  end
769
972
 
770
973
  it "should use its current ':config' value for the file to parse" do
771
- myfile = make_absolute("/my/file")
772
- @settings[:config] = myfile
773
-
774
- expect(Puppet::FileSystem).to receive(:exist?).with(myfile).and_return(true)
974
+ myfile = tmpfile('myfile')
975
+ File.write(myfile, <<~CONF)
976
+ [main]
977
+ one=myfile
978
+ CONF
775
979
 
776
- expect(Puppet::FileSystem).to receive(:read).with(myfile, :encoding => 'utf-8').and_return("[main]")
980
+ @settings[:config] = myfile
981
+ @settings.initialize_global_settings
777
982
 
778
- @settings.send(:parse_config_files)
983
+ expect(@settings[:one]).to eq('myfile')
779
984
  end
780
985
 
781
986
  it "should not try to parse non-existent files" do
@@ -783,42 +988,50 @@ describe Puppet::Settings do
783
988
 
784
989
  expect(File).not_to receive(:read).with(@file)
785
990
 
786
- @settings.send(:parse_config_files)
991
+ @settings.initialize_global_settings
787
992
  end
788
993
 
789
994
  it "should return values set in the configuration file" do
790
- text = "[main]
791
- one = fileval
792
- "
793
- expect(@settings).to receive(:read_file).and_return(text)
794
- @settings.send(:parse_config_files)
995
+ File.write(@file, <<~CONF)
996
+ [main]
997
+ one = fileval
998
+ CONF
999
+
1000
+ @settings.initialize_global_settings
795
1001
  expect(@settings[:one]).to eq("fileval")
796
1002
  end
797
1003
 
798
1004
  #484 - this should probably be in the regression area
799
1005
  it "should not throw an exception on unknown parameters" do
800
- text = "[main]\nnosuchparam = mval\n"
801
- expect(@settings).to receive(:read_file).and_return(text)
802
- expect { @settings.send(:parse_config_files) }.not_to raise_error
1006
+ File.write(@file, <<~CONF)
1007
+ [main]
1008
+ nosuchparam = mval
1009
+ CONF
1010
+
1011
+ expect { @settings.initialize_global_settings }.not_to raise_error
803
1012
  end
804
1013
 
805
1014
  it "should convert booleans in the configuration file into Ruby booleans" do
806
- text = "[main]
807
- one = true
808
- two = false
809
- "
810
- expect(@settings).to receive(:read_file).and_return(text)
811
- @settings.send(:parse_config_files)
1015
+ File.write(@file, <<~CONF)
1016
+ [main]
1017
+ one = true
1018
+ two = false
1019
+ CONF
1020
+
1021
+ @settings.initialize_global_settings
1022
+
812
1023
  expect(@settings[:one]).to eq(true)
813
1024
  expect(@settings[:two]).to eq(false)
814
1025
  end
815
1026
 
816
1027
  it "should convert integers in the configuration file into Ruby Integers" do
817
- text = "[main]
818
- one = 65
819
- "
820
- expect(@settings).to receive(:read_file).and_return(text)
821
- @settings.send(:parse_config_files)
1028
+ File.write(@file, <<~CONF)
1029
+ [main]
1030
+ one = 65
1031
+ CONF
1032
+
1033
+ @settings.initialize_global_settings
1034
+
822
1035
  expect(@settings[:one]).to eq(65)
823
1036
  end
824
1037
 
@@ -849,57 +1062,186 @@ describe Puppet::Settings do
849
1062
  end
850
1063
 
851
1064
  it "should support loading metadata (owner, group, or mode) from a run_mode section in the configuration file" do
852
- default_values = {}
853
- PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
854
- default_values[key] = 'default value'
855
- end
856
1065
  @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
857
- @settings.define_settings :master, :myfile => { :type => :file, :default => make_absolute("/myfile"), :desc => "a" }
1066
+ @settings.define_settings :server, :myfile => { :type => :file, :default => make_absolute("/myfile"), :desc => "a" }
858
1067
 
859
1068
  otherfile = make_absolute("/other/file")
860
- text = "[master]
861
- myfile = #{otherfile} {mode = 664}
862
- "
863
- expect(@settings).to receive(:read_file).and_return(text)
1069
+ File.write(@file, <<~CONF)
1070
+ [server]
1071
+ myfile = #{otherfile} {mode = 664}
1072
+ CONF
864
1073
 
865
1074
  # will start initialization as user
866
1075
  expect(@settings.preferred_run_mode).to eq(:user)
867
- @settings.send(:parse_config_files)
1076
+ @settings.initialize_global_settings
868
1077
 
869
- # change app run_mode to master
870
- @settings.initialize_app_defaults(default_values.merge(:run_mode => :master))
871
- expect(@settings.preferred_run_mode).to eq(:master)
1078
+ # change app run_mode to server
1079
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
1080
+ expect(@settings.preferred_run_mode).to eq(:server)
872
1081
 
873
1082
  # initializing the app should have reloaded the metadata based on run_mode
874
1083
  expect(@settings[:myfile]).to eq(otherfile)
875
1084
  expect(metadata(@settings.setting(:myfile))).to eq({:mode => "664"})
876
1085
  end
877
1086
 
878
- it "does not use the metadata from the same setting in a different section" do
879
- default_values = {}
880
- PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
881
- default_values[key] = 'default value'
1087
+ context "when setting serverport and masterport" do
1088
+ before(:each) do
1089
+ @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
1090
+ @settings.define_settings :server, :masterport => { :desc => "a", :default => 1000 }
1091
+ @settings.define_settings :server, :serverport => { :desc => "a", :default => 1000 }
1092
+ @settings.define_settings :server, :ca_port => { :desc => "a", :default => "$serverport" }
1093
+ @settings.define_settings :server, :report_port => { :desc => "a", :default => "$serverport" }
1094
+
1095
+ config_file = tmpfile('config')
1096
+ @settings[:config] = config_file
1097
+ File.write(config_file, text)
1098
+
1099
+ @settings.initialize_global_settings
1100
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
1101
+ expect(@settings.preferred_run_mode).to eq(:agent)
1102
+ end
1103
+
1104
+ context 'with serverport in main and masterport in agent' do
1105
+ let(:text) do
1106
+ "[main]
1107
+ serverport = 444
1108
+ [agent]
1109
+ masterport = 445
1110
+ "
1111
+ end
1112
+
1113
+ it { expect(@settings[:serverport]).to eq(445) }
1114
+ it { expect(@settings[:ca_port]).to eq("445") }
1115
+ it { expect(@settings[:report_port]).to eq("445") }
1116
+ end
1117
+
1118
+ context 'with serverport and masterport in main' do
1119
+ let(:text) do
1120
+ "[main]
1121
+ serverport = 445
1122
+ masterport = 444
1123
+ "
1124
+ end
1125
+
1126
+ it { expect(@settings[:serverport]).to eq(445) }
1127
+ it { expect(@settings[:ca_port]).to eq("445") }
1128
+ it { expect(@settings[:report_port]).to eq("445") }
1129
+ end
1130
+
1131
+ context 'with serverport and masterport in agent' do
1132
+ let(:text) do
1133
+ "[agent]
1134
+ serverport = 445
1135
+ masterport = 444
1136
+ "
1137
+ end
1138
+
1139
+ it { expect(@settings[:serverport]).to eq(445) }
1140
+ it { expect(@settings[:ca_port]).to eq("445") }
1141
+ it { expect(@settings[:report_port]).to eq("445") }
1142
+ end
1143
+
1144
+ context 'with both serverport and masterport in main and agent' do
1145
+ let(:text) do
1146
+ "[main]
1147
+ serverport = 447
1148
+ masterport = 442
1149
+ [agent]
1150
+ serverport = 445
1151
+ masterport = 444
1152
+ "
1153
+ end
1154
+
1155
+ it { expect(@settings[:serverport]).to eq(445) }
1156
+ it { expect(@settings[:ca_port]).to eq("445") }
1157
+ it { expect(@settings[:report_port]).to eq("445") }
1158
+ end
1159
+
1160
+ context 'with serverport in agent and masterport in main' do
1161
+ let(:text) do
1162
+ "[agent]
1163
+ serverport = 444
1164
+ [main]
1165
+ masterport = 445
1166
+ "
1167
+ end
1168
+
1169
+ it { expect(@settings[:serverport]).to eq(444) }
1170
+ it { expect(@settings[:ca_port]).to eq("444") }
1171
+ it { expect(@settings[:report_port]).to eq("444") }
1172
+ end
1173
+
1174
+ context 'with masterport in main' do
1175
+ let(:text) do
1176
+ "[main]
1177
+ masterport = 445
1178
+ "
1179
+ end
1180
+
1181
+ it { expect(@settings[:serverport]).to eq(445) }
1182
+ it { expect(@settings[:ca_port]).to eq("445") }
1183
+ it { expect(@settings[:report_port]).to eq("445") }
882
1184
  end
883
1185
 
1186
+ context 'with masterport in agent' do
1187
+ let(:text) do
1188
+ "[agent]
1189
+ masterport = 445
1190
+ "
1191
+ end
1192
+
1193
+ it { expect(@settings[:serverport]).to eq(445) }
1194
+ it { expect(@settings[:ca_port]).to eq("445") }
1195
+ it { expect(@settings[:report_port]).to eq("445") }
1196
+ end
1197
+
1198
+ context 'with serverport in agent' do
1199
+ let(:text) do
1200
+ "[agent]
1201
+ serverport = 445
1202
+ "
1203
+ end
1204
+
1205
+ it { expect(@settings[:serverport]).to eq(445) }
1206
+ it { expect(@settings[:masterport]).to eq(445) }
1207
+ it { expect(@settings[:ca_port]).to eq("445") }
1208
+ it { expect(@settings[:report_port]).to eq("445") }
1209
+ end
1210
+
1211
+ context 'with serverport in main' do
1212
+ let(:text) do
1213
+ "[main]
1214
+ serverport = 445
1215
+ "
1216
+ end
1217
+
1218
+ it { expect(@settings[:serverport]).to eq(445) }
1219
+ it { expect(@settings[:masterport]).to eq(445) }
1220
+ it { expect(@settings[:ca_port]).to eq("445") }
1221
+ it { expect(@settings[:report_port]).to eq("445") }
1222
+ end
1223
+ end
1224
+
1225
+ it "does not use the metadata from the same setting in a different section" do
884
1226
  file = make_absolute("/file")
885
1227
  default_mode = "0600"
886
1228
  @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
887
- @settings.define_settings :master, :myfile => { :type => :file, :default => file, :desc => "a", :mode => default_mode }
1229
+ @settings.define_settings :server, :myfile => { :type => :file, :default => file, :desc => "a", :mode => default_mode }
888
1230
 
889
- text = "[master]
890
- myfile = #{file}/foo
891
- [agent]
892
- myfile = #{file} {mode = 664}
893
- "
894
- expect(@settings).to receive(:read_file).and_return(text)
1231
+ File.write(@file, <<~CONF)
1232
+ [server]
1233
+ myfile = #{file}/foo
1234
+ [agent]
1235
+ myfile = #{file} {mode = 664}
1236
+ CONF
895
1237
 
896
1238
  # will start initialization as user
897
1239
  expect(@settings.preferred_run_mode).to eq(:user)
898
- @settings.send(:parse_config_files)
1240
+ @settings.initialize_global_settings
899
1241
 
900
- # change app run_mode to master
901
- @settings.initialize_app_defaults(default_values.merge(:run_mode => :master))
902
- expect(@settings.preferred_run_mode).to eq(:master)
1242
+ # change app run_mode to server
1243
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
1244
+ expect(@settings.preferred_run_mode).to eq(:server)
903
1245
 
904
1246
  # initializing the app should have reloaded the metadata based on run_mode
905
1247
  expect(@settings[:myfile]).to eq("#{file}/foo")
@@ -910,11 +1252,12 @@ describe Puppet::Settings do
910
1252
  values = []
911
1253
  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
912
1254
 
913
- text = "[main]
914
- mysetting = setval
915
- "
916
- expect(@settings).to receive(:read_file).and_return(text)
917
- @settings.send(:parse_config_files)
1255
+ File.write(@file, <<~CONF)
1256
+ [main]
1257
+ mysetting = setval
1258
+ CONF
1259
+ @settings.initialize_global_settings
1260
+
918
1261
  expect(values).to eq(["setval"])
919
1262
  end
920
1263
 
@@ -922,13 +1265,14 @@ describe Puppet::Settings do
922
1265
  values = []
923
1266
  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
924
1267
 
925
- text = "[user]
926
- mysetting = setval
927
- [main]
928
- mysetting = other
929
- "
930
- expect(@settings).to receive(:read_file).and_return(text)
931
- @settings.send(:parse_config_files)
1268
+ File.write(@file, <<~CONF)
1269
+ [user]
1270
+ mysetting = setval
1271
+ [main]
1272
+ mysetting = other
1273
+ CONF
1274
+ @settings.initialize_global_settings
1275
+
932
1276
  expect(values).to eq(["setval"])
933
1277
  end
934
1278
 
@@ -937,11 +1281,12 @@ describe Puppet::Settings do
937
1281
  @settings.define_settings :section, :base => {:default => "yay", :desc => "a", :hook => proc { |v| values << v }}
938
1282
  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
939
1283
 
940
- text = "[main]
941
- mysetting = $base/setval
942
- "
943
- expect(@settings).to receive(:read_file).and_return(text)
944
- @settings.send(:parse_config_files)
1284
+ File.write(@file, <<~CONF)
1285
+ [main]
1286
+ mysetting = $base/setval
1287
+ CONF
1288
+ @settings.initialize_global_settings
1289
+
945
1290
  expect(values).to eq(["yay/setval"])
946
1291
  end
947
1292
 
@@ -951,23 +1296,25 @@ describe Puppet::Settings do
951
1296
  :hook => proc { |v| hook_invoked = true },
952
1297
  :call_hook => :on_initialize_and_write, }
953
1298
 
1299
+ # This test relies on `confdir` defaulting to nil which causes the default
1300
+ # value of `deferred=$confdir/goose` to raise an interpolation error during
1301
+ # global initialization, and the hook to be skipped
954
1302
  @settings.define_settings(:main,
955
- :logdir => { :type => :directory, :default => nil, :desc => "logdir" },
956
- :confdir => { :type => :directory, :default => nil, :desc => "confdir" },
957
- :codedir => { :type => :directory, :default => nil, :desc => "codedir" },
958
- :vardir => { :type => :directory, :default => nil, :desc => "vardir" })
1303
+ PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.merge(
1304
+ :confdir => { :type => :directory, :default => nil, :desc => "confdir" }))
959
1305
 
960
- text = <<-EOD
961
- [main]
962
- deferred=$confdir/goose
1306
+ File.write(@file, <<~EOD)
1307
+ [main]
1308
+ deferred=$confdir/goose
963
1309
  EOD
964
1310
 
965
- allow(@settings).to receive(:read_file).and_return(text)
966
1311
  @settings.initialize_global_settings
967
1312
 
968
1313
  expect(hook_invoked).to be_falsey
969
1314
 
970
- @settings.initialize_app_defaults(:logdir => '/path/to/logdir', :confdir => '/path/to/confdir', :vardir => '/path/to/vardir', :codedir => '/path/to/codedir')
1315
+ # And now that we initialize app defaults with `confdir`, then `deferred`
1316
+ # can be interpolated and its hook called
1317
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
971
1318
 
972
1319
  expect(hook_invoked).to be_truthy
973
1320
  expect(@settings[:deferred]).to eq(File.expand_path('/path/to/confdir/goose'))
@@ -976,45 +1323,33 @@ describe Puppet::Settings do
976
1323
  it "does not require the value for a setting without a hook to resolve during global setup" do
977
1324
  @settings.define_settings :section, :can_cause_problems => {:desc => '' }
978
1325
 
979
- @settings.define_settings(:main,
980
- :logdir => { :type => :directory, :default => nil, :desc => "logdir" },
981
- :confdir => { :type => :directory, :default => nil, :desc => "confdir" },
982
- :codedir => { :type => :directory, :default => nil, :desc => "codedir" },
983
- :vardir => { :type => :directory, :default => nil, :desc => "vardir" })
1326
+ @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
984
1327
 
985
- text = <<-EOD
1328
+ File.write(@file, <<~EOD)
986
1329
  [main]
987
1330
  can_cause_problems=$confdir/goose
988
1331
  EOD
989
1332
 
990
- allow(@settings).to receive(:read_file).and_return(text)
991
1333
  @settings.initialize_global_settings
992
- @settings.initialize_app_defaults(:logdir => '/path/to/logdir', :confdir => '/path/to/confdir', :vardir => '/path/to/vardir', :codedir => '/path/to/codedir')
1334
+ @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
993
1335
 
994
- expect(@settings[:can_cause_problems]).to eq(File.expand_path('/path/to/confdir/goose'))
1336
+ expect(@settings[:can_cause_problems]).to eq('/path/to/confdir/goose')
995
1337
  end
996
1338
 
997
1339
  it "should allow empty values" do
998
1340
  @settings.define_settings :section, :myarg => { :default => "myfile", :desc => "a" }
999
1341
 
1000
- text = "[main]
1001
- myarg =
1002
- "
1003
- allow(@settings).to receive(:read_file).and_return(text)
1004
- @settings.send(:parse_config_files)
1342
+ File.write(@file, <<~CONF)
1343
+ [main]
1344
+ myarg =
1345
+ CONF
1346
+ @settings.initialize_global_settings
1347
+
1005
1348
  expect(@settings[:myarg]).to eq("")
1006
1349
  end
1007
1350
 
1008
1351
  describe "deprecations" do
1009
1352
  let(:settings) { Puppet::Settings.new }
1010
- let(:app_defaults) {
1011
- {
1012
- :logdir => "/dev/null",
1013
- :confdir => "/dev/null",
1014
- :codedir => "/dev/null",
1015
- :vardir => "/dev/null",
1016
- }
1017
- }
1018
1353
 
1019
1354
  def assert_accessing_setting_is_deprecated(settings, setting)
1020
1355
  expect(Puppet).to receive(:deprecation_warning).with("Accessing '#{setting}' as a setting is deprecated.")
@@ -1024,12 +1359,7 @@ describe Puppet::Settings do
1024
1359
  end
1025
1360
 
1026
1361
  before(:each) do
1027
- settings.define_settings(:main, {
1028
- :logdir => { :default => 'a', :desc => 'a' },
1029
- :confdir => { :default => 'b', :desc => 'b' },
1030
- :vardir => { :default => 'c', :desc => 'c' },
1031
- :codedir => { :default => 'd', :desc => 'd' },
1032
- })
1362
+ settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
1033
1363
  end
1034
1364
 
1035
1365
  context "complete" do
@@ -1050,7 +1380,7 @@ describe Puppet::Settings do
1050
1380
  completely_deprecated_settings.parse_config(<<-CONF)
1051
1381
  completely_deprecated_setting='should warn'
1052
1382
  CONF
1053
- completely_deprecated_settings.initialize_app_defaults(app_defaults)
1383
+ completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
1054
1384
  end
1055
1385
 
1056
1386
  it "warns when set on the commandline" do
@@ -1058,7 +1388,7 @@ describe Puppet::Settings do
1058
1388
 
1059
1389
  args = ["--completely_deprecated_setting", "/some/value"]
1060
1390
  completely_deprecated_settings.send(:parse_global_options, args)
1061
- completely_deprecated_settings.initialize_app_defaults(app_defaults)
1391
+ completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
1062
1392
  end
1063
1393
 
1064
1394
  it "warns when set in code" do
@@ -1083,7 +1413,7 @@ describe Puppet::Settings do
1083
1413
  partially_deprecated_settings.parse_config(<<-CONF)
1084
1414
  partially_deprecated_setting='should warn'
1085
1415
  CONF
1086
- partially_deprecated_settings.initialize_app_defaults(app_defaults)
1416
+ partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
1087
1417
  end
1088
1418
 
1089
1419
  it "does not warn when manifest is set on command line" do
@@ -1091,7 +1421,7 @@ describe Puppet::Settings do
1091
1421
 
1092
1422
  args = ["--partially_deprecated_setting", "/some/value"]
1093
1423
  partially_deprecated_settings.send(:parse_global_options, args)
1094
- partially_deprecated_settings.initialize_app_defaults(app_defaults)
1424
+ partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
1095
1425
  end
1096
1426
 
1097
1427
  it "warns when set in code" do
@@ -1184,23 +1514,24 @@ describe Puppet::Settings do
1184
1514
 
1185
1515
  describe "when reparsing its configuration" do
1186
1516
  before do
1187
- @file = make_absolute("/test/file")
1188
- @userconfig = make_absolute("/test/userconfigfile")
1517
+ @file = tmpfile("testfile")
1518
+ Puppet::FileSystem.touch(@file)
1519
+
1189
1520
  @settings = Puppet::Settings.new
1190
1521
  @settings.define_settings :section,
1191
1522
  :config => { :type => :file, :default => @file, :desc => "a" },
1192
1523
  :one => { :default => "ONE", :desc => "a" },
1193
1524
  :two => { :default => "$one TWO", :desc => "b" },
1194
1525
  :three => { :default => "$one $two THREE", :desc => "c" }
1195
- allow(Puppet::FileSystem).to receive(:exist?).with(@file).and_return(true)
1196
- allow(Puppet::FileSystem).to receive(:exist?).with(@userconfig).and_return(false)
1197
- allow(@settings).to receive(:user_config_file).and_return(@userconfig)
1526
+
1527
+ userconfig = tmpfile("userconfig")
1528
+ allow(@settings).to receive(:user_config_file).and_return(userconfig)
1198
1529
  end
1199
1530
 
1200
1531
  it "does not create the WatchedFile instance and should not parse if the file does not exist" do
1201
- expect(Puppet::FileSystem).to receive(:exist?).with(@file).and_return(false)
1202
- expect(Puppet::Util::WatchedFile).not_to receive(:new)
1532
+ Puppet::FileSystem.unlink(@file)
1203
1533
 
1534
+ expect(Puppet::Util::WatchedFile).not_to receive(:new)
1204
1535
  expect(@settings).not_to receive(:parse_config_files)
1205
1536
 
1206
1537
  @settings.reparse_config_files
@@ -1239,8 +1570,8 @@ describe Puppet::Settings do
1239
1570
  @settings[:one] = "init"
1240
1571
 
1241
1572
  # Now replace the value
1242
- text = "[main]\none = disk-replace\n"
1243
- allow(@settings).to receive(:read_file).and_return(text)
1573
+ File.write(@file, "[main]\none = disk-replace\n")
1574
+
1244
1575
  @settings.reparse_config_files
1245
1576
  expect(@settings[:one]).to eq("disk-replace")
1246
1577
  end
@@ -1249,23 +1580,20 @@ describe Puppet::Settings do
1249
1580
  it "should retain parameters set by cli when configuration files are reparsed" do
1250
1581
  @settings.handlearg("--one", "clival")
1251
1582
 
1252
- text = "[main]\none = on-disk\n"
1253
- allow(@settings).to receive(:read_file).and_return(text)
1254
- @settings.send(:parse_config_files)
1583
+ File.write(@file, "[main]\none = on-disk\n")
1584
+ @settings.initialize_global_settings
1255
1585
 
1256
1586
  expect(@settings[:one]).to eq("clival")
1257
1587
  end
1258
1588
 
1259
1589
  it "should remove in-memory values that are no longer set in the file" do
1260
1590
  # Init the value
1261
- text = "[main]\none = disk-init\n"
1262
- expect(@settings).to receive(:read_file).and_return(text)
1591
+ File.write(@file, "[main]\none = disk-init\n")
1263
1592
  @settings.send(:parse_config_files)
1264
1593
  expect(@settings[:one]).to eq("disk-init")
1265
1594
 
1266
1595
  # Now replace the value
1267
- text = "[main]\ntwo = disk-replace\n"
1268
- expect(@settings).to receive(:read_file).and_return(text)
1596
+ File.write(@file, "[main]\ntwo = disk-replace\n")
1269
1597
  @settings.send(:parse_config_files)
1270
1598
 
1271
1599
  # The originally-overridden value should be replaced with the default
@@ -1277,14 +1605,12 @@ describe Puppet::Settings do
1277
1605
 
1278
1606
  it "should retain in-memory values if the file has a syntax error" do
1279
1607
  # Init the value
1280
- text = "[main]\none = initial-value\n"
1281
- expect(@settings).to receive(:read_file).with(@file).and_return(text)
1282
- @settings.send(:parse_config_files)
1608
+ File.write(@file, "[main]\none = initial-value\n")
1609
+ @settings.initialize_global_settings
1283
1610
  expect(@settings[:one]).to eq("initial-value")
1284
1611
 
1285
1612
  # Now replace the value with something bogus
1286
- text = "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n"
1287
- expect(@settings).to receive(:read_file).with(@file).and_return(text)
1613
+ File.write(@file, "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n")
1288
1614
  @settings.send(:parse_config_files)
1289
1615
 
1290
1616
  # The originally-overridden value should not be replaced with the default
@@ -1296,46 +1622,49 @@ describe Puppet::Settings do
1296
1622
  end
1297
1623
 
1298
1624
  it "should provide a method for creating a catalog of resources from its configuration" do
1299
- expect(Puppet::Settings.new).to respond_to(:to_catalog)
1625
+ expect(Puppet::Settings.new.to_catalog).to be_an_instance_of(Puppet::Resource::Catalog)
1300
1626
  end
1301
1627
 
1302
1628
  describe "when creating a catalog" do
1629
+ let(:maindir) { make_absolute('/maindir') }
1630
+ let(:seconddir) { make_absolute('/seconddir') }
1631
+ let(:otherdir) { make_absolute('/otherdir') }
1632
+
1303
1633
  before do
1304
1634
  @settings = Puppet::Settings.new
1305
1635
  allow(@settings).to receive(:service_user_available?).and_return(true)
1306
- @prefix = Puppet.features.posix? ? "" : "C:"
1307
1636
  end
1308
1637
 
1309
1638
  it "should add all file resources to the catalog if no sections have been specified" do
1310
1639
  @settings.define_settings :main,
1311
- :maindir => { :type => :directory, :default => @prefix+"/maindir", :desc => "a"},
1312
- :seconddir => { :type => :directory, :default => @prefix+"/seconddir", :desc => "a"}
1640
+ :maindir => { :type => :directory, :default => maindir, :desc => "a"},
1641
+ :seconddir => { :type => :directory, :default => seconddir, :desc => "a"}
1313
1642
  @settings.define_settings :other,
1314
- :otherdir => { :type => :directory, :default => @prefix+"/otherdir", :desc => "a" }
1643
+ :otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
1315
1644
 
1316
1645
  catalog = @settings.to_catalog
1317
1646
 
1318
- [@prefix+"/maindir", @prefix+"/seconddir", @prefix+"/otherdir"].each do |path|
1647
+ [maindir, seconddir, otherdir].each do |path|
1319
1648
  expect(catalog.resource(:file, path)).to be_instance_of(Puppet::Resource)
1320
1649
  end
1321
1650
  end
1322
1651
 
1323
1652
  it "should add only files in the specified sections if section names are provided" do
1324
- @settings.define_settings :main, :maindir => { :type => :directory, :default => @prefix+"/maindir", :desc => "a" }
1325
- @settings.define_settings :other, :otherdir => { :type => :directory, :default => @prefix+"/otherdir", :desc => "a" }
1653
+ @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
1654
+ @settings.define_settings :other, :otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
1326
1655
  catalog = @settings.to_catalog(:main)
1327
- expect(catalog.resource(:file, @prefix+"/otherdir")).to be_nil
1328
- expect(catalog.resource(:file, @prefix+"/maindir")).to be_instance_of(Puppet::Resource)
1656
+ expect(catalog.resource(:file, otherdir)).to be_nil
1657
+ expect(catalog.resource(:file, maindir)).to be_instance_of(Puppet::Resource)
1329
1658
  end
1330
1659
 
1331
1660
  it "should not try to add the same file twice" do
1332
- @settings.define_settings :main, :maindir => { :type => :directory, :default => @prefix+"/maindir", :desc => "a" }
1333
- @settings.define_settings :other, :otherdir => { :type => :directory, :default => @prefix+"/maindir", :desc => "a" }
1661
+ @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
1662
+ @settings.define_settings :other, :otherdir => { :type => :directory, :default => maindir, :desc => "a" }
1334
1663
  expect { @settings.to_catalog }.not_to raise_error
1335
1664
  end
1336
1665
 
1337
1666
  it "should ignore files whose :to_resource method returns nil" do
1338
- @settings.define_settings :main, :maindir => { :type => :directory, :default => @prefix+"/maindir", :desc => "a" }
1667
+ @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
1339
1668
  expect(@settings.setting(:maindir)).to receive(:to_resource).and_return(nil)
1340
1669
 
1341
1670
  expect_any_instance_of(Puppet::Resource::Catalog).not_to receive(:add_resource)
@@ -1365,6 +1694,7 @@ describe Puppet::Settings do
1365
1694
  describe "adding default directory environment to the catalog" do
1366
1695
  let(:tmpenv) { tmpdir("envs") }
1367
1696
  let(:default_path) { "#{tmpenv}/environments" }
1697
+
1368
1698
  before(:each) do
1369
1699
  @settings.define_settings :main,
1370
1700
  :environment => { :default => "production", :desc => "env"},
@@ -1654,6 +1984,23 @@ describe Puppet::Settings do
1654
1984
  end
1655
1985
  end
1656
1986
 
1987
+ describe 'when settings_catalog is disabled' do
1988
+ let(:settings) { Puppet::Settings.new }
1989
+ before do
1990
+ allow(Puppet).to receive(:[]).with(:settings_catalog).and_return(false)
1991
+ end
1992
+
1993
+ it 'does not compile and apply settings catalog' do
1994
+ expect(settings).not_to receive(:to_catalog)
1995
+ settings.use(:main)
1996
+ end
1997
+
1998
+ it 'logs a message that settings catalog is skipped' do
1999
+ expect(Puppet).to receive(:debug).with('Skipping settings catalog for sections main')
2000
+ settings.use(:main)
2001
+ end
2002
+ end
2003
+
1657
2004
  describe "when dealing with printing configs" do
1658
2005
  before do
1659
2006
  @settings = Puppet::Settings.new
@@ -1900,18 +2247,18 @@ describe Puppet::Settings do
1900
2247
  end
1901
2248
 
1902
2249
  it "should set preferred run mode from --run_mode <foo> string without error" do
1903
- args = ["--run_mode", "master"]
1904
- expect(settings).not_to receive(:handlearg).with("--run_mode", "master")
2250
+ args = ["--run_mode", "server"]
2251
+ expect(settings).not_to receive(:handlearg).with("--run_mode", "server")
1905
2252
  expect { settings.send(:parse_global_options, args) } .to_not raise_error
1906
- expect(Puppet.settings.preferred_run_mode).to eq(:master)
2253
+ expect(Puppet.settings.preferred_run_mode).to eq(:server)
1907
2254
  expect(args.empty?).to eq(true)
1908
2255
  end
1909
2256
 
1910
2257
  it "should set preferred run mode from --run_mode=<foo> string without error" do
1911
- args = ["--run_mode=master"]
1912
- expect(settings).not_to receive(:handlearg).with("--run_mode", "master")
2258
+ args = ["--run_mode=server"]
2259
+ expect(settings).not_to receive(:handlearg).with("--run_mode", "server")
1913
2260
  expect { settings.send(:parse_global_options, args) }.to_not raise_error
1914
- expect(Puppet.settings.preferred_run_mode).to eq(:master)
2261
+ expect(Puppet.settings.preferred_run_mode).to eq(:server)
1915
2262
  expect(args.empty?).to eq(true)
1916
2263
  end
1917
2264
  end