puppet 6.13.0 → 6.14.0

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +7 -13
  3. data/Gemfile.lock +6 -6
  4. data/README.md +15 -22
  5. data/lib/puppet.rb +1 -1
  6. data/lib/puppet/application/agent.rb +9 -11
  7. data/lib/puppet/application/describe.rb +7 -5
  8. data/lib/puppet/application/device.rb +2 -2
  9. data/lib/puppet/application/filebucket.rb +14 -1
  10. data/lib/puppet/application/ssl.rb +1 -1
  11. data/lib/puppet/configurer.rb +30 -41
  12. data/lib/puppet/configurer/plugin_handler.rb +10 -1
  13. data/lib/puppet/defaults.rb +7 -1
  14. data/lib/puppet/face/plugin.rb +1 -1
  15. data/lib/puppet/functions/eyaml_lookup_key.rb +13 -8
  16. data/lib/puppet/http.rb +1 -0
  17. data/lib/puppet/http/client.rb +69 -34
  18. data/lib/puppet/http/resolver/server_list.rb +2 -2
  19. data/lib/puppet/http/resolver/settings.rb +1 -1
  20. data/lib/puppet/http/resolver/srv.rb +1 -1
  21. data/lib/puppet/http/response.rb +6 -1
  22. data/lib/puppet/http/service.rb +30 -11
  23. data/lib/puppet/http/service/ca.rb +8 -8
  24. data/lib/puppet/http/service/compiler.rb +41 -10
  25. data/lib/puppet/http/service/file_server.rb +40 -20
  26. data/lib/puppet/http/service/report.rb +12 -15
  27. data/lib/puppet/http/session.rb +39 -1
  28. data/lib/puppet/indirector/catalog/rest.rb +33 -0
  29. data/lib/puppet/indirector/facts/rest.rb +41 -0
  30. data/lib/puppet/indirector/file_content/rest.rb +30 -0
  31. data/lib/puppet/indirector/file_metadata/rest.rb +50 -0
  32. data/lib/puppet/indirector/node/rest.rb +23 -0
  33. data/lib/puppet/indirector/report/rest.rb +19 -0
  34. data/lib/puppet/indirector/rest.rb +6 -0
  35. data/lib/puppet/indirector/status/rest.rb +17 -0
  36. data/lib/puppet/loaders.rb +6 -0
  37. data/lib/puppet/network/http/base_pool.rb +1 -1
  38. data/lib/puppet/network/http/pool.rb +6 -1
  39. data/lib/puppet/provider/group/groupadd.rb +9 -4
  40. data/lib/puppet/runtime.rb +8 -1
  41. data/lib/puppet/settings.rb +2 -0
  42. data/lib/puppet/settings/http_extra_headers_setting.rb +25 -0
  43. data/lib/puppet/ssl/state_machine.rb +4 -0
  44. data/lib/puppet/test/test_helper.rb +3 -1
  45. data/lib/puppet/type/file.rb +13 -0
  46. data/lib/puppet/type/file/source.rb +47 -58
  47. data/lib/puppet/version.rb +1 -1
  48. data/locales/puppet.pot +167 -160
  49. data/man/man5/puppet.conf.5 +11 -3
  50. data/man/man8/puppet-agent.8 +6 -6
  51. data/man/man8/puppet-apply.8 +1 -1
  52. data/man/man8/puppet-catalog.8 +1 -1
  53. data/man/man8/puppet-config.8 +1 -1
  54. data/man/man8/puppet-describe.8 +1 -1
  55. data/man/man8/puppet-device.8 +2 -2
  56. data/man/man8/puppet-doc.8 +1 -1
  57. data/man/man8/puppet-epp.8 +1 -1
  58. data/man/man8/puppet-facts.8 +1 -1
  59. data/man/man8/puppet-filebucket.8 +17 -2
  60. data/man/man8/puppet-generate.8 +1 -1
  61. data/man/man8/puppet-help.8 +1 -1
  62. data/man/man8/puppet-key.8 +1 -1
  63. data/man/man8/puppet-lookup.8 +1 -1
  64. data/man/man8/puppet-man.8 +1 -1
  65. data/man/man8/puppet-module.8 +1 -1
  66. data/man/man8/puppet-node.8 +1 -1
  67. data/man/man8/puppet-parser.8 +1 -1
  68. data/man/man8/puppet-plugin.8 +1 -1
  69. data/man/man8/puppet-report.8 +1 -1
  70. data/man/man8/puppet-resource.8 +1 -1
  71. data/man/man8/puppet-script.8 +1 -1
  72. data/man/man8/puppet-ssl.8 +2 -2
  73. data/man/man8/puppet-status.8 +1 -1
  74. data/man/man8/puppet.8 +2 -2
  75. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +1 -67
  76. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +1 -69
  77. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +1 -69
  78. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +1 -67
  79. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +1 -65
  80. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +1 -67
  81. data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +1 -67
  82. data/spec/integration/faces/plugin_spec.rb +3 -1
  83. data/spec/integration/http/client_spec.rb +11 -0
  84. data/spec/integration/network/http_pool_spec.rb +9 -1
  85. data/spec/unit/application/describe_spec.rb +88 -50
  86. data/spec/unit/configurer/plugin_handler_spec.rb +36 -19
  87. data/spec/unit/configurer_spec.rb +16 -14
  88. data/spec/unit/face/plugin_spec.rb +12 -10
  89. data/spec/unit/functions/lookup_spec.rb +13 -0
  90. data/spec/unit/http/client_spec.rb +172 -1
  91. data/spec/unit/http/resolver_spec.rb +14 -2
  92. data/spec/unit/http/response_spec.rb +69 -0
  93. data/spec/unit/http/service/ca_spec.rb +28 -9
  94. data/spec/unit/http/service/compiler_spec.rb +151 -24
  95. data/spec/unit/http/service/file_server_spec.rb +65 -8
  96. data/spec/unit/http/service/report_spec.rb +17 -8
  97. data/spec/unit/http/service_spec.rb +92 -3
  98. data/spec/unit/http/session_spec.rb +104 -1
  99. data/spec/unit/indirector/catalog/rest_spec.rb +59 -2
  100. data/spec/unit/indirector/facts/rest_spec.rb +79 -24
  101. data/spec/unit/indirector/file_content/rest_spec.rb +53 -2
  102. data/spec/unit/indirector/file_metadata/rest_spec.rb +109 -2
  103. data/spec/unit/indirector/node/rest_spec.rb +57 -2
  104. data/spec/unit/indirector/report/rest_spec.rb +58 -51
  105. data/spec/unit/indirector/resource/ral_spec.rb +7 -8
  106. data/spec/unit/indirector/status/rest_spec.rb +43 -2
  107. data/spec/unit/network/http/pool_spec.rb +57 -11
  108. data/spec/unit/provider/group/groupadd_spec.rb +22 -8
  109. data/spec/unit/settings/autosign_setting_spec.rb +1 -1
  110. data/spec/unit/settings/http_extra_headers_spec.rb +64 -0
  111. data/spec/unit/ssl/state_machine_spec.rb +10 -0
  112. data/spec/unit/transaction_spec.rb +0 -2
  113. data/spec/unit/type/file/ensure_spec.rb +1 -2
  114. data/spec/unit/type/file/source_spec.rb +86 -35
  115. data/spec/unit/util/at_fork_spec.rb +1 -0
  116. data/spec/unit/util/pidlock_spec.rb +36 -24
  117. metadata +7 -3
  118. data/COMMITTERS.md +0 -244
@@ -53,7 +53,9 @@ describe "Puppet plugin face" do
53
53
  app = init_cli_args_and_apply_app
54
54
  expect do
55
55
  expect {
56
- app.run
56
+ Puppet.override(server_agent_version: '6.13.0') do
57
+ app.run
58
+ end
57
59
  }.to exit_with(0)
58
60
  end.to have_printed(/No plugins downloaded/)
59
61
  end
@@ -141,4 +141,15 @@ describe Puppet::HTTP::Client, unless: Puppet::Util::Platform.jruby? do
141
141
  end
142
142
  end
143
143
  end
144
+
145
+ context 'persistent connections' do
146
+ it "detects when the server has closed the connection and reconnects" do
147
+ server.start_server do |port|
148
+ uri = URI("https://127.0.0.1:#{port}")
149
+
150
+ expect(client.get(uri, ssl_context: root_context)).to be_success
151
+ expect(client.get(uri, ssl_context: root_context)).to be_success
152
+ end
153
+ end
154
+ end
144
155
  end
@@ -98,8 +98,16 @@ describe Puppet::Network::HttpPool, unless: Puppet::Util::Platform.jruby? do
98
98
  %r{certificate verify failed.* .self signed certificate in certificate chain for CN=Test CA.})
99
99
  end
100
100
  end
101
- end
102
101
 
102
+ it "detects when the server has closed the connection and reconnects" do
103
+ server.start_server do |port|
104
+ http = connection(hostname, port)
105
+
106
+ expect(http.request_get('/')).to be_a(Net::HTTPSuccess)
107
+ expect(http.request_get('/')).to be_a(Net::HTTPSuccess)
108
+ end
109
+ end
110
+ end
103
111
 
104
112
  context "when using single use HTTPS connections" do
105
113
  include_examples 'HTTPS client'
@@ -3,95 +3,133 @@ require 'spec_helper'
3
3
  require 'puppet/application/describe'
4
4
 
5
5
  describe Puppet::Application::Describe do
6
- before :each do
7
- @describe = Puppet::Application[:describe]
8
- end
6
+ let(:describe) { Puppet::Application[:describe] }
7
+
8
+ it "lists all types" do
9
+ describe.command_line.args << '--list'
9
10
 
10
- it "should declare a main command" do
11
- expect(@describe).to respond_to(:main)
11
+ expect {
12
+ describe.run
13
+ }.to output(/These are the types known to puppet:/).to_stdout
12
14
  end
13
15
 
14
- it "should declare a preinit block" do
15
- expect(@describe).to respond_to(:preinit)
16
+ it "describes a single type" do
17
+ describe.command_line.args << 'exec'
18
+
19
+ expect {
20
+ describe.run
21
+ }.to output(/exec.*====.*Executes external commands/m).to_stdout
16
22
  end
17
23
 
18
- [:providers,:list,:meta].each do |option|
19
- it "should declare handle_#{option} method" do
20
- expect(@describe).to respond_to("handle_#{option}".to_sym)
21
- end
24
+ it "describes multiple types" do
25
+ describe.command_line.args.concat(['exec', 'file'])
22
26
 
23
- it "should store argument value when calling handle_#{option}" do
24
- expect(@describe.options).to receive(:[]=).with("#{option}".to_sym, 'arg')
25
- @describe.send("handle_#{option}".to_sym, 'arg')
26
- end
27
+ expect {
28
+ describe.run
29
+ }.to output(/Executes external commands.*Manages files, including their content, ownership, and permissions./m).to_stdout
27
30
  end
28
31
 
32
+ it "describes parameters for the type by default" do
33
+ describe.command_line.args << 'exec'
29
34
 
30
- describe "in preinit" do
31
- it "should set options[:parameters] to true" do
32
- @describe.preinit
35
+ expect {
36
+ describe.run
37
+ }.to output(/Parameters\n----------/m).to_stdout
38
+ end
33
39
 
34
- expect(@describe.options[:parameters]).to be_truthy
35
- end
40
+ it "lists parameter names, but excludes description in short mode" do
41
+ describe.command_line.args.concat(['exec', '-s'])
42
+
43
+ expect {
44
+ describe.run
45
+ }.to output(/Parameters.*command, creates, cwd/m).to_stdout
36
46
  end
37
47
 
38
- describe "when handling parameters" do
39
- it "should set options[:parameters] to false" do
40
- @describe.handle_short(nil)
48
+ it "outputs providers for the type" do
49
+ describe.command_line.args.concat(['exec', '--providers'])
41
50
 
42
- expect(@describe.options[:parameters]).to be_falsey
43
- end
51
+ expect {
52
+ describe.run
53
+ }.to output(/Providers.*#{Regexp.escape('**posix**')}.*#{Regexp.escape('**windows**')}/m).to_stdout
44
54
  end
45
55
 
46
- describe "during setup" do
47
- it "should collect arguments in options[:types]" do
48
- allow(@describe.command_line).to receive(:args).and_return(['1','2'])
49
- @describe.setup
56
+ it "lists metaparameters for a type" do
57
+ describe.command_line.args.concat(['exec', '--meta'])
50
58
 
51
- expect(@describe.options[:types]).to eq(['1','2'])
52
- end
59
+ expect {
60
+ describe.run
61
+ }.to output(/Meta Parameters.*#{Regexp.escape('**notify**')}/m).to_stdout
53
62
  end
54
63
 
55
- describe "when running" do
64
+ it "outputs no documentation if the summary is missing" do
65
+ Puppet::Type.newtype(:describe_test) {}
66
+
67
+ describe.command_line.args << '--list'
68
+ expect {
69
+ describe.run
70
+ }.to output(/#{Regexp.escape("describe_test - .. no documentation ..")}/).to_stdout
71
+ end
56
72
 
57
- before :each do
58
- @typedoc = double('type_doc')
59
- allow(TypeDoc).to receive(:new).and_return(@typedoc)
73
+ it "outputs the first short sentence ending in a dot" do
74
+ Puppet::Type.newtype(:describe_test) do
75
+ @doc = "ends in a dot."
60
76
  end
61
77
 
62
- it "should call list_types if options list is set" do
63
- @describe.options[:list] = true
78
+ describe.command_line.args << '--list'
79
+ expect {
80
+ describe.run
81
+ }.to output(/#{Regexp.escape("describe_test - ends in a dot\n")}/).to_stdout
82
+ end
64
83
 
65
- expect(@typedoc).to receive(:list_types)
84
+ it "outputs the first short sentence missing a dot" do
85
+ Puppet::Type.newtype(:describe_test) do
86
+ @doc = "missing a dot"
87
+ end
66
88
 
67
- @describe.run_command
89
+ describe.command_line.args << '--list'
90
+ expect {
91
+ describe.run
92
+ }.to output(/describe_test - missing a dot\n/).to_stdout
93
+ end
94
+
95
+ it "truncates long summaries ending in a dot" do
96
+ Puppet::Type.newtype(:describe_test) do
97
+ @doc = "This sentence is more than 45 characters and ends in a dot."
68
98
  end
69
99
 
70
- it "should call format_type for each given types" do
71
- @describe.options[:list] = false
72
- @describe.options[:types] = ['type']
100
+ describe.command_line.args << '--list'
101
+ expect {
102
+ describe.run
103
+ }.to output(/#{Regexp.escape("describe_test - This sentence is more than 45 characters and ...")}/).to_stdout
104
+ end
73
105
 
74
- expect(@typedoc).to receive(:format_type).with('type', @describe.options)
75
- @describe.run_command
106
+ it "truncates long summaries missing a dot" do
107
+ Puppet::Type.newtype(:describe_test) do
108
+ @doc = "This sentence is more than 45 characters and is missing a dot"
76
109
  end
110
+
111
+ describe.command_line.args << '--list'
112
+ expect {
113
+ describe.run
114
+ }.to output(/#{Regexp.escape("describe_test - This sentence is more than 45 characters and ...")}/).to_stdout
77
115
  end
78
116
 
79
- it "should format text with long non-space runs without garbling" do
80
- @f = Formatter.new(76)
117
+ it "formats text with long non-space runs without garbling" do
118
+ f = Formatter.new(76)
81
119
 
82
- @teststring = <<TESTSTRING
120
+ teststring = <<TESTSTRING
83
121
  . 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 nick@magpie.puppetlabs.lan
84
122
  **this part should not repeat!**
85
123
  TESTSTRING
86
124
 
87
- @expected_result = <<EXPECTED
125
+ expected_result = <<EXPECTED
88
126
  .
89
127
  1234567890123456789012345678901234567890123456789012345678901234567890123456
90
128
  7890123456789012345678901234567890 nick@magpie.puppetlabs.lan
91
129
  **this part should not repeat!**
92
130
  EXPECTED
93
131
 
94
- result = @f.wrap(@teststring, {:indent => 0, :scrub => true})
95
- expect(result).to eql(@expected_result)
132
+ result = f.wrap(teststring, {:indent => 0, :scrub => true})
133
+ expect(result).to eql(expected_result)
96
134
  end
97
135
  end
@@ -6,13 +6,17 @@ describe Puppet::Configurer::PluginHandler do
6
6
  let(:pluginhandler) { Puppet::Configurer::PluginHandler.new() }
7
7
  let(:environment) { Puppet::Node::Environment.create(:myenv, []) }
8
8
 
9
+ before :each do
10
+ # PluginHandler#load_plugin has an extra-strong rescue clause
11
+ # this mock is to make sure that we don't silently ignore errors
12
+ expect(Puppet).not_to receive(:err)
13
+ end
14
+
9
15
  context "server agent version is 5.3.4" do
10
- before :each do
11
- # PluginHandler#load_plugin has an extra-strong rescue clause
12
- # this mock is to make sure that we don't silently ignore errors
13
- expect(Puppet).not_to receive(:err)
14
- # Server_agent version needs to be at 5.3.4 in order to mount locales
15
- Puppet.push_context({:server_agent_version => "5.3.4"})
16
+ around do |example|
17
+ Puppet.override(server_agent_version: "5.3.4") do
18
+ example.run
19
+ end
16
20
  end
17
21
 
18
22
  it "downloads plugins, facts, and locales" do
@@ -43,12 +47,10 @@ describe Puppet::Configurer::PluginHandler do
43
47
  end
44
48
 
45
49
  context "server agent version is 5.3.3" do
46
- before :each do
47
- # PluginHandler#load_plugin has an extra-strong rescue clause
48
- # this mock is to make sure that we don't silently ignore errors
49
- expect(Puppet).not_to receive(:err)
50
- # Server_agent version needs to be at 5.3.4 in order to mount locales
51
- Puppet.push_context({:server_agent_version => "5.3.3"})
50
+ around do |example|
51
+ Puppet.override(server_agent_version: "5.3.3") do
52
+ example.run
53
+ end
52
54
  end
53
55
 
54
56
  it "returns downloaded plugin, fact, but not locale filenames" do
@@ -69,15 +71,30 @@ describe Puppet::Configurer::PluginHandler do
69
71
  end
70
72
 
71
73
  context "blank server agent version" do
72
- before :each do
73
- # PluginHandler#load_plugin has an extra-strong rescue clause
74
- # this mock is to make sure that we don't silently ignore errors
75
- expect(Puppet).not_to receive(:err)
76
- # Server_agent version needs to be at 5.3.4 in order to mount locales
77
- # A blank version will default to 0.0
78
- Puppet.push_context({:server_agent_version => ""})
74
+ around do |example|
75
+ Puppet.override(server_agent_version: "") do
76
+ example.run
77
+ end
78
+ end
79
+
80
+ it "returns downloaded plugin, fact, but not locale filenames" do
81
+ times_called = 0
82
+ allow_any_instance_of(Puppet::Configurer::Downloader).to receive(:evaluate) do
83
+ times_called += 1
84
+
85
+ if times_called == 1
86
+ %w[/a]
87
+ else
88
+ %w[/b]
89
+ end
90
+ end
91
+
92
+ expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b])
93
+ expect(times_called).to eq(2)
79
94
  end
95
+ end
80
96
 
97
+ context "nil server agent version" do
81
98
  it "returns downloaded plugin, fact, but not locale filenames" do
82
99
  times_called = 0
83
100
  allow_any_instance_of(Puppet::Configurer::Downloader).to receive(:evaluate) do
@@ -10,11 +10,12 @@ describe Puppet::Configurer do
10
10
  catalog.add_resource(resource)
11
11
  end
12
12
 
13
+ let(:node_name) { Puppet[:node_name_value] }
13
14
  let(:configurer) { Puppet::Configurer.new }
14
15
  let(:report) { Puppet::Transaction::Report.new }
15
- let(:catalog) { Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym)) }
16
+ let(:catalog) { Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote(Puppet[:environment].to_sym)) }
16
17
  let(:resource) { Puppet::Resource.new(:notice, 'a') }
17
- let(:facts) { Puppet::Node::Facts.new(Puppet[:node_name_value]) }
18
+ let(:facts) { Puppet::Node::Facts.new(node_name) }
18
19
 
19
20
  describe "when executing a pre-run hook" do
20
21
  it "should do nothing if the hook is set to an empty string" do
@@ -101,6 +102,7 @@ describe Puppet::Configurer do
101
102
  end
102
103
 
103
104
  it "should respect node_name_fact when setting the host on a report" do
105
+ Puppet[:node_name_value] = nil
104
106
  Puppet[:node_name_fact] = 'my_name_fact'
105
107
  facts.values = {'my_name_fact' => 'node_name_from_fact'}
106
108
  Puppet::Node::Facts.indirection.save(facts)
@@ -316,7 +318,7 @@ describe Puppet::Configurer do
316
318
  end
317
319
 
318
320
  it "should refetch the catalog if the server specifies a new environment in the catalog" do
319
- catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
321
+ catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote('second_env'))
320
322
  expect(configurer).to receive(:retrieve_catalog).and_return(catalog).twice
321
323
 
322
324
  configurer.run
@@ -611,7 +613,7 @@ describe Puppet::Configurer do
611
613
  end
612
614
 
613
615
  it "should set its cached_catalog_status to 'explicitly requested' if the cached catalog is from a different environment" do
614
- cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
616
+ cached_catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote('second_env'))
615
617
  expects_cached_catalog_only(cached_catalog)
616
618
 
617
619
  options = {}
@@ -644,7 +646,7 @@ describe Puppet::Configurer do
644
646
  end
645
647
 
646
648
  it "should return the cached catalog when the environment doesn't match" do
647
- cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
649
+ cached_catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote('second_env'))
648
650
  expects_cached_catalog_only(cached_catalog)
649
651
 
650
652
  allow(Puppet).to receive(:info)
@@ -702,7 +704,7 @@ describe Puppet::Configurer do
702
704
  Puppet[:environment] = 'second_env'
703
705
  configurer = Puppet::Configurer.new
704
706
 
705
- catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote("production"))
707
+ catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote("production"))
706
708
  expects_new_catalog_only(catalog)
707
709
 
708
710
  expect(Puppet).to receive(:err).with("Not using catalog because its environment 'production' does not match agent specified environment 'second_env' and strict_environment_mode is set")
@@ -724,7 +726,7 @@ describe Puppet::Configurer do
724
726
  Puppet[:environment] = 'second_env'
725
727
  configurer = Puppet::Configurer.new
726
728
 
727
- catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote("production"))
729
+ catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote("production"))
728
730
  expects_cached_catalog_only(catalog)
729
731
 
730
732
  expect(Puppet).to receive(:err).with("Not using catalog because its environment 'production' does not match agent specified environment 'second_env' and strict_environment_mode is set")
@@ -824,7 +826,7 @@ describe Puppet::Configurer do
824
826
  end
825
827
 
826
828
  it "should return nil if its cached catalog environment doesn't match server-specified environment" do
827
- cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
829
+ cached_catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote('second_env'))
828
830
 
829
831
  expects_fallback_to_cached_catalog(cached_catalog)
830
832
 
@@ -834,7 +836,7 @@ describe Puppet::Configurer do
834
836
  end
835
837
 
836
838
  it "should set its cached_catalog_status to 'not_used' if the cached catalog environment doesn't match server-specified environment" do
837
- cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
839
+ cached_catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote('second_env'))
838
840
 
839
841
  expects_fallback_to_cached_catalog(cached_catalog)
840
842
 
@@ -854,7 +856,7 @@ describe Puppet::Configurer do
854
856
  it "should not update the cached catalog in noop mode" do
855
857
  Puppet[:noop] = true
856
858
 
857
- stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
859
+ stub_request(:post, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
858
860
 
859
861
  Puppet::Resource::Catalog.indirection.cache_class = :json
860
862
  path = Puppet::Resource::Catalog.indirection.cache.path(catalog.name)
@@ -868,7 +870,7 @@ describe Puppet::Configurer do
868
870
  Puppet[:noop] = false
869
871
  Puppet[:log_level] = 'info'
870
872
 
871
- stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
873
+ stub_request(:post, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
872
874
 
873
875
  Puppet::Resource::Catalog.indirection.cache_class = :json
874
876
  cache_path = Puppet::Resource::Catalog.indirection.cache.path(Puppet[:node_name_value])
@@ -881,7 +883,7 @@ describe Puppet::Configurer do
881
883
  end
882
884
 
883
885
  it "successfully applies the catalog without a cache" do
884
- stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
886
+ stub_request(:post, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
885
887
 
886
888
  Puppet::Resource::Catalog.indirection.cache_class = nil
887
889
 
@@ -996,7 +998,7 @@ describe Puppet::Configurer do
996
998
 
997
999
  it "should not failover during an apply run" do
998
1000
  Puppet.settings[:server_list] = ["myserver:123"]
999
- catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
1001
+ catalog = Puppet::Resource::Catalog.new(node_name, Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
1000
1002
  configurer.run(catalog: catalog)
1001
1003
  end
1002
1004
 
@@ -1041,7 +1043,7 @@ describe Puppet::Configurer do
1041
1043
  Puppet::Resource::Catalog.indirection.terminus_class = :rest
1042
1044
 
1043
1045
  stub_request(:get, 'https://myserver:123/status/v1/simple/master').to_return(status: 200)
1044
- stub_request(:get, %r{https://myserver:123/puppet/v3/catalog}).to_return(status: 200)
1046
+ stub_request(:post, %r{https://myserver:123/puppet/v3/catalog}).to_return(status: 200)
1045
1047
  node_request = stub_request(:get, %r{https://myserver:123/puppet/v3/node/}).to_return(status: 200)
1046
1048
 
1047
1049
  configurer.run
@@ -10,9 +10,10 @@ describe Puppet::Face[:plugin, :current] do
10
10
  end
11
11
 
12
12
  context "download" do
13
- before :each do
14
- #Server_agent version needs to be at 5.3.4 in order to mount locales
15
- Puppet.push_context({:server_agent_version => "5.3.4"})
13
+ around do |example|
14
+ Puppet.override(server_agent_version: "5.3.4") do
15
+ example.run
16
+ end
16
17
  end
17
18
 
18
19
  it "downloads plugins, external facts, and locales" do
@@ -61,9 +62,10 @@ describe Puppet::Face[:plugin, :current] do
61
62
  end
62
63
 
63
64
  context "download when server_agent_version is 5.3.3" do
64
- before :each do
65
- #Server_agent version needs to be at 5.3.4 in order to mount locales
66
- Puppet.push_context({:server_agent_version => "5.3.3"})
65
+ around do |example|
66
+ Puppet.override(server_agent_version: "5.3.3") do
67
+ example.run
68
+ end
67
69
  end
68
70
 
69
71
  it "downloads plugins, and external facts, but not locales" do
@@ -87,10 +89,10 @@ describe Puppet::Face[:plugin, :current] do
87
89
  end
88
90
 
89
91
  context "download when server_agent_version is blank" do
90
- before :each do
91
- #Server_agent version needs to be at 5.3.4 in order to mount locales
92
- #A blank version will default to 0.0
93
- Puppet.push_context({:server_agent_version => ""})
92
+ around do |example|
93
+ Puppet.override(server_agent_version: "") do
94
+ example.run
95
+ end
94
96
  end
95
97
 
96
98
  it "downloads plugins, and external facts, but not locales" do