puppet 6.19.0 → 6.22.1

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 (212) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -16
  3. data/Gemfile +3 -1
  4. data/Gemfile.lock +50 -39
  5. data/ext/project_data.yaml +2 -2
  6. data/lib/puppet/application.rb +10 -6
  7. data/lib/puppet/application/agent.rb +1 -0
  8. data/lib/puppet/application/apply.rb +3 -2
  9. data/lib/puppet/application/device.rb +1 -0
  10. data/lib/puppet/application/filebucket.rb +2 -2
  11. data/lib/puppet/application/script.rb +1 -0
  12. data/lib/puppet/application/ssl.rb +11 -0
  13. data/lib/puppet/application_support.rb +7 -0
  14. data/lib/puppet/configurer.rb +28 -18
  15. data/lib/puppet/defaults.rb +46 -20
  16. data/lib/puppet/environments.rb +54 -55
  17. data/lib/puppet/face/config.rb +10 -0
  18. data/lib/puppet/face/epp.rb +12 -2
  19. data/lib/puppet/face/facts.rb +158 -0
  20. data/lib/puppet/ffi/posix.rb +10 -0
  21. data/lib/puppet/ffi/posix/constants.rb +14 -0
  22. data/lib/puppet/ffi/posix/functions.rb +24 -0
  23. data/lib/puppet/file_system/memory_file.rb +8 -1
  24. data/lib/puppet/file_system/windows.rb +2 -0
  25. data/lib/puppet/functions/epp.rb +1 -0
  26. data/lib/puppet/functions/inline_epp.rb +1 -0
  27. data/lib/puppet/functions/partition.rb +8 -0
  28. data/lib/puppet/indirector/fact_search.rb +60 -0
  29. data/lib/puppet/indirector/facts/facter.rb +24 -3
  30. data/lib/puppet/indirector/facts/json.rb +27 -0
  31. data/lib/puppet/indirector/facts/yaml.rb +3 -58
  32. data/lib/puppet/indirector/json.rb +5 -1
  33. data/lib/puppet/indirector/node/json.rb +8 -0
  34. data/lib/puppet/indirector/report/json.rb +34 -0
  35. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  36. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  37. data/lib/puppet/network/formats.rb +69 -1
  38. data/lib/puppet/network/http/factory.rb +4 -0
  39. data/lib/puppet/pal/pal_impl.rb +70 -17
  40. data/lib/puppet/parser/ast/leaf.rb +3 -2
  41. data/lib/puppet/parser/templatewrapper.rb +1 -1
  42. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -3
  44. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  45. data/lib/puppet/property/list.rb +1 -1
  46. data/lib/puppet/provider/group/groupadd.rb +13 -8
  47. data/lib/puppet/provider/package/apt.rb +34 -2
  48. data/lib/puppet/provider/package/aptitude.rb +6 -0
  49. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  50. data/lib/puppet/provider/service/debian.rb +2 -0
  51. data/lib/puppet/provider/service/systemd.rb +1 -1
  52. data/lib/puppet/provider/user/aix.rb +2 -2
  53. data/lib/puppet/provider/user/useradd.rb +62 -8
  54. data/lib/puppet/reference/configuration.rb +6 -5
  55. data/lib/puppet/settings.rb +43 -15
  56. data/lib/puppet/settings/alias_setting.rb +37 -0
  57. data/lib/puppet/settings/base_setting.rb +26 -2
  58. data/lib/puppet/settings/environment_conf.rb +1 -0
  59. data/lib/puppet/type/package.rb +3 -3
  60. data/lib/puppet/util/autoload.rb +1 -8
  61. data/lib/puppet/util/fact_dif.rb +81 -0
  62. data/lib/puppet/util/monkey_patches.rb +7 -0
  63. data/lib/puppet/util/posix.rb +54 -5
  64. data/lib/puppet/util/rubygems.rb +5 -1
  65. data/lib/puppet/util/windows/adsi.rb +46 -0
  66. data/lib/puppet/util/windows/api_types.rb +1 -1
  67. data/lib/puppet/util/windows/principal.rb +9 -2
  68. data/lib/puppet/util/windows/service.rb +1 -1
  69. data/lib/puppet/util/windows/sid.rb +4 -2
  70. data/lib/puppet/version.rb +1 -1
  71. data/locales/puppet.pot +295 -219
  72. data/man/man5/puppet.conf.5 +15 -7
  73. data/man/man8/puppet-agent.8 +2 -2
  74. data/man/man8/puppet-apply.8 +2 -2
  75. data/man/man8/puppet-catalog.8 +1 -1
  76. data/man/man8/puppet-config.8 +1 -1
  77. data/man/man8/puppet-describe.8 +1 -1
  78. data/man/man8/puppet-device.8 +2 -2
  79. data/man/man8/puppet-doc.8 +1 -1
  80. data/man/man8/puppet-epp.8 +1 -1
  81. data/man/man8/puppet-facts.8 +90 -1
  82. data/man/man8/puppet-filebucket.8 +3 -3
  83. data/man/man8/puppet-generate.8 +1 -1
  84. data/man/man8/puppet-help.8 +1 -1
  85. data/man/man8/puppet-key.8 +1 -1
  86. data/man/man8/puppet-lookup.8 +1 -1
  87. data/man/man8/puppet-man.8 +1 -1
  88. data/man/man8/puppet-module.8 +1 -1
  89. data/man/man8/puppet-node.8 +4 -1
  90. data/man/man8/puppet-parser.8 +1 -1
  91. data/man/man8/puppet-plugin.8 +1 -1
  92. data/man/man8/puppet-report.8 +4 -1
  93. data/man/man8/puppet-resource.8 +1 -1
  94. data/man/man8/puppet-script.8 +2 -2
  95. data/man/man8/puppet-ssl.8 +5 -1
  96. data/man/man8/puppet-status.8 +1 -1
  97. data/man/man8/puppet.8 +2 -2
  98. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  99. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  100. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
  101. data/spec/integration/application/agent_spec.rb +160 -3
  102. data/spec/integration/application/apply_spec.rb +19 -0
  103. data/spec/integration/application/plugin_spec.rb +1 -1
  104. data/spec/integration/defaults_spec.rb +0 -7
  105. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  106. data/spec/integration/http/client_spec.rb +12 -0
  107. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  108. data/spec/integration/resource/type_collection_spec.rb +2 -6
  109. data/spec/integration/transaction_spec.rb +4 -9
  110. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  111. data/spec/integration/util/windows/principal_spec.rb +21 -0
  112. data/spec/integration/util/windows/registry_spec.rb +6 -10
  113. data/spec/lib/puppet_spec/settings.rb +6 -1
  114. data/spec/spec_helper.rb +12 -5
  115. data/spec/unit/agent_spec.rb +8 -6
  116. data/spec/unit/application/agent_spec.rb +0 -1
  117. data/spec/unit/application/config_spec.rb +224 -4
  118. data/spec/unit/application/facts_spec.rb +482 -3
  119. data/spec/unit/application/filebucket_spec.rb +0 -2
  120. data/spec/unit/application/ssl_spec.rb +23 -0
  121. data/spec/unit/application_spec.rb +51 -9
  122. data/spec/unit/confine/feature_spec.rb +1 -1
  123. data/spec/unit/confine_spec.rb +8 -2
  124. data/spec/unit/defaults_spec.rb +36 -1
  125. data/spec/unit/environments_spec.rb +221 -68
  126. data/spec/unit/face/config_spec.rb +27 -32
  127. data/spec/unit/face/facts_spec.rb +4 -0
  128. data/spec/unit/face/node_spec.rb +0 -11
  129. data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
  130. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  131. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  132. data/spec/unit/file_system_spec.rb +9 -0
  133. data/spec/unit/forge/module_release_spec.rb +2 -7
  134. data/spec/unit/functions/inline_epp_spec.rb +26 -1
  135. data/spec/unit/http/service/compiler_spec.rb +49 -0
  136. data/spec/unit/http/service_spec.rb +1 -1
  137. data/spec/unit/indirector/face_spec.rb +0 -1
  138. data/spec/unit/indirector/facts/facter_spec.rb +95 -1
  139. data/spec/unit/indirector/facts/json_spec.rb +255 -0
  140. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  141. data/spec/unit/indirector/indirection_spec.rb +8 -12
  142. data/spec/unit/indirector/key/file_spec.rb +0 -1
  143. data/spec/unit/indirector/node/json_spec.rb +33 -0
  144. data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
  145. data/spec/unit/indirector/report/yaml_spec.rb +72 -8
  146. data/spec/unit/indirector_spec.rb +2 -2
  147. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  148. data/spec/unit/network/authconfig_spec.rb +0 -3
  149. data/spec/unit/network/formats_spec.rb +41 -0
  150. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -9
  151. data/spec/unit/network/http/factory_spec.rb +19 -0
  152. data/spec/unit/network/http/handler_spec.rb +0 -5
  153. data/spec/unit/parser/compiler_spec.rb +3 -19
  154. data/spec/unit/parser/resource_spec.rb +14 -8
  155. data/spec/unit/parser/templatewrapper_spec.rb +4 -3
  156. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  157. data/spec/unit/property_spec.rb +1 -0
  158. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  159. data/spec/unit/provider/nameservice_spec.rb +66 -65
  160. data/spec/unit/provider/package/apt_spec.rb +28 -23
  161. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  162. data/spec/unit/provider/package/base_spec.rb +6 -5
  163. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  164. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  165. data/spec/unit/provider/package/pip_spec.rb +6 -11
  166. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  167. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  168. data/spec/unit/provider/user/aix_spec.rb +5 -0
  169. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  170. data/spec/unit/provider/user/pw_spec.rb +2 -0
  171. data/spec/unit/provider/user/useradd_spec.rb +71 -3
  172. data/spec/unit/provider_spec.rb +8 -10
  173. data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
  174. data/spec/unit/resource/capability_finder_spec.rb +6 -1
  175. data/spec/unit/resource/catalog_spec.rb +1 -1
  176. data/spec/unit/resource/type_spec.rb +1 -1
  177. data/spec/unit/resource_spec.rb +11 -10
  178. data/spec/unit/settings_spec.rb +543 -228
  179. data/spec/unit/ssl/base_spec.rb +0 -1
  180. data/spec/unit/ssl/host_spec.rb +0 -5
  181. data/spec/unit/ssl/ssl_provider_spec.rb +14 -8
  182. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  183. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  184. data/spec/unit/transaction_spec.rb +13 -4
  185. data/spec/unit/type/file/content_spec.rb +0 -1
  186. data/spec/unit/type/file/selinux_spec.rb +0 -2
  187. data/spec/unit/type/file_spec.rb +0 -6
  188. data/spec/unit/type/group_spec.rb +13 -6
  189. data/spec/unit/type/resources_spec.rb +7 -7
  190. data/spec/unit/type/service_spec.rb +1 -1
  191. data/spec/unit/type/tidy_spec.rb +0 -1
  192. data/spec/unit/type_spec.rb +2 -2
  193. data/spec/unit/util/at_fork_spec.rb +2 -2
  194. data/spec/unit/util/autoload_spec.rb +5 -1
  195. data/spec/unit/util/backups_spec.rb +1 -2
  196. data/spec/unit/util/execution_spec.rb +15 -11
  197. data/spec/unit/util/inifile_spec.rb +6 -14
  198. data/spec/unit/util/log_spec.rb +8 -7
  199. data/spec/unit/util/logging_spec.rb +3 -3
  200. data/spec/unit/util/posix_spec.rb +363 -15
  201. data/spec/unit/util/rubygems_spec.rb +2 -2
  202. data/spec/unit/util/selinux_spec.rb +76 -52
  203. data/spec/unit/util/storage_spec.rb +3 -1
  204. data/spec/unit/util/suidmanager_spec.rb +44 -41
  205. data/spec/unit/util/windows/sid_spec.rb +6 -0
  206. data/spec/unit/util_spec.rb +13 -6
  207. metadata +23 -14
  208. data/spec/integration/application/config_spec.rb +0 -74
  209. data/spec/lib/matchers/include.rb +0 -27
  210. data/spec/lib/matchers/include_spec.rb +0 -32
  211. data/spec/unit/face/catalog_spec.rb +0 -6
  212. data/spec/unit/face/module_spec.rb +0 -3
@@ -4,14 +4,6 @@ require 'puppet/transaction/report'
4
4
  require 'puppet/indirector/report/yaml'
5
5
 
6
6
  describe Puppet::Transaction::Report::Yaml do
7
- it "should be a subclass of the Yaml terminus" do
8
- expect(Puppet::Transaction::Report::Yaml.superclass).to equal(Puppet::Indirector::Yaml)
9
- end
10
-
11
- it "should have documentation" do
12
- expect(Puppet::Transaction::Report::Yaml.doc).not_to be_nil
13
- end
14
-
15
7
  it "should be registered with the report indirection" do
16
8
  indirection = Puppet::Indirector::Indirection.instance(:report)
17
9
  expect(Puppet::Transaction::Report::Yaml.indirection).to equal(indirection)
@@ -24,4 +16,76 @@ describe Puppet::Transaction::Report::Yaml do
24
16
  it "should unconditionally save/load from the --lastrunreport setting" do
25
17
  expect(subject.path(:me)).to eq(Puppet[:lastrunreport])
26
18
  end
19
+
20
+ describe '#save' do
21
+ subject(:indirection) { described_class.indirection }
22
+
23
+ let(:request) { described_class.new }
24
+ let(:certname) { 'ziggy' }
25
+ let(:report) do
26
+ report = Puppet::Transaction::Report.new
27
+ report.host = certname
28
+ report
29
+ end
30
+ let(:file) { request.path(:me) }
31
+
32
+ before do
33
+ indirection.terminus_class = :yaml
34
+ end
35
+
36
+ it 'saves the instance of the report as YAML to disk' do
37
+ indirection.save(report)
38
+ content = Puppet::Util::Yaml.safe_load_file(
39
+ Puppet[:lastrunreport], [Puppet::Transaction::Report]
40
+ )
41
+ expect(content.host).to eq(certname)
42
+ end
43
+
44
+ it 'allows mode overwrite' do
45
+ Puppet.settings.setting(:lastrunreport).mode = '0644'
46
+ indirection.save(report)
47
+
48
+ if Puppet::Util::Platform.windows?
49
+ mode = File.stat(file).mode
50
+ else
51
+ mode = Puppet::FileSystem.stat(file).mode
52
+ end
53
+
54
+ expect(mode & 07777).to eq(0644)
55
+ end
56
+
57
+ context 'when mode is invalid' do
58
+ before do
59
+ Puppet.settings.setting(:lastrunreport).mode = '9999'
60
+ end
61
+
62
+ after do
63
+ Puppet.settings.setting(:lastrunreport).mode = '0644'
64
+ end
65
+
66
+ it 'raises Puppet::DevError ' do
67
+ expect{
68
+ indirection.save(report)
69
+ }.to raise_error(Puppet::DevError, "replace_file mode: 9999 is invalid")
70
+ end
71
+ end
72
+
73
+ context 'when repport is invalid' do
74
+ it 'logs error' do
75
+ expect(Puppet).to receive(:send_log).with(:err, /Could not save yaml ziggy: can't dump anonymous class/)
76
+
77
+ report.configuration_version = Class.new
78
+ indirection.save(report)
79
+ end
80
+ end
81
+
82
+ context 'when report cannot be saved' do
83
+ it 'raises Error' do
84
+ FileUtils.mkdir_p(file)
85
+ expect {
86
+ indirection.save(report)
87
+ }.to raise_error(Errno::EISDIR, /last_run_report.yaml/)
88
+ end
89
+ end
90
+ end
27
91
  end
@@ -112,8 +112,8 @@ describe Puppet::Indirector, "when registering an indirection" do
112
112
  end
113
113
 
114
114
  it "should pass any provided options to the indirection during initialization" do
115
- expect(Puppet::Indirector::Indirection).to receive(:new).with(@thingie, :first, {:some => :options, :indirected_class => 'Thingie'})
116
- @indirection = @thingie.indirects :first, :some => :options
115
+ expect(Puppet::Indirector::Indirection).to receive(:new).with(@thingie, :first, {:doc => 'some docs', :indirected_class => 'Thingie'})
116
+ @indirection = @thingie.indirects :first, :doc => 'some docs'
117
117
  end
118
118
 
119
119
  it "should extend the class to handle serialization" do
@@ -247,6 +247,21 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
247
247
  expect(subject).to include :result => :success
248
248
  graph_should_include 'pmtacceptance-mysql', nil => v('0.8.0')
249
249
  end
250
+
251
+ context 'with an already installed dependency' do
252
+ before { preinstall('pmtacceptance-stdlib', '2.6.0') }
253
+
254
+ def options
255
+ super.merge(:version => '0.7.0')
256
+ end
257
+
258
+ it 'installs given version without errors and does not change version of dependency' do
259
+ expect(subject).to include :result => :success
260
+ graph_should_include 'pmtacceptance-mysql', nil => v('0.7.0')
261
+ expect(subject[:error]).to be_nil
262
+ graph_should_include 'pmtacceptance-stdlib', v('2.6.0') => v('2.6.0')
263
+ end
264
+ end
250
265
  end
251
266
 
252
267
  context 'with a --version that cannot satisfy' do
@@ -258,6 +273,20 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
258
273
  expect(subject).to include :result => :failure
259
274
  end
260
275
 
276
+ it 'prints a detailed error containing the modules that would not be satisfied' do
277
+ graph = double(SemanticPuppet::Dependency::Graph, :modules => ['pmtacceptance-mysql'])
278
+ exception = SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph)
279
+ allow(exception).to receive(:respond_to?).and_return(true)
280
+ allow(exception).to receive(:unsatisfied).and_return('pmtacceptance-mysql')
281
+ allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(exception)
282
+
283
+ expect(subject[:error]).to include(:multiline)
284
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
285
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
286
+ expect(subject[:error][:multiline]).to include("pmtacceptance-keystone, expects 'pmtacceptance-mysql': >=0.6.1 <1.0.0")
287
+ expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
288
+ end
289
+
261
290
  context 'with --ignore-dependencies' do
262
291
  def options
263
292
  super.merge(:ignore_dependencies => true)
@@ -278,6 +307,43 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
278
307
  graph_should_include 'pmtacceptance-mysql', nil => v('2.1.0')
279
308
  end
280
309
  end
310
+
311
+ context 'with an already installed dependency' do
312
+ let(:graph) {
313
+ double(SemanticPuppet::Dependency::Graph,
314
+ :dependencies => {
315
+ 'pmtacceptance-mysql' => {
316
+ :version => '2.1.0'
317
+ }
318
+ },
319
+ :modules => ['pmtacceptance-mysql'],
320
+ :unsatisfied => 'pmtacceptance-stdlib'
321
+ )
322
+ }
323
+
324
+ let(:unsatisfiable_graph_exception) { SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph) }
325
+
326
+ before do
327
+ allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(unsatisfiable_graph_exception)
328
+ allow(unsatisfiable_graph_exception).to receive(:respond_to?).and_return(true)
329
+ allow(unsatisfiable_graph_exception).to receive(:unsatisfied).and_return(graph.unsatisfied)
330
+
331
+ preinstall('pmtacceptance-stdlib', '2.6.0')
332
+ end
333
+
334
+ def options
335
+ super.merge(:version => '2.1.0')
336
+ end
337
+
338
+ it 'fails to install and outputs a multiline error containing the versions, expectations and workaround' do
339
+ expect(subject).to include :result => :failure
340
+ expect(subject[:error]).to include(:multiline)
341
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (v2.1.0)")
342
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
343
+ expect(subject[:error][:multiline]).to include("pmtacceptance-stdlib, installed: 2.6.0, expected: >= 2.2.1")
344
+ expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
345
+ end
346
+ end
281
347
  end
282
348
  end
283
349
 
@@ -6,9 +6,6 @@ describe Puppet::Network::DefaultAuthProvider do
6
6
  before :each do
7
7
  allow(Puppet::FileSystem).to receive(:stat).and_return(double('stat', :ctime => :now))
8
8
  allow(Time).to receive(:now).and_return(Time.now)
9
-
10
- allow_any_instance_of(Puppet::Network::DefaultAuthProvider).to receive(:exists?).and_return(true)
11
- # FIXME @authprovider = Puppet::Network::DefaultAuthProvider.new("dummy")
12
9
  end
13
10
 
14
11
  describe "when initializing" do
@@ -534,4 +534,45 @@ EOT
534
534
  end
535
535
  end
536
536
  end
537
+
538
+ describe ":flat format" do
539
+ let(:flat) { Puppet::Network::FormatHandler.format(:flat) }
540
+
541
+ it "should include a flat format" do
542
+ expect(flat).to be_an_instance_of Puppet::Network::Format
543
+ end
544
+
545
+ [:intern, :intern_multiple].each do |method|
546
+ it "should not implement #{method}" do
547
+ expect { flat.send(method, String, 'blah') }.to raise_error NotImplementedError
548
+ end
549
+ end
550
+
551
+ context "when rendering arrays" do
552
+ {
553
+ [] => "",
554
+ [1, 2] => "0=1\n1=2\n",
555
+ ["one"] => "0=one\n",
556
+ [{"one" => 1}, {"two" => 2}] => "0.one=1\n1.two=2\n",
557
+ [['something', 'for'], ['the', 'test']] => "0=[\"something\", \"for\"]\n1=[\"the\", \"test\"]\n"
558
+ }.each_pair do |input, output|
559
+ it "should render #{input.inspect} as one item per line" do
560
+ expect(flat.render(input)).to eq(output)
561
+ end
562
+ end
563
+ end
564
+
565
+ context "when rendering hashes" do
566
+ {
567
+ {} => "",
568
+ {1 => 2} => "1=2\n",
569
+ {"one" => "two"} => "one=two\n",
570
+ {[1,2] => 3, [2,3] => 5, [3,4] => 7} => "[1, 2]=3\n[2, 3]=5\n[3, 4]=7\n",
571
+ }.each_pair do |input, output|
572
+ it "should render #{input.inspect}" do
573
+ expect(flat.render(input)).to eq(output)
574
+ end
575
+ end
576
+ end
577
+ end
537
578
  end
@@ -17,7 +17,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
17
17
  before do
18
18
  Puppet::IndirectorTesting.indirection.terminus_class = :memory
19
19
  Puppet::IndirectorTesting.indirection.terminus.clear
20
- allow(handler).to receive(:warn_if_near_expiration)
21
20
  end
22
21
 
23
22
  describe "when converting a URI into a request" do
@@ -25,10 +24,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
25
24
  let(:env_loaders) { Puppet::Environments::Static.new(environment) }
26
25
  let(:params) { { :environment => "env" } }
27
26
 
28
- before do
29
- allow(handler).to receive(:handler).and_return("foo")
30
- end
31
-
32
27
  around do |example|
33
28
  Puppet.override(:environments => env_loaders) do
34
29
  example.run
@@ -180,10 +175,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
180
175
  let(:environment) { Puppet::Node::Environment.create(:myenv, []) }
181
176
  let(:request) { Puppet::Indirector::Request.new(:foo, :find, "with spaces", nil, :foo => :bar, :environment => environment) }
182
177
 
183
- before do
184
- allow(handler).to receive(:handler).and_return("foo")
185
- end
186
-
187
178
  it "should include the environment in the query string of the URI" do
188
179
  expect(handler.class.request_to_uri(request)).to eq("#{master_url_prefix}/foo/with%20spaces?environment=myenv&foo=bar")
189
180
  end
@@ -144,4 +144,23 @@ describe Puppet::Network::HTTP::Factory do
144
144
  expect(conn.local_host).to eq('127.0.0.1')
145
145
  end
146
146
  end
147
+
148
+ context 'tls' do
149
+ it "sets the minimum version to TLS 1.0", if: RUBY_VERSION.to_f >= 2.5 do
150
+ conn = create_connection(site)
151
+ expect(conn.min_version).to eq(OpenSSL::SSL::TLS1_VERSION)
152
+ end
153
+
154
+ it "defaults to ciphersuites providing 128 bits of security or greater" do
155
+ conn = create_connection(site)
156
+ expect(conn.ciphers).to eq("ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256")
157
+ end
158
+
159
+ it "can be restricted to TLSv1.3 ciphers" do
160
+ tls13_ciphers = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"
161
+ Puppet[:ciphers] = tls13_ciphers
162
+ conn = create_connection(site)
163
+ expect(conn.ciphers).to eq(tls13_ciphers)
164
+ end
165
+ end
147
166
  end
@@ -102,11 +102,6 @@ describe Puppet::Network::HTTP::Handler do
102
102
  { :status => 200 }
103
103
  end
104
104
 
105
- before do
106
- allow(handler).to receive(:check_authorization)
107
- allow(handler).to receive(:warn_if_near_expiration)
108
- end
109
-
110
105
  it "should setup a profiler when the puppet-profiling header exists" do
111
106
  request = a_request
112
107
  request[:headers][Puppet::Network::HTTP::HEADER_ENABLE_PROFILING.downcase] = "true"
@@ -240,20 +240,9 @@ describe Puppet::Parser::Compiler do
240
240
  end
241
241
 
242
242
  describe "when compiling" do
243
- def compile_methods
244
- [:set_node_parameters, :evaluate_main, :evaluate_ast_node, :evaluate_node_classes, :evaluate_generators, :fail_on_unevaluated,
245
- :finish, :store, :extract, :evaluate_relationships]
246
- end
247
-
248
- # Stub all of the main compile methods except the ones we're specifically interested in.
249
- def compile_stub(*except)
250
- (compile_methods - except).each { |m| allow(@compiler).to receive(m) }
251
- end
252
-
253
243
  it "should set node parameters as variables in the top scope" do
254
244
  params = {"a" => "b", "c" => "d"}
255
245
  allow(@node).to receive(:parameters).and_return(params)
256
- compile_stub(:set_node_parameters)
257
246
  @compiler.compile
258
247
  expect(@compiler.topscope['a']).to eq("b")
259
248
  expect(@compiler.topscope['c']).to eq("d")
@@ -262,13 +251,11 @@ describe Puppet::Parser::Compiler do
262
251
  it "should set node parameters that are of Symbol type as String variables in the top scope" do
263
252
  params = {"a" => :b}
264
253
  allow(@node).to receive(:parameters).and_return(params)
265
- compile_stub(:set_node_parameters)
266
254
  @compiler.compile
267
255
  expect(@compiler.topscope['a']).to eq("b")
268
256
  end
269
257
 
270
258
  it "should set the node's environment as a string variable in top scope" do
271
- compile_stub(:set_node_parameters)
272
259
  @node.merge({'wat' => 'this is how the sausage is made'})
273
260
  @compiler.compile
274
261
  expect(@compiler.topscope['environment']).to eq("testing")
@@ -276,7 +263,6 @@ describe Puppet::Parser::Compiler do
276
263
  end
277
264
 
278
265
  it "sets the environment based on node.environment instead of the parameters" do
279
- compile_stub(:set_node_parameters)
280
266
  @node.parameters['environment'] = "Not actually #{@node.environment.name}"
281
267
 
282
268
  @compiler.compile
@@ -286,23 +272,21 @@ describe Puppet::Parser::Compiler do
286
272
  it "should set the client and server versions on the catalog" do
287
273
  params = {"clientversion" => "2", "serverversion" => "3"}
288
274
  allow(@node).to receive(:parameters).and_return(params)
289
- compile_stub(:set_node_parameters)
290
275
  @compiler.compile
291
276
  expect(@compiler.catalog.client_version).to eq("2")
292
277
  expect(@compiler.catalog.server_version).to eq("3")
293
278
  end
294
279
 
295
280
  it "should evaluate the main class if it exists" do
296
- compile_stub(:evaluate_main)
297
281
  main_class = @known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
282
+ @compiler.topscope.source = main_class
283
+
298
284
  expect(main_class).to receive(:evaluate_code).with(be_a(Puppet::Parser::Resource))
299
- expect(@compiler.topscope).to receive(:source=).with(main_class)
300
285
 
301
286
  @compiler.compile
302
287
  end
303
288
 
304
289
  it "should create a new, empty 'main' if no main class exists" do
305
- compile_stub(:evaluate_main)
306
290
  @compiler.compile
307
291
  expect(@known_resource_types.find_hostclass("")).to be_instance_of(Puppet::Resource::Type)
308
292
  end
@@ -325,7 +309,7 @@ describe Puppet::Parser::Compiler do
325
309
  @compiler.add_collection(colls[0])
326
310
  @compiler.add_collection(colls[1])
327
311
 
328
- compile_stub(:evaluate_generators)
312
+ allow(@compiler).to receive(:fail_on_unevaluated)
329
313
  @compiler.compile
330
314
  end
331
315
 
@@ -418,22 +418,27 @@ describe Puppet::Parser::Resource do
418
418
  end
419
419
 
420
420
  describe "when merging overrides" do
421
+ def resource_type(name)
422
+ double(name, :child_of? => false)
423
+ end
424
+
421
425
  before do
422
- @source = "source1"
426
+ @source = resource_type("source1")
423
427
  @resource = mkresource :source => @source
424
428
  @override = mkresource :source => @source
425
429
  end
426
430
 
427
431
  it "should fail when the override was not created by a parent class" do
428
- @override.source = "source2"
429
- expect(@override.source).to receive(:child_of?).with("source1").and_return(false)
432
+ @override.source = resource_type("source2")
433
+ expect(@override.source).to receive(:child_of?).with(@source).and_return(false)
430
434
  expect { @resource.merge(@override) }.to raise_error(Puppet::ParseError)
431
435
  end
432
436
 
433
437
  it "should succeed when the override was created in the current scope" do
434
- @resource.source = "source3"
438
+ @source3 = resource_type("source3")
439
+ @resource.source = @source3
435
440
  @override.source = @resource.source
436
- expect(@override.source).not_to receive(:child_of?).with("source3")
441
+ expect(@override.source).not_to receive(:child_of?).with(@source3)
437
442
  params = {:a => :b, :c => :d}
438
443
  expect(@override).to receive(:parameters).and_return(params)
439
444
  expect(@resource).to receive(:override_parameter).with(:b)
@@ -442,9 +447,10 @@ describe Puppet::Parser::Resource do
442
447
  end
443
448
 
444
449
  it "should succeed when a parent class created the override" do
445
- @resource.source = "source3"
446
- @override.source = "source4"
447
- expect(@override.source).to receive(:child_of?).with("source3").and_return(true)
450
+ @source3 = resource_type("source3")
451
+ @resource.source = @source3
452
+ @override.source = resource_type("source4")
453
+ expect(@override.source).to receive(:child_of?).with(@source3).and_return(true)
448
454
  params = {:a => :b, :c => :d}
449
455
  expect(@override).to receive(:parameters).and_return(params)
450
456
  expect(@resource).to receive(:override_parameter).with(:b)
@@ -57,9 +57,10 @@ describe Puppet::Parser::TemplateWrapper do
57
57
  expect(tw.all_tags).to eq(["tag1","tag2"])
58
58
  end
59
59
 
60
- it "provides the tags defined in the current scope with #tags" do
61
- expect(scope).to receive(:tags).and_return(["tag1", "tag2"])
62
- expect(tw.tags).to eq(["tag1","tag2"])
60
+ it "raises not implemented error" do
61
+ expect {
62
+ tw.tags
63
+ }.to raise_error(NotImplementedError, /Call 'all_tags' instead/)
63
64
  end
64
65
 
65
66
  it "raises error on access to removed in-scope variables via method calls" do