puppet 6.4.5-universal-darwin → 6.5.0-universal-darwin

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 (329) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +10 -10
  3. data/Gemfile +6 -6
  4. data/Gemfile.lock +46 -52
  5. data/ext/build_defaults.yaml +0 -1
  6. data/ext/project_data.yaml +3 -3
  7. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  8. data/ext/solaris/smf/puppet.xml +0 -2
  9. data/ext/windows/eventlog/Rakefile +32 -0
  10. data/ext/windows/eventlog/puppetres.dll +0 -0
  11. data/ext/windows/eventlog/puppetres.mc +18 -0
  12. data/ext/windows/service/daemon.rb +8 -38
  13. data/install.rb +24 -6
  14. data/lib/puppet.rb +3 -1
  15. data/lib/puppet/application.rb +1 -1
  16. data/lib/puppet/application/agent.rb +11 -34
  17. data/lib/puppet/application/apply.rb +6 -6
  18. data/lib/puppet/application/describe.rb +9 -3
  19. data/lib/puppet/application/device.rb +4 -14
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/application/lookup.rb +2 -2
  22. data/lib/puppet/application/resource.rb +4 -4
  23. data/lib/puppet/application/script.rb +2 -2
  24. data/lib/puppet/application/ssl.rb +10 -9
  25. data/lib/puppet/configurer.rb +30 -86
  26. data/lib/puppet/configurer/downloader.rb +6 -2
  27. data/lib/puppet/defaults.rb +50 -44
  28. data/lib/puppet/error.rb +14 -9
  29. data/lib/puppet/face/catalog.rb +20 -1
  30. data/lib/puppet/face/config.rb +48 -10
  31. data/lib/puppet/face/facts.rb +1 -1
  32. data/lib/puppet/face/help.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +5 -5
  34. data/lib/puppet/face/module/search.rb +1 -1
  35. data/lib/puppet/face/module/uninstall.rb +1 -1
  36. data/lib/puppet/face/module/upgrade.rb +1 -1
  37. data/lib/puppet/face/parser.rb +48 -9
  38. data/lib/puppet/face/plugin.rb +2 -9
  39. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  40. data/lib/puppet/file_system.rb +12 -2
  41. data/lib/puppet/file_system/file_impl.rb +6 -3
  42. data/lib/puppet/file_system/memory_file.rb +1 -1
  43. data/lib/puppet/file_system/posix.rb +2 -3
  44. data/lib/puppet/forge.rb +3 -3
  45. data/lib/puppet/functions.rb +2 -1
  46. data/lib/puppet/functions/camelcase.rb +2 -2
  47. data/lib/puppet/functions/epp.rb +4 -4
  48. data/lib/puppet/functions/find_file.rb +9 -9
  49. data/lib/puppet/functions/inline_epp.rb +5 -5
  50. data/lib/puppet/functions/regsubst.rb +6 -8
  51. data/lib/puppet/gettext/module_translations.rb +1 -1
  52. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  53. data/lib/puppet/graph/simple_graph.rb +3 -4
  54. data/lib/puppet/indirector/catalog/compiler.rb +5 -11
  55. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  56. data/lib/puppet/indirector/hiera.rb +0 -2
  57. data/lib/puppet/indirector/resource/ral.rb +3 -1
  58. data/lib/puppet/indirector/resource/validator.rb +1 -1
  59. data/lib/puppet/interface.rb +1 -2
  60. data/lib/puppet/loaders.rb +1 -0
  61. data/lib/puppet/metatype/manager.rb +1 -1
  62. data/lib/puppet/module.rb +1 -1
  63. data/lib/puppet/module/task.rb +4 -20
  64. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  65. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  66. data/lib/puppet/module_tool/metadata.rb +1 -1
  67. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  68. data/lib/puppet/module_tool/tar/mini.rb +2 -12
  69. data/lib/puppet/network/http/api/indirected_routes.rb +11 -12
  70. data/lib/puppet/network/http/connection.rb +12 -10
  71. data/lib/puppet/network/http/factory.rb +11 -1
  72. data/lib/puppet/network/http/pool.rb +0 -2
  73. data/lib/puppet/network/http/site.rb +1 -1
  74. data/lib/puppet/network/resolver.rb +2 -2
  75. data/lib/puppet/node/environment.rb +2 -4
  76. data/lib/puppet/pal/pal_impl.rb +2 -2
  77. data/lib/puppet/parser/ast.rb +1 -1
  78. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  79. data/lib/puppet/parser/functions.rb +1 -1
  80. data/lib/puppet/parser/functions/epp.rb +3 -3
  81. data/lib/puppet/parser/functions/fail.rb +8 -1
  82. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  83. data/lib/puppet/parser/scope.rb +7 -8
  84. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  85. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  86. data/lib/puppet/pops/evaluator/external_syntax_support.rb +2 -3
  87. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  88. data/lib/puppet/pops/loader/null_loader.rb +60 -0
  89. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -4
  90. data/lib/puppet/pops/loader/task_instantiator.rb +0 -4
  91. data/lib/puppet/pops/loaders.rb +1 -1
  92. data/lib/puppet/pops/lookup/hiera_config.rb +0 -1
  93. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  94. data/lib/puppet/pops/merge_strategy.rb +18 -22
  95. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  96. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  97. data/lib/puppet/pops/parser/locator.rb +1 -1
  98. data/lib/puppet/pops/parser/pn_parser.rb +16 -17
  99. data/lib/puppet/pops/puppet_stack.rb +49 -51
  100. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  101. data/lib/puppet/pops/types/string_converter.rb +10 -10
  102. data/lib/puppet/pops/types/types.rb +6 -5
  103. data/lib/puppet/property.rb +1 -1
  104. data/lib/puppet/property/ensure.rb +1 -1
  105. data/lib/puppet/provider/exec.rb +2 -6
  106. data/lib/puppet/provider/file/posix.rb +0 -5
  107. data/lib/puppet/provider/nameservice.rb +3 -10
  108. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  109. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  110. data/lib/puppet/provider/package.rb +0 -2
  111. data/lib/puppet/provider/package/apt.rb +1 -5
  112. data/lib/puppet/provider/package/dnf.rb +1 -1
  113. data/lib/puppet/provider/package/dpkg.rb +18 -34
  114. data/lib/puppet/provider/package/openbsd.rb +1 -1
  115. data/lib/puppet/provider/package/pip.rb +13 -37
  116. data/lib/puppet/provider/package/portage.rb +4 -4
  117. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  118. data/lib/puppet/provider/package/rpm.rb +18 -56
  119. data/lib/puppet/provider/package/windows/package.rb +1 -1
  120. data/lib/puppet/provider/package/yum.rb +5 -9
  121. data/lib/puppet/provider/package_targetable.rb +4 -7
  122. data/lib/puppet/provider/parsedfile.rb +1 -1
  123. data/lib/puppet/provider/service/daemontools.rb +9 -9
  124. data/lib/puppet/provider/service/launchd.rb +5 -20
  125. data/lib/puppet/provider/service/openbsd.rb +1 -1
  126. data/lib/puppet/provider/service/rcng.rb +2 -2
  127. data/lib/puppet/provider/service/runit.rb +8 -2
  128. data/lib/puppet/provider/service/systemd.rb +19 -14
  129. data/lib/puppet/provider/service/windows.rb +0 -8
  130. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  131. data/lib/puppet/provider/user/hpux.rb +1 -1
  132. data/lib/puppet/provider/user/pw.rb +3 -12
  133. data/lib/puppet/provider/user/user_role_add.rb +1 -5
  134. data/lib/puppet/provider/user/useradd.rb +20 -45
  135. data/lib/puppet/provider/user/windows_adsi.rb +5 -4
  136. data/lib/puppet/reference/configuration.rb +3 -3
  137. data/lib/puppet/reference/indirection.rb +2 -2
  138. data/lib/puppet/reference/metaparameter.rb +3 -1
  139. data/lib/puppet/reference/providers.rb +3 -1
  140. data/lib/puppet/reference/type.rb +9 -3
  141. data/lib/puppet/reports.rb +1 -1
  142. data/lib/puppet/resource.rb +1 -18
  143. data/lib/puppet/resource/catalog.rb +1 -1
  144. data/lib/puppet/rest/routes.rb +30 -17
  145. data/lib/puppet/settings.rb +3 -43
  146. data/lib/puppet/settings/environment_conf.rb +0 -1
  147. data/lib/puppet/ssl/certificate_request.rb +12 -2
  148. data/lib/puppet/ssl/host.rb +2 -2
  149. data/lib/puppet/ssl/oids.rb +1 -1
  150. data/lib/puppet/ssl/ssl_provider.rb +11 -5
  151. data/lib/puppet/ssl/state_machine.rb +102 -98
  152. data/lib/puppet/test/test_helper.rb +1 -0
  153. data/lib/puppet/transaction.rb +11 -33
  154. data/lib/puppet/transaction/report.rb +1 -1
  155. data/lib/puppet/type.rb +4 -2
  156. data/lib/puppet/type/exec.rb +17 -23
  157. data/lib/puppet/type/file.rb +39 -11
  158. data/lib/puppet/type/file/data_sync.rb +1 -5
  159. data/lib/puppet/type/group.rb +2 -4
  160. data/lib/puppet/type/notify.rb +3 -4
  161. data/lib/puppet/type/package.rb +3 -20
  162. data/lib/puppet/type/schedule.rb +1 -1
  163. data/lib/puppet/type/service.rb +3 -8
  164. data/lib/puppet/type/user.rb +2 -4
  165. data/lib/puppet/util.rb +29 -39
  166. data/lib/puppet/util/command_line/trollop.rb +1 -1
  167. data/lib/puppet/util/execution.rb +3 -4
  168. data/lib/puppet/util/http_proxy.rb +19 -27
  169. data/lib/puppet/util/log.rb +2 -2
  170. data/lib/puppet/util/log/destinations.rb +2 -2
  171. data/lib/puppet/util/logging.rb +20 -32
  172. data/lib/puppet/util/metric.rb +2 -2
  173. data/lib/puppet/util/monkey_patches.rb +33 -0
  174. data/lib/puppet/util/pidlock.rb +2 -3
  175. data/lib/puppet/util/provider_features.rb +4 -2
  176. data/lib/puppet/util/rdoc.rb +1 -1
  177. data/lib/puppet/util/reference.rb +1 -1
  178. data/lib/puppet/util/resource_template.rb +1 -1
  179. data/lib/puppet/util/selinux.rb +2 -8
  180. data/lib/puppet/util/skip_tags.rb +4 -0
  181. data/lib/puppet/util/windows/adsi.rb +18 -48
  182. data/lib/puppet/util/windows/process.rb +8 -8
  183. data/lib/puppet/util/windows/registry.rb +5 -7
  184. data/lib/puppet/util/windows/security.rb +0 -2
  185. data/lib/puppet/util/windows/service.rb +4 -149
  186. data/lib/puppet/util/windows/sid.rb +0 -1
  187. data/lib/puppet/vendor.rb +1 -1
  188. data/lib/puppet/version.rb +1 -1
  189. data/lib/puppet/x509/cert_provider.rb +81 -24
  190. data/locales/puppet.pot +462 -482
  191. data/man/man5/puppet.conf.5 +43 -44
  192. data/man/man8/puppet-agent.8 +1 -1
  193. data/man/man8/puppet-apply.8 +3 -3
  194. data/man/man8/puppet-catalog.8 +31 -3
  195. data/man/man8/puppet-config.8 +1 -1
  196. data/man/man8/puppet-describe.8 +1 -1
  197. data/man/man8/puppet-device.8 +1 -1
  198. data/man/man8/puppet-doc.8 +1 -1
  199. data/man/man8/puppet-epp.8 +1 -1
  200. data/man/man8/puppet-facts.8 +1 -1
  201. data/man/man8/puppet-filebucket.8 +1 -1
  202. data/man/man8/puppet-generate.8 +1 -1
  203. data/man/man8/puppet-help.8 +1 -1
  204. data/man/man8/puppet-key.8 +1 -1
  205. data/man/man8/puppet-lookup.8 +1 -1
  206. data/man/man8/puppet-man.8 +1 -1
  207. data/man/man8/puppet-module.8 +1 -1
  208. data/man/man8/puppet-node.8 +1 -1
  209. data/man/man8/puppet-parser.8 +1 -1
  210. data/man/man8/puppet-plugin.8 +1 -1
  211. data/man/man8/puppet-report.8 +1 -1
  212. data/man/man8/puppet-resource.8 +1 -1
  213. data/man/man8/puppet-script.8 +1 -1
  214. data/man/man8/puppet-ssl.8 +1 -1
  215. data/man/man8/puppet-status.8 +1 -1
  216. data/man/man8/puppet.8 +3 -3
  217. data/spec/fixtures/ssl/127.0.0.1-key.pem +56 -56
  218. data/spec/fixtures/ssl/127.0.0.1.pem +27 -27
  219. data/spec/fixtures/ssl/bad-basic-constraints.pem +32 -32
  220. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +30 -30
  221. data/spec/fixtures/ssl/ca.pem +30 -30
  222. data/spec/fixtures/ssl/crl.pem +15 -15
  223. data/spec/fixtures/ssl/ec-key.pem +18 -0
  224. data/spec/fixtures/ssl/ec.pem +40 -0
  225. data/spec/fixtures/ssl/encrypted-ec-key.pem +21 -0
  226. data/spec/fixtures/ssl/encrypted-key.pem +57 -57
  227. data/spec/fixtures/ssl/intermediate-agent-crl.pem +16 -16
  228. data/spec/fixtures/ssl/intermediate-agent.pem +33 -33
  229. data/spec/fixtures/ssl/intermediate-crl.pem +17 -17
  230. data/spec/fixtures/ssl/intermediate.pem +31 -31
  231. data/spec/fixtures/ssl/pluto-key.pem +56 -56
  232. data/spec/fixtures/ssl/pluto.pem +28 -28
  233. data/spec/fixtures/ssl/request-key.pem +56 -56
  234. data/spec/fixtures/ssl/request.pem +24 -24
  235. data/spec/fixtures/ssl/revoked-key.pem +56 -56
  236. data/spec/fixtures/ssl/revoked.pem +25 -25
  237. data/spec/fixtures/ssl/signed-key.pem +56 -56
  238. data/spec/fixtures/ssl/signed.pem +25 -25
  239. data/spec/fixtures/ssl/tampered-cert.pem +27 -27
  240. data/spec/fixtures/ssl/tampered-csr.pem +24 -24
  241. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/func_with_syntax_error.rb +9 -0
  242. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  243. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  244. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  245. data/spec/integration/configurer_spec.rb +0 -52
  246. data/spec/integration/provider/service/init_spec.rb +1 -0
  247. data/spec/integration/provider/service/systemd_spec.rb +5 -8
  248. data/spec/integration/type/file_spec.rb +38 -28
  249. data/spec/integration/util/execution_spec.rb +0 -27
  250. data/spec/lib/puppet/certificate_factory.rb +2 -2
  251. data/spec/lib/puppet/test_ca.rb +17 -4
  252. data/spec/lib/puppet_spec/fixtures.rb +4 -0
  253. data/spec/spec_helper.rb +0 -28
  254. data/spec/unit/application/agent_spec.rb +34 -67
  255. data/spec/unit/application/device_spec.rb +1 -27
  256. data/spec/unit/application/ssl_spec.rb +60 -35
  257. data/spec/unit/configurer_spec.rb +399 -395
  258. data/spec/unit/defaults_spec.rb +4 -4
  259. data/spec/unit/face/facts_spec.rb +0 -9
  260. data/spec/unit/face/parser_spec.rb +69 -22
  261. data/spec/unit/face/plugin_spec.rb +0 -8
  262. data/spec/unit/file_system_spec.rb +30 -1
  263. data/spec/unit/forge/forge_spec.rb +3 -1
  264. data/spec/unit/forge/repository_spec.rb +3 -1
  265. data/spec/unit/indirector/catalog/compiler_spec.rb +5 -62
  266. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  267. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  268. data/spec/unit/network/http/api/indirected_routes_spec.rb +10 -25
  269. data/spec/unit/network/http/connection_spec.rb +145 -119
  270. data/spec/unit/network/http/factory_spec.rb +5 -27
  271. data/spec/unit/parser/scope_spec.rb +0 -10
  272. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +3 -8
  273. data/spec/unit/pops/loaders/loaders_spec.rb +4 -0
  274. data/spec/unit/pops/loaders/module_loaders_spec.rb +0 -37
  275. data/spec/unit/pops/types/types_spec.rb +27 -0
  276. data/spec/unit/provider/exec_spec.rb +0 -209
  277. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  278. data/spec/unit/provider/package/dnf_spec.rb +0 -7
  279. data/spec/unit/provider/package/dpkg_spec.rb +80 -240
  280. data/spec/unit/provider/package/pip_spec.rb +8 -61
  281. data/spec/unit/provider/package/portage_spec.rb +4 -4
  282. data/spec/unit/provider/package/rpm_spec.rb +16 -150
  283. data/spec/unit/provider/package/yum_spec.rb +0 -7
  284. data/spec/unit/provider/service/daemontools_spec.rb +0 -24
  285. data/spec/unit/provider/service/launchd_spec.rb +0 -28
  286. data/spec/unit/provider/service/runit_spec.rb +0 -24
  287. data/spec/unit/provider/service/systemd_spec.rb +25 -39
  288. data/spec/unit/provider/service/windows_spec.rb +0 -20
  289. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  290. data/spec/unit/provider/user/pw_spec.rb +0 -37
  291. data/spec/unit/provider/user/useradd_spec.rb +0 -88
  292. data/spec/unit/resource_spec.rb +1 -26
  293. data/spec/unit/ssl/host_spec.rb +5 -0
  294. data/spec/unit/ssl/ssl_provider_spec.rb +36 -11
  295. data/spec/unit/ssl/state_machine_spec.rb +233 -158
  296. data/spec/unit/transaction_spec.rb +0 -64
  297. data/spec/unit/type/exec_spec.rb +12 -15
  298. data/spec/unit/type/file/content_spec.rb +3 -9
  299. data/spec/unit/type/file/source_spec.rb +4 -4
  300. data/spec/unit/type/file_spec.rb +15 -11
  301. data/spec/unit/type/package_spec.rb +0 -5
  302. data/spec/unit/type/schedule_spec.rb +1 -3
  303. data/spec/unit/type/service_spec.rb +0 -16
  304. data/spec/unit/util/execution_spec.rb +0 -16
  305. data/spec/unit/util/http_proxy_spec.rb +21 -151
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -15
  307. data/spec/unit/util/log/destinations_spec.rb +3 -7
  308. data/spec/unit/util/log_spec.rb +138 -0
  309. data/spec/unit/util/logging_spec.rb +0 -200
  310. data/spec/unit/util/pidlock_spec.rb +0 -26
  311. data/spec/unit/util/skip_tags_spec.rb +14 -0
  312. data/spec/unit/util/windows/adsi_spec.rb +0 -51
  313. data/spec/unit/util/windows/service_spec.rb +0 -9
  314. data/spec/unit/util_spec.rb +10 -0
  315. data/spec/unit/x509/cert_provider_spec.rb +82 -43
  316. data/tasks/generate_cert_fixtures.rake +13 -1
  317. data/tasks/manpages.rake +0 -1
  318. metadata +26 -20
  319. data/ext/cert_inspector +0 -140
  320. data/ext/envpuppet +0 -139
  321. data/ext/envpuppet.bat +0 -14
  322. data/ext/puppet-test +0 -476
  323. data/ext/pure_ruby_dsl/dsl_test.rb +0 -7
  324. data/ext/upload_facts.rb +0 -119
  325. data/lib/puppet/provider/package/dnfmodule.rb +0 -87
  326. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +0 -11
  327. data/spec/integration/type/notify_spec.rb +0 -46
  328. data/spec/unit/provider/package/dnfmodule_spec.rb +0 -186
  329. data/spec/unit/provider/package_targetable_spec.rb +0 -60
@@ -3,7 +3,6 @@ require 'matchers/include_in_order'
3
3
  require 'puppet_spec/compiler'
4
4
 
5
5
  require 'puppet/transaction'
6
- require 'puppet/type/exec'
7
6
  require 'puppet/type/notify'
8
7
  require 'fileutils'
9
8
 
@@ -780,24 +779,6 @@ describe Puppet::Transaction do
780
779
 
781
780
  transaction.evaluate
782
781
  end
783
-
784
- it "should call Selinux.matchpathcon_fini in case Selinux is enabled ", :if => Puppet.features.posix? do
785
- unless defined?(Selinux)
786
- module Selinux
787
- def self.is_selinux_enabled
788
- true
789
- end
790
- end
791
- end
792
-
793
- resource = Puppet::Type.type(:file).new(:path => make_absolute("/tmp/foo"))
794
- transaction = transaction_with_resource(resource)
795
-
796
- expect(Selinux).to receive(:matchpathcon_fini)
797
- expect(Puppet::Util::SELinux).to receive(:selinux_support?).and_return(true)
798
-
799
- transaction.evaluate
800
- end
801
782
  end
802
783
 
803
784
  describe 'when checking application run state' do
@@ -968,51 +949,6 @@ describe Puppet::Transaction do
968
949
  expect(times_send_log_with_skipping_called).to eq(3)
969
950
  end
970
951
  end
971
-
972
- describe "failed dependency is depended on multiple times" do
973
- it "notifies and warns the failed class dependency once" do
974
- Puppet.settings[:merge_dependency_warnings] = true
975
-
976
- command_string = File.expand_path('/my/command')
977
- allow(Puppet::Util::Execution).to receive(:execute).with([command_string]).and_raise(Puppet::ExecutionFailure, "Failed")
978
-
979
- # Exec['exec1'] is outside of a class, so it's warning is not subject to being coalesced.
980
- times_send_log_with_skipping_called = 0
981
- allow_any_instance_of(Puppet::Type::Exec).to receive(:send_log) {times_send_log_with_skipping_called += 1; nil}.with(:warning, "Skipping because of failed dependencies")
982
-
983
- # Class['declared_class'] depends upon Class['required_class'] which contains a resource with a failure.
984
- times_send_log_with_class_dependency_called = 0
985
- allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_dependency_called += 1; nil}.with(:notice, "Class dependency Exec[exec2] has failures: true")
986
- times_send_log_with_class_skipping_called = 0
987
- allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_skipping_called += 1; nil}.with(:warning, "Skipping resources in class because of failed class dependencies")
988
-
989
- apply_compiled_manifest(<<-MANIFEST)
990
- class required_class {
991
- exec { 'exec2':
992
- command => '#{command_string}'
993
- }
994
- }
995
- class declared_class {
996
- require required_class
997
- exec { 'exec3':
998
- command => '#{command_string}'
999
- }
1000
- exec { 'exec4':
1001
- command => '#{command_string}'
1002
- }
1003
- }
1004
- exec { 'exec1':
1005
- command => '#{command_string}',
1006
- require => Exec['exec2']
1007
- }
1008
- include declared_class
1009
- MANIFEST
1010
-
1011
- expect(times_send_log_with_skipping_called).to eq(1)
1012
- expect(times_send_log_with_class_dependency_called).to eq(1)
1013
- expect(times_send_log_with_class_skipping_called).to eq(1)
1014
- end
1015
- end
1016
952
  end
1017
953
 
1018
954
  describe Puppet::Transaction, " when determining tags" do
@@ -150,13 +150,16 @@ RSpec.describe Puppet::Type.type(:exec) do
150
150
  end
151
151
  end
152
152
 
153
- it "should redact the sensitive command on failure" do
153
+ it "should redact the command on failure" do
154
154
  output = "output1\noutput2\n"
155
155
  expect { exec_tester('false', 1, :output => output, :logoutput => :on_failure, :sensitive_parameters => [:command]).refresh }.
156
156
  to raise_error(Puppet::Error, /^\[command redacted\] returned 1 instead of/)
157
157
 
158
- expect(@logs).to include(an_object_having_attributes(level: :err, message: '[output redacted]'))
159
- expect(@logs).to_not include(an_object_having_attributes(message: /output1|output2/))
158
+ output.split("\n").each do |line|
159
+ log = @logs.shift
160
+ expect(log.level).to eq(:err)
161
+ expect(log.message).to eq(line)
162
+ end
160
163
  end
161
164
 
162
165
  it "should log the output on failure when returns is specified as an array" do
@@ -174,7 +177,7 @@ RSpec.describe Puppet::Type.type(:exec) do
174
177
  end
175
178
  end
176
179
 
177
- it "should redact the sensitive command on failure when returns is specified as an array" do
180
+ it "should redact the command on failure when returns is specified as an array" do
178
181
  output = "output1\noutput2\n"
179
182
 
180
183
  expect {
@@ -182,8 +185,11 @@ RSpec.describe Puppet::Type.type(:exec) do
182
185
  :logoutput => :on_failure, :sensitive_parameters => [:command]).refresh
183
186
  }.to raise_error(Puppet::Error, /^\[command redacted\] returned 1 instead of/)
184
187
 
185
- expect(@logs).to include(an_object_having_attributes(level: :err, message: '[output redacted]'))
186
- expect(@logs).to_not include(an_object_having_attributes(message: /output1|output2/))
188
+ output.split("\n").each do |line|
189
+ log = @logs.shift
190
+ expect(log.level).to eq(:err)
191
+ expect(log.message).to eq(line)
192
+ end
187
193
  end
188
194
 
189
195
  it "shouldn't log the output on success" do
@@ -765,15 +771,6 @@ RSpec.describe Puppet::Type.type(:exec) do
765
771
  expect(@test.check_all_attributes).to eq(true)
766
772
  expect(@logs.shift.message).to eq("test output")
767
773
  end
768
-
769
- it "should not emit output to debug if sensitive is true" do
770
- Puppet::Util::Log.level = :debug
771
- @test[param] = @fail
772
- allow(@test.parameters[param]).to receive(:sensitive).and_return(true)
773
- expect(@test.check_all_attributes).to eq(true)
774
- expect(@logs).not_to include(an_object_having_attributes(level: :debug, message: "test output"))
775
- expect(@logs).to include(an_object_having_attributes(level: :debug, message: "[output redacted]"))
776
- end
777
774
  end
778
775
  end
779
776
  end
@@ -200,21 +200,15 @@ describe Puppet::Type.type(:file).attrclass(:content), :uses_checksums => true d
200
200
  end
201
201
 
202
202
  it "prints the diff" do
203
- expect(content).to receive(:diff).and_return("my diff")
204
- expect(content).to receive(:debug).with("\nmy diff")
205
- expect(content).not_to be_safe_insync("other content")
206
- end
207
-
208
- it "prints binary file notice if diff is not valid encoding" do
209
- expect(content).to receive(:diff).and_return("\xc7\xd1\xfc\x84")
210
- expect(content).to receive(:debug).with(/\nBinary files #{filename} and .* differ/)
203
+ expect(content).to receive(:diff).and_return("my diff").once
204
+ expect(content).to receive(:debug).with("\nmy diff").once
211
205
  expect(content).not_to be_safe_insync("other content")
212
206
  end
213
207
 
214
208
  it "redacts the diff when the property is sensitive" do
215
209
  content.sensitive = true
216
210
  expect(content).not_to receive(:diff)
217
- expect(content).to receive(:debug).with("[diff redacted]")
211
+ expect(content).to receive(:debug).with("[diff redacted]").once
218
212
  expect(content).not_to be_safe_insync("other content")
219
213
  end
220
214
  end
@@ -34,11 +34,11 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
34
34
  it "should fail if the set values are not URLs" do
35
35
  expect(URI).to receive(:parse).with('foo').and_raise(RuntimeError)
36
36
 
37
- expect { resource[:source] = %w{foo} }.to raise_error(Puppet::Error)
37
+ expect(lambda { resource[:source] = %w{foo} }).to raise_error(Puppet::Error)
38
38
  end
39
39
 
40
40
  it "should fail if the URI is not a local file, file URI, or puppet URI" do
41
- expect { resource[:source] = %w{ftp://foo/bar} }.to raise_error(Puppet::Error, /Cannot use URLs of type 'ftp' as source for fileserving/)
41
+ expect(lambda { resource[:source] = %w{ftp://foo/bar} }).to raise_error(Puppet::Error, /Cannot use URLs of type 'ftp' as source for fileserving/)
42
42
  end
43
43
 
44
44
  it "should strip trailing forward slashes", :unless => Puppet::Util::Platform.windows? do
@@ -61,11 +61,11 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
61
61
  end
62
62
 
63
63
  it "should reject relative URI sources" do
64
- expect { resource[:source] = 'foo/bar' }.to raise_error(Puppet::Error)
64
+ expect(lambda { resource[:source] = 'foo/bar' }).to raise_error(Puppet::Error)
65
65
  end
66
66
 
67
67
  it "should reject opaque sources" do
68
- expect { resource[:source] = 'mailto:foo@com' }.to raise_error(Puppet::Error)
68
+ expect(lambda { resource[:source] = 'mailto:foo@com' }).to raise_error(Puppet::Error)
69
69
  end
70
70
 
71
71
  it "should accept URI authority component" do
@@ -477,9 +477,6 @@ describe Puppet::Type.type(:file) do
477
477
  end
478
478
 
479
479
  describe "#recurse" do
480
- let(:name) { 'bar' }
481
- let(:child) { double('puppet_type_file') }
482
-
483
480
  before do
484
481
  file[:recurse] = true
485
482
  @metadata = Puppet::FileServing::Metadata
@@ -488,9 +485,8 @@ describe Puppet::Type.type(:file) do
488
485
  describe "and a source is set" do
489
486
  it "should pass the already-discovered resources to recurse_remote" do
490
487
  file[:source] = File.expand_path(__FILE__)
491
- allow(child).to receive(:[]).with(:path).and_return(name)
492
- allow(file).to receive(:recurse_local).and_return(name => child)
493
- expect(file).to receive(:recurse_remote).with(name => child).and_return([])
488
+ allow(file).to receive(:recurse_local).and_return(:foo => "bar")
489
+ expect(file).to receive(:recurse_remote).with(:foo => "bar").and_return([])
494
490
  file.recurse
495
491
  end
496
492
  end
@@ -498,9 +494,8 @@ describe Puppet::Type.type(:file) do
498
494
  describe "and a target is set" do
499
495
  it "should use recurse_link" do
500
496
  file[:target] = File.expand_path(__FILE__)
501
- allow(child).to receive(:[]).with(:path).and_return(name)
502
- allow(file).to receive(:recurse_local).and_return(name => child)
503
- expect(file).to receive(:recurse_link).with(name => child).and_return([])
497
+ allow(file).to receive(:recurse_local).and_return(:foo => "bar")
498
+ expect(file).to receive(:recurse_link).with(:foo => "bar").and_return([])
504
499
  file.recurse
505
500
  end
506
501
  end
@@ -1152,13 +1147,13 @@ describe Puppet::Type.type(:file) do
1152
1147
 
1153
1148
  it "should convert symbolic mode to int" do
1154
1149
  file[:mode] = 'oga=r'
1155
- expect(Puppet::Util).to receive(:replace_file).with(file[:path], 0444)
1150
+ expect(Puppet::Util).to receive(:replace_file).with(file[:path], 0444, { :staging_location => nil, :validate_callback => nil })
1156
1151
  file.write
1157
1152
  end
1158
1153
 
1159
1154
  it "should support int modes" do
1160
1155
  file[:mode] = '0444'
1161
- expect(Puppet::Util).to receive(:replace_file).with(file[:path], 0444)
1156
+ expect(Puppet::Util).to receive(:replace_file).with(file[:path], 0444, { :staging_location => nil, :validate_callback => nil })
1162
1157
  file.write
1163
1158
  end
1164
1159
  end
@@ -1259,6 +1254,15 @@ describe Puppet::Type.type(:file) do
1259
1254
  it "should be false if the file has neither content nor source" do
1260
1255
  expect(file.send(:write_temporary_file?)).to be_falsey
1261
1256
  end
1257
+
1258
+ context "and staging_location is provided" do
1259
+ it "should write the file first to the staging location" do
1260
+ file[:content] = 'some content'
1261
+ file[:staging_location] = Dir.tmpdir()
1262
+ expect(Puppet::Util).to receive(:replace_file).with(file[:path], nil, { staging_location: Dir.tmpdir(), validate_callback: nil })
1263
+ file.write
1264
+ end
1265
+ end
1262
1266
  end
1263
1267
 
1264
1268
  describe "#property_fix" do
@@ -375,11 +375,6 @@ describe Puppet::Type.type(:package) do
375
375
  expect(pkg[:allow_virtual]).to eq true
376
376
  end
377
377
 
378
- it "defaults to false on dpkg provider" do
379
- pkg = Puppet::Type.type(:package).new(:name => 'yay', :provider => :dpkg)
380
- expect(pkg[:allow_virtual]).to be_nil
381
- end
382
-
383
378
  it "defaults to false on platforms that do not support virtual packages" do
384
379
  pkg = Puppet::Type.type(:package).new(:name => 'yay', :provider => :apple)
385
380
  expect(pkg[:allow_virtual]).to be_nil
@@ -446,9 +446,7 @@ describe Puppet::Type.type(:schedule) do
446
446
 
447
447
  it "should fail if the periodmatch is 'number'" do
448
448
  @schedule[:periodmatch] = :number
449
- expect {
450
- @schedule[:repeat] = 2
451
- }.to raise_error(Puppet::Error)
449
+ expect(proc { @schedule[:repeat] = 2 }).to raise_error(Puppet::Error)
452
450
  end
453
451
 
454
452
  it "should match if the previous run was further away than the distance divided by the repeat" do
@@ -93,13 +93,6 @@ describe test_title, "when validating attribute values" do
93
93
  expect(srv.should(:enable)).to eq(:manual)
94
94
  end
95
95
 
96
- it "should support :delayed as a value on Windows" do
97
- allow(Puppet::Util::Platform).to receive(:windows?).and_return(true)
98
-
99
- srv = Puppet::Type.type(:service).new(:name => "yay", :enable => :delayed)
100
- expect(srv.should(:enable)).to eq(:delayed)
101
- end
102
-
103
96
  it "should not support :manual as a value when not on Windows" do
104
97
  allow(Puppet::Util::Platform).to receive(:windows?).and_return(false)
105
98
 
@@ -108,15 +101,6 @@ describe test_title, "when validating attribute values" do
108
101
  /Setting enable to manual is only supported on Microsoft Windows\./
109
102
  )
110
103
  end
111
-
112
- it "should not support :delayed as a value when not on Windows" do
113
- allow(Puppet::Util::Platform).to receive(:windows?).and_return(false)
114
-
115
- expect { Puppet::Type.type(:service).new(:name => "yay", :enable => :delayed) }.to raise_error(
116
- Puppet::Error,
117
- /Setting enable to delayed is only supported on Microsoft Windows\./
118
- )
119
- end
120
104
  end
121
105
 
122
106
  describe "the timeout parameter" do
@@ -128,13 +128,6 @@ describe Puppet::Util::Execution, if: !Puppet::Util::Platform.jruby? do
128
128
 
129
129
  call_exec_posix('test command', { :cwd => cwd }, @stdin, @stdout, @stderr)
130
130
  end
131
-
132
- it "should not change the current working directory if cwd is unspecified" do
133
- expect(Dir).to receive(:chdir).never
134
- expect(Kernel).to receive(:exec).with('test command')
135
-
136
- call_exec_posix('test command', {}, @stdin, @stdout, @stderr)
137
- end
138
131
  end
139
132
 
140
133
  it "should return the pid of the child process" do
@@ -178,15 +171,6 @@ describe Puppet::Util::Execution, if: !Puppet::Util::Platform.jruby? do
178
171
 
179
172
  call_exec_windows('test command', { :cwd => cwd }, @stdin, @stdout, @stderr)
180
173
  end
181
-
182
- it "should not change the current working directory if cwd is unspecified" do
183
- expect(Dir).to receive(:chdir).never
184
- expect(Process).to receive(:create) do |args|
185
- expect(args[:cwd]).to be_nil
186
- end
187
-
188
- call_exec_windows('test command', {}, @stdin, @stdout, @stderr)
189
- end
190
174
  end
191
175
 
192
176
  context 'suppress_window option' do
@@ -12,103 +12,6 @@ describe Puppet::Util::HttpProxy do
12
12
 
13
13
  host, port, user, password = 'some.host', 1234, 'user1', 'pAssw0rd'
14
14
 
15
- def expects_direct_connection_to(http, www)
16
- expect(http.address).to eq(www.host)
17
- expect(http.port).to eq(www.port)
18
-
19
- expect(http.proxy_address).to be_nil
20
- expect(http.proxy_port).to be_nil
21
- expect(http.proxy_user).to be_nil
22
- expect(http.proxy_pass).to be_nil
23
- end
24
-
25
- def expects_proxy_connection_via(http, www, host, port, user, password)
26
- expect(http.address).to eq(www.host)
27
- expect(http.port).to eq(www.port)
28
-
29
- expect(http.proxy_address).to eq(host)
30
- expect(http.proxy_port).to eq(port)
31
- expect(http.proxy_user).to eq(user)
32
- expect(http.proxy_pass).to eq(password)
33
- end
34
-
35
- describe '.proxy' do
36
- let(:www) { URI::HTTP.build(host: 'www.example.com', port: 80) }
37
-
38
- it 'uses a proxy' do
39
- Puppet[:http_proxy_host] = host
40
- Puppet[:http_proxy_port] = port
41
- Puppet[:http_proxy_user] = user
42
- Puppet[:http_proxy_password] = password
43
-
44
- http = subject.proxy(www)
45
- expects_proxy_connection_via(http, www, host, port, user, password)
46
- end
47
-
48
- it 'connects directly to the server' do
49
- http = subject.proxy(www)
50
- expects_direct_connection_to(http, www)
51
- end
52
-
53
- context 'when setting no_proxy' do
54
- before :each do
55
- Puppet[:http_proxy_host] = host
56
- Puppet[:http_proxy_port] = port
57
- end
58
-
59
- it 'connects directly to the server when HTTP_PROXY environment variable is set, but server matches no_proxy setting' do
60
- Puppet[:no_proxy] = www.host
61
-
62
- Puppet::Util.withenv('HTTP_PROXY' => "http://#{host}:#{port}") do
63
- http = subject.proxy(www)
64
- expects_direct_connection_to(http, www)
65
- end
66
- end
67
-
68
- it 'connects directly to the server when no_proxy matches wildcard domain' do
69
- Puppet[:no_proxy] = '*.example.com'
70
-
71
- http = subject.proxy(www)
72
- expects_direct_connection_to(http, www)
73
- end
74
-
75
- it 'connects directly to the server when no_proxy matches dotted domain' do
76
- Puppet[:no_proxy] = '.example.com'
77
-
78
- http = subject.proxy(www)
79
- expects_direct_connection_to(http, www)
80
- end
81
-
82
- it 'connects directly to the server when no_proxy matches a domain suffix like ruby does' do
83
- Puppet[:no_proxy] = 'example.com'
84
-
85
- http = subject.proxy(www)
86
- expects_direct_connection_to(http, www)
87
- end
88
-
89
- it 'connects directly to the server when no_proxy matches a partial suffix like ruby does' do
90
- Puppet[:no_proxy] = 'ample.com'
91
-
92
- http = subject.proxy(www)
93
- expects_direct_connection_to(http, www)
94
- end
95
-
96
- it 'connects directly to the server when it is a subdomain of no_proxy' do
97
- Puppet[:no_proxy] = '*.com'
98
-
99
- http = subject.proxy(www)
100
- expects_direct_connection_to(http, www)
101
- end
102
-
103
- it 'connects directly to the server when no_proxy is *' do
104
- Puppet[:no_proxy] = '*'
105
-
106
- http = subject.proxy(www)
107
- expects_direct_connection_to(http, www)
108
- end
109
- end
110
- end
111
-
112
15
  describe ".http_proxy_env" do
113
16
  it "should return nil if no environment variables" do
114
17
  expect(subject.http_proxy_env).to eq(nil)
@@ -226,32 +129,9 @@ describe Puppet::Util::HttpProxy do
226
129
 
227
130
  end
228
131
 
229
- describe ".no_proxy" do
230
- no_proxy = '127.0.0.1, localhost'
231
- it "should use a no_proxy list if set in environment" do
232
- Puppet::Util.withenv('NO_PROXY' => no_proxy) do
233
- expect(subject.no_proxy).to eq(no_proxy)
234
- end
235
- end
236
-
237
- it "should use a no_proxy list if set in config" do
238
- Puppet.settings[:no_proxy] = no_proxy
239
- expect(subject.no_proxy).to eq(no_proxy)
240
- end
241
-
242
- it "should use environment variable before puppet settings" do
243
- no_proxy_puppet_setting = '10.0.0.1, localhost'
244
- Puppet::Util.withenv('NO_PROXY' => no_proxy) do
245
- Puppet.settings[:no_proxy] = no_proxy_puppet_setting
246
- expect(subject.no_proxy).to eq(no_proxy)
247
- end
248
- end
249
- end
250
-
251
132
  describe ".no_proxy?" do
252
133
  no_proxy = '127.0.0.1, localhost, mydomain.com, *.otherdomain.com, oddport.com:8080, *.otheroddport.com:8080, .anotherdomain.com, .anotheroddport.com:8080'
253
-
254
- it "should return false if no_proxy does not exist in environment or puppet settings" do
134
+ it "should return false if no_proxy does not exist in env" do
255
135
  Puppet::Util.withenv('no_proxy' => nil) do
256
136
  dest = 'https://puppetlabs.com'
257
137
  expect(subject.no_proxy?(dest)).to be false
@@ -338,22 +218,22 @@ describe Puppet::Util::HttpProxy do
338
218
 
339
219
  describe '.request_with_redirects' do
340
220
  let(:dest) { URI.parse('http://mydomain.com/some/path') }
221
+ let(:http_ok) { double('http ok', :code => 200, :message => 'HTTP OK') }
341
222
 
342
223
  it 'generates accept and accept-encoding headers' do
343
- stub_request(:head, dest)
344
-
345
- headers = {
346
- 'Accept' => '*/*',
347
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
348
- 'User-Agent' => /Puppet/
349
- }
350
- stub_request(:get, dest).with(headers: headers)
224
+ allow_any_instance_of(Net::HTTP).to receive(:head).and_return(http_ok)
225
+ expect_any_instance_of(Net::HTTP).to receive(:get) do |_, _, headers|
226
+ expect(headers)
227
+ .to match({'Accept' => '*/*',
228
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
229
+ 'User-Agent' => /Puppet/})
230
+ end.and_return(http_ok)
351
231
 
352
232
  subject.request_with_redirects(dest, :get, 0)
353
233
  end
354
234
 
355
235
  it 'can return a compressed response body' do
356
- stub_request(:head, dest)
236
+ allow_any_instance_of(Net::HTTP).to receive(:head).and_return(http_ok)
357
237
 
358
238
  compressed_body = [
359
239
  0x1f, 0x8b, 0x08, 0x08, 0xe9, 0x08, 0x7a, 0x5a, 0x00, 0x03,
@@ -361,7 +241,9 @@ describe Puppet::Util::HttpProxy do
361
241
  0x00, 0x7a, 0x7a, 0x6f, 0xed, 0x03, 0x00, 0x00, 0x00
362
242
  ].pack('C*')
363
243
 
364
- stub_request(:get, dest).to_return(status: 200, body: compressed_body, headers: { 'Content-Encoding' => 'gzip' })
244
+ response = double('http ok', :code => 200, :message => 'HTTP OK', :body => compressed_body)
245
+ allow(response).to receive(:[]).with('content-encoding').and_return('gzip')
246
+ expect_any_instance_of(Net::HTTP).to receive(:get).and_return(response)
365
247
 
366
248
  expect(
367
249
  uncompress_body(subject.request_with_redirects(dest, :get, 0))
@@ -369,14 +251,13 @@ describe Puppet::Util::HttpProxy do
369
251
  end
370
252
 
371
253
  it 'generates accept and accept-encoding headers when a block is provided' do
372
- stub_request(:head, dest)
373
-
374
- headers = {
375
- 'Accept' => '*/*',
376
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
377
- 'User-Agent' => /Puppet/
378
- }
379
- stub_request(:get, dest).with(headers: headers)
254
+ allow_any_instance_of(Net::HTTP).to receive(:head).and_return(http_ok)
255
+ expect_any_instance_of(Net::HTTP).to receive(:request_get) do |_, _, headers, &block|
256
+ expect(headers)
257
+ .to match({'Accept' => '*/*',
258
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
259
+ 'User-Agent' => /Puppet/})
260
+ end.and_return(http_ok)
380
261
 
381
262
  subject.request_with_redirects(dest, :get, 0) do
382
263
  # unused
@@ -384,20 +265,9 @@ describe Puppet::Util::HttpProxy do
384
265
  end
385
266
 
386
267
  it 'only makes a single HEAD request' do
387
- stub_request(:head, dest)
268
+ expect_any_instance_of(Net::HTTP).to receive(:head).with(anything, anything).and_return(http_ok)
388
269
 
389
270
  subject.request_with_redirects(dest, :head, 0)
390
271
  end
391
-
392
- it 'preserves query parameters' do
393
- url = URI.parse('http://mydomain.com/some/path?foo=bar')
394
-
395
- stub_request(:head, url)
396
- stub_request(:get, url)
397
-
398
- subject.request_with_redirects(url, :get, 0) do
399
- # unused
400
- end
401
- end
402
272
  end
403
273
  end