puppet 6.15.0-x64-mingw32 → 6.16.0-x64-mingw32

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

Potentially problematic release.


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

Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -7
  3. data/Gemfile.lock +17 -14
  4. data/lib/puppet.rb +32 -8
  5. data/lib/puppet/agent.rb +18 -4
  6. data/lib/puppet/application/agent.rb +1 -2
  7. data/lib/puppet/application/device.rb +1 -1
  8. data/lib/puppet/application/plugin.rb +1 -0
  9. data/lib/puppet/application/ssl.rb +1 -1
  10. data/lib/puppet/configurer.rb +2 -2
  11. data/lib/puppet/context/trusted_information.rb +14 -8
  12. data/lib/puppet/daemon.rb +13 -27
  13. data/lib/puppet/defaults.rb +19 -0
  14. data/lib/puppet/face/facts.rb +1 -1
  15. data/lib/puppet/face/help.rb +29 -3
  16. data/lib/puppet/face/module/search.rb +5 -0
  17. data/lib/puppet/face/plugin.rb +1 -1
  18. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  19. data/lib/puppet/file_system/uniquefile.rb +4 -0
  20. data/lib/puppet/forge/repository.rb +7 -6
  21. data/lib/puppet/functions/filter.rb +1 -0
  22. data/lib/puppet/http/client.rb +22 -11
  23. data/lib/puppet/http/external_client.rb +0 -6
  24. data/lib/puppet/indirector/file_content/http.rb +5 -0
  25. data/lib/puppet/indirector/file_metadata/http.rb +4 -4
  26. data/lib/puppet/indirector/rest.rb +7 -1
  27. data/lib/puppet/network/http/compression.rb +7 -0
  28. data/lib/puppet/network/http/connection.rb +2 -0
  29. data/lib/puppet/network/http/connection_adapter.rb +182 -0
  30. data/lib/puppet/network/http/nocache_pool.rb +1 -0
  31. data/lib/puppet/network/http_pool.rb +2 -2
  32. data/lib/puppet/pal/catalog_compiler.rb +5 -0
  33. data/lib/puppet/pal/pal_impl.rb +4 -1
  34. data/lib/puppet/parser/compiler.rb +28 -25
  35. data/lib/puppet/parser/functions/filter.rb +1 -0
  36. data/lib/puppet/provider/package/aix.rb +17 -2
  37. data/lib/puppet/provider/package/apt.rb +4 -1
  38. data/lib/puppet/provider/package/dnfmodule.rb +24 -4
  39. data/lib/puppet/provider/package/pip.rb +60 -37
  40. data/lib/puppet/provider/package/portage.rb +2 -2
  41. data/lib/puppet/provider/package/yum.rb +7 -0
  42. data/lib/puppet/provider/package/zypper.rb +59 -1
  43. data/lib/puppet/provider/service/systemd.rb +21 -4
  44. data/lib/puppet/provider/user/useradd.rb +5 -1
  45. data/lib/puppet/reports/http.rb +5 -3
  46. data/lib/puppet/runtime.rb +25 -2
  47. data/lib/puppet/ssl/state_machine.rb +33 -8
  48. data/lib/puppet/ssl/verifier_adapter.rb +9 -1
  49. data/lib/puppet/test/test_helper.rb +1 -1
  50. data/lib/puppet/type/file/source.rb +1 -1
  51. data/lib/puppet/type/package.rb +16 -1
  52. data/lib/puppet/type/service.rb +6 -8
  53. data/lib/puppet/type/user.rb +1 -7
  54. data/lib/puppet/util/autoload.rb +1 -18
  55. data/lib/puppet/util/log/destinations.rb +1 -10
  56. data/lib/puppet/util/package/version/range.rb +4 -1
  57. data/lib/puppet/util/package/version/range/eq.rb +14 -0
  58. data/lib/puppet/version.rb +1 -1
  59. data/locales/puppet.pot +191 -111
  60. data/man/man5/puppet.conf.5 +21 -2
  61. data/man/man8/puppet-agent.8 +1 -1
  62. data/man/man8/puppet-apply.8 +1 -1
  63. data/man/man8/puppet-catalog.8 +1 -1
  64. data/man/man8/puppet-config.8 +1 -1
  65. data/man/man8/puppet-describe.8 +1 -1
  66. data/man/man8/puppet-device.8 +1 -1
  67. data/man/man8/puppet-doc.8 +1 -1
  68. data/man/man8/puppet-epp.8 +1 -1
  69. data/man/man8/puppet-facts.8 +1 -1
  70. data/man/man8/puppet-filebucket.8 +1 -1
  71. data/man/man8/puppet-generate.8 +1 -1
  72. data/man/man8/puppet-help.8 +6 -3
  73. data/man/man8/puppet-key.8 +1 -1
  74. data/man/man8/puppet-lookup.8 +1 -1
  75. data/man/man8/puppet-man.8 +1 -1
  76. data/man/man8/puppet-module.8 +4 -1
  77. data/man/man8/puppet-node.8 +1 -1
  78. data/man/man8/puppet-parser.8 +1 -1
  79. data/man/man8/puppet-plugin.8 +1 -1
  80. data/man/man8/puppet-report.8 +1 -1
  81. data/man/man8/puppet-resource.8 +1 -1
  82. data/man/man8/puppet-script.8 +1 -1
  83. data/man/man8/puppet-ssl.8 +1 -1
  84. data/man/man8/puppet-status.8 +1 -1
  85. data/man/man8/puppet.8 +2 -2
  86. data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-enabled.txt → dnf-module-list.txt} +6 -0
  87. data/spec/fixtures/unit/provider/package/zypper/zypper-search-uninstalled.out +13 -0
  88. data/spec/integration/application/agent_spec.rb +66 -1
  89. data/spec/integration/application/plugin_spec.rb +23 -0
  90. data/spec/integration/http/client_spec.rb +6 -1
  91. data/spec/integration/network/http_pool_spec.rb +56 -0
  92. data/spec/integration/util/windows/adsi_spec.rb +5 -0
  93. data/spec/lib/puppet_spec/https.rb +6 -0
  94. data/spec/unit/agent_spec.rb +47 -1
  95. data/spec/unit/application/agent_spec.rb +4 -4
  96. data/spec/unit/context/trusted_information_spec.rb +17 -0
  97. data/spec/unit/daemon_spec.rb +5 -64
  98. data/spec/unit/face/module/search_spec.rb +17 -0
  99. data/spec/unit/file_system/uniquefile_spec.rb +11 -0
  100. data/spec/unit/http/client_spec.rb +10 -10
  101. data/spec/unit/http/external_client_spec.rb +9 -9
  102. data/spec/unit/indirector/catalog/compiler_spec.rb +1 -0
  103. data/spec/unit/indirector/file_metadata/http_spec.rb +167 -0
  104. data/spec/unit/indirector/file_metadata/rest_spec.rb +15 -14
  105. data/spec/unit/indirector/rest_spec.rb +13 -0
  106. data/spec/unit/network/http/connection_spec.rb +542 -190
  107. data/spec/unit/network/http/nocache_pool_spec.rb +22 -0
  108. data/spec/unit/network/http_pool_spec.rb +63 -57
  109. data/spec/unit/network/http_spec.rb +1 -1
  110. data/spec/unit/provider/package/aix_spec.rb +29 -0
  111. data/spec/unit/provider/package/dnfmodule_spec.rb +25 -5
  112. data/spec/unit/provider/package/pip_spec.rb +42 -16
  113. data/spec/unit/provider/package/portage_spec.rb +5 -0
  114. data/spec/unit/provider/package/yum_spec.rb +16 -8
  115. data/spec/unit/provider/package/zypper_spec.rb +84 -0
  116. data/spec/unit/provider/service/init_spec.rb +1 -0
  117. data/spec/unit/provider/service/openbsd_spec.rb +9 -0
  118. data/spec/unit/provider/service/openwrt_spec.rb +1 -0
  119. data/spec/unit/provider/service/redhat_spec.rb +9 -0
  120. data/spec/unit/provider/service/systemd_spec.rb +84 -13
  121. data/spec/unit/provider/user/useradd_spec.rb +8 -0
  122. data/spec/unit/puppet_pal_catalog_spec.rb +43 -0
  123. data/spec/unit/puppet_spec.rb +33 -0
  124. data/spec/unit/reports/http_spec.rb +1 -1
  125. data/spec/unit/ssl/state_machine_spec.rb +52 -8
  126. data/spec/unit/type/service_spec.rb +9 -8
  127. data/spec/unit/type/user_spec.rb +1 -1
  128. data/spec/unit/util/autoload_spec.rb +2 -1
  129. data/spec/unit/util/log/destinations_spec.rb +1 -29
  130. data/spec/unit/util/package/version/range_spec.rb +22 -1
  131. data/tasks/manpages.rake +5 -35
  132. metadata +10 -4
@@ -132,7 +132,12 @@ describe Puppet::HTTP::Client, unless: Puppet::Util::Platform.jruby? do
132
132
  it "detects when the server has closed the connection and reconnects" do
133
133
  Puppet[:http_debug] = true
134
134
 
135
- https_server.start_server do |port|
135
+ # advertise that we support keep-alive, but we don't really
136
+ response_proc = -> (req, res) {
137
+ res['Connection'] = 'Keep-Alive'
138
+ }
139
+
140
+ https_server.start_server(response_proc: response_proc) do |port|
136
141
  uri = URI("https://127.0.0.1:#{port}")
137
142
  kwargs = {headers: {'Content-Type' => 'text/plain'}, options: {ssl_context: root_context}}
138
143
 
@@ -116,6 +116,62 @@ describe Puppet::Network::HttpPool, unless: Puppet::Util::Platform.jruby? do
116
116
 
117
117
  include_examples 'HTTPS client'
118
118
  end
119
+
120
+ shared_examples_for "an HttpPool connection" do |klass, legacy_api|
121
+ before :each do
122
+ Puppet::Network::HttpPool.http_client_class = klass
123
+ end
124
+
125
+ it "connects using the scheme, host and port from the http instance" do
126
+ request_line = nil
127
+
128
+ response_proc = -> (req, res) {
129
+ request_line = req.request_line
130
+ }
131
+
132
+ server.start_server(response_proc: response_proc) do |port|
133
+ http = Puppet::Network::HttpPool.http_instance(hostname, port, true)
134
+ path = "http://bogus.example.com:443/foo"
135
+ http.get(path)
136
+
137
+ if legacy_api
138
+ # The old API passed the bogus hostname which didn't match
139
+ # the host we connected to.
140
+ expect(request_line).to eq("GET http://bogus.example.com:443/foo HTTP/1.1\r\n")
141
+ else
142
+ expect(request_line).to eq("GET /foo HTTP/1.1\r\n")
143
+ end
144
+ end
145
+ end
146
+
147
+ it "requires the caller to URL encode the path" do
148
+ request_line = nil
149
+
150
+ response_proc = -> (req, res) {
151
+ request_line = req.request_line
152
+ }
153
+
154
+ server.start_server(response_proc: response_proc) do |port|
155
+ http = Puppet::Network::HttpPool.http_instance(hostname, port, true)
156
+ encoded_url = "https://#{hostname}:#{port}/foo%20bar"
157
+ http.get(encoded_url)
158
+
159
+ if legacy_api
160
+ expect(request_line).to eq("GET #{encoded_url} HTTP/1.1\r\n")
161
+ else
162
+ expect(request_line).to eq("GET /foo%20bar HTTP/1.1\r\n")
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ describe Puppet::Network::HTTP::Connection do
169
+ it_behaves_like "an HttpPool connection", described_class, true
170
+ end
171
+
172
+ describe Puppet::Network::HTTP::ConnectionAdapter do
173
+ it_behaves_like "an HttpPool connection", described_class, false
174
+ end
119
175
  end
120
176
 
121
177
  context "when calling HttpPool.connection method" do
@@ -82,6 +82,9 @@ describe Puppet::Util::Windows::ADSI::Group,
82
82
  it 'should return a list of members resolvable with Puppet::Util::Windows::ADSI::Group.name_sid_hash' do
83
83
  temp_groupname = "g#{SecureRandom.uuid}"
84
84
  temp_username = "u#{SecureRandom.uuid}"[0..12]
85
+ # From https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements
86
+ specials = "~!@#$%^&*_-+=`|\(){}[]:;\"'<>,.?/"
87
+ temp_password = "p#{SecureRandom.uuid[0..7]}-#{SecureRandom.uuid.upcase[0..7]}-#{specials[rand(specials.length)]}"
85
88
 
86
89
  # select a virtual account that requires an authority to be able to resolve to SID
87
90
  # the Dhcp service is chosen for no particular reason aside from it's a service available on all Windows versions
@@ -110,6 +113,8 @@ describe Puppet::Util::Windows::ADSI::Group,
110
113
  begin
111
114
  # :SidTypeUser as user on localhost, can be resolved with or without authority prefix
112
115
  user = Puppet::Util::Windows::ADSI::User.create(temp_username)
116
+ # appveyor sometimes requires a password
117
+ user.password = temp_password
113
118
  user.commit()
114
119
  users.push({ :sid => user.sid.sid, :name => Puppet::Util::Windows::ADSI.computer_name + '\\' + temp_username })
115
120
 
@@ -24,6 +24,12 @@ class PuppetSpec::HTTPSServer
24
24
  res = WEBrick::HTTPResponse.new(@config)
25
25
  res.status = 200
26
26
  res.body = 'OK'
27
+ # The server explicitly closes the connection after handling it,
28
+ # so explicitly tell the client we're not going to keep it open.
29
+ # Without this, ruby will add `Connection: Keep-Alive`, which
30
+ # confuses the client when it tries to reuse the half-closed
31
+ # connection.
32
+ res['Connection'] = 'close'
27
33
  response_proc.call(req, res) if response_proc
28
34
 
29
35
  res.send_response(ssl)
@@ -179,6 +179,52 @@ describe Puppet::Agent do
179
179
  expect(@agent.run).to eq(:result)
180
180
  end
181
181
 
182
+ describe "and a puppet agent is already running" do
183
+ before(:each) do
184
+ allow_any_instance_of(Object).to receive(:sleep)
185
+ lockfile = double('lockfile')
186
+ expect(@agent).to receive(:lockfile).and_return(lockfile).at_least(:once)
187
+ # so the lock method raises Puppet::LockError
188
+ allow(lockfile).to receive(:lock).and_return(false)
189
+ end
190
+
191
+ it "should notify that a run is already in progres" do
192
+ client = AgentTestClient.new
193
+ expect(AgentTestClient).to receive(:new).and_return(client)
194
+ expect(Puppet).to receive(:notice).with(/Run of .* already in progress; skipping .* exists/)
195
+ @agent.run
196
+ end
197
+
198
+ it "should inform that a run is already in progres and try to run every X seconds if waitforlock is used" do
199
+ # so the locked file exists
200
+ allow(File).to receive(:file?).and_return(true)
201
+ # so we don't have to wait again for the run to exit (default maxwaitforcert is 60)
202
+ # first 0 is to get the time, second 0 is to inform user, then 1000 so the time expires
203
+ allow(Time).to receive(:now).and_return(0, 0, 1000)
204
+ allow(Puppet).to receive(:info)
205
+ client = AgentTestClient.new
206
+ expect(AgentTestClient).to receive(:new).and_return(client)
207
+
208
+ Puppet[:waitforlock] = 1
209
+ Puppet[:maxwaitforlock] = 2
210
+ expect(Puppet).to receive(:info).with(/Another puppet instance is already running; --waitforlock flag used, waiting for running instance to finish./)
211
+ expect(Puppet).to receive(:info).with(/Will try again in #{Puppet[:waitforlock]} seconds./)
212
+ @agent.run
213
+ end
214
+
215
+ it "should notify that the run is exiting if waitforlock is used and maxwaitforlock is exceeded" do
216
+ # so we don't have to wait again for the run to exit (default maxwaitforcert is 60)
217
+ # first 0 is to get the time, then 1000 so that the time expires
218
+ allow(Time).to receive(:now).and_return(0, 1000)
219
+ client = AgentTestClient.new
220
+ expect(AgentTestClient).to receive(:new).and_return(client)
221
+
222
+ Puppet[:waitforlock] = 1
223
+ expect(Puppet).to receive(:notice).with(/Exiting now because the maxwaitforlock timeout has been exceeded./)
224
+ @agent.run
225
+ end
226
+ end
227
+
182
228
  describe "when should_fork is true", :if => Puppet.features.posix? && RUBY_PLATFORM != 'java' do
183
229
  before do
184
230
  @agent = Puppet::Agent.new(AgentTestClient, true)
@@ -291,7 +337,7 @@ describe Puppet::Agent do
291
337
  expect(client).not_to receive(:handling)
292
338
  expect(Puppet).to receive(:log_exception).with(be_an_instance_of(Puppet::Agent::RunTimeoutError), anything)
293
339
 
294
- expect(@agent.run).to eq(1)
340
+ expect(@agent.run).to eq(nil)
295
341
  end
296
342
  end
297
343
  end
@@ -12,16 +12,16 @@ describe Puppet::Application::Agent do
12
12
  before :each do
13
13
  @puppetd = Puppet::Application[:agent]
14
14
 
15
- @daemon = Puppet::Daemon.new(nil)
15
+ @agent = double('agent')
16
+ allow(Puppet::Agent).to receive(:new).and_return(@agent)
17
+
18
+ @daemon = Puppet::Daemon.new(@agent, nil)
16
19
  allow(@daemon).to receive(:daemonize)
17
20
  allow(@daemon).to receive(:start)
18
21
  allow(@daemon).to receive(:stop)
19
22
  allow(Puppet::Daemon).to receive(:new).and_return(@daemon)
20
23
  Puppet[:daemonize] = false
21
24
 
22
- @agent = double('agent')
23
- allow(Puppet::Agent).to receive(:new).and_return(@agent)
24
-
25
25
  @puppetd.preinit
26
26
  allow(Puppet::Util::Log).to receive(:newdestination)
27
27
 
@@ -90,6 +90,23 @@ describe Puppet::Context::TrustedInformation, :unless => RUBY_PLATFORM == 'java'
90
90
 
91
91
  expect(trusted.external).to eq(external_data)
92
92
  end
93
+
94
+ it 'does not run the trusted external command when creating a trusted context' do
95
+ Puppet[:trusted_external_command] = '/usr/bin/generate_data.sh'
96
+
97
+ expect(Puppet::Util::Execution).to receive(:execute).never
98
+ Puppet::Context::TrustedInformation.remote(true, 'cert name', cert)
99
+ end
100
+
101
+ it 'only runs the trusted external command the first time it is invoked' do
102
+ Puppet[:trusted_external_command] = '/usr/bin/generate_data.sh'
103
+
104
+ expect(Puppet::Util::Execution).to receive(:execute).with(['/usr/bin/generate_data.sh', 'cert name'], anything).and_return(JSON.dump(external_data)).once
105
+
106
+ trusted = Puppet::Context::TrustedInformation.remote(true, 'cert name', cert)
107
+ trusted.external
108
+ trusted.external
109
+ end
93
110
  end
94
111
 
95
112
  context "when local" do
@@ -32,13 +32,17 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
32
32
  let(:pidfile) { double("PidFile", :lock => true, :unlock => true, :file_path => 'fake.pid') }
33
33
  let(:scheduler) { RecordingScheduler.new }
34
34
 
35
- let(:daemon) { Puppet::Daemon.new(pidfile, scheduler) }
35
+ let(:daemon) { Puppet::Daemon.new(agent, pidfile, scheduler) }
36
36
 
37
37
  before(:each) do
38
38
  allow(Signal).to receive(:trap)
39
39
  allow(daemon).to receive(:close_streams).and_return(nil)
40
40
  end
41
41
 
42
+ it "should fail when no agent is provided" do
43
+ expect { Puppet::Daemon.new(nil, pidfile, scheduler) }.to raise_error(Puppet::DevError)
44
+ end
45
+
42
46
  it "should reopen the Log logs when told to reopen logs" do
43
47
  expect(Puppet::Util::Log).to receive(:reopen)
44
48
  daemon.reopen_logs
@@ -72,65 +76,21 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
72
76
  allow(daemon).to receive(:set_signal_traps)
73
77
  end
74
78
 
75
- it "should fail if it has neither agent nor server" do
76
- expect { daemon.start }.to raise_error(Puppet::DevError)
77
- end
78
-
79
79
  it "should create its pidfile" do
80
80
  expect(pidfile).to receive(:lock).and_return(true)
81
-
82
- daemon.agent = agent
83
81
  daemon.start
84
82
  end
85
83
 
86
84
  it "should fail if it cannot lock" do
87
85
  expect(pidfile).to receive(:lock).and_return(false)
88
- daemon.agent = agent
89
-
90
86
  expect { daemon.start }.to raise_error(RuntimeError, "Could not create PID file: #{pidfile.file_path}")
91
87
  end
92
88
 
93
- it "should start its server if one is configured" do
94
- daemon.server = server
95
-
96
- expect(server).to receive(:start)
97
-
98
- daemon.start
99
- end
100
-
101
89
  it "disables the reparse of configs if the filetimeout is 0" do
102
90
  Puppet[:filetimeout] = 0
103
- daemon.agent = agent
104
-
105
91
  daemon.start
106
-
107
92
  expect(scheduler.jobs[0]).not_to be_enabled
108
93
  end
109
-
110
- it "disables the agent run when there is no agent" do
111
- Puppet[:filetimeout] = 0
112
- daemon.server = server
113
-
114
- daemon.start
115
-
116
- expect(scheduler.jobs[1]).not_to be_enabled
117
- end
118
-
119
- it "waits for the server to shutdown when there is one" do
120
- daemon.server = server
121
-
122
- expect(server).to receive(:wait_for_shutdown)
123
-
124
- daemon.start
125
- end
126
-
127
- it "waits for the server to shutdown when there is one" do
128
- daemon.server = server
129
-
130
- expect(server).to receive(:wait_for_shutdown)
131
-
132
- daemon.start
133
- end
134
94
  end
135
95
 
136
96
  describe "when stopping" do
@@ -146,14 +106,6 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
146
106
  without_warnings { Puppet::Application = Puppet::Application.superclass }
147
107
  end
148
108
 
149
- it "should stop its server if one is configured" do
150
- expect(server).to receive(:stop)
151
-
152
- daemon.server = server
153
-
154
- expect { daemon.stop }.to exit_with 0
155
- end
156
-
157
109
  it 'should request a stop from Puppet::Application' do
158
110
  expect(Puppet::Application).to receive(:stop!)
159
111
  expect { daemon.stop }.to exit_with 0
@@ -161,7 +113,6 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
161
113
 
162
114
  it "should remove its pidfile" do
163
115
  expect(pidfile).to receive(:unlock)
164
-
165
116
  expect { daemon.stop }.to exit_with 0
166
117
  end
167
118
 
@@ -188,8 +139,6 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
188
139
  expect(agent).to receive(:run).with({:splay => false}).and_raise(Puppet::LockError, 'Failed to aquire lock')
189
140
  expect(Puppet).to receive(:notice).with('Not triggering already-running agent')
190
141
 
191
- daemon.agent = agent
192
-
193
142
  daemon.reload
194
143
  end
195
144
 
@@ -197,8 +146,6 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
197
146
  expect(agent).to receive(:run).with({:splay => false})
198
147
  expect(Puppet).not_to receive(:notice).with('Not triggering already-running agent')
199
148
 
200
- daemon.agent = agent
201
-
202
149
  daemon.reload
203
150
  end
204
151
  end
@@ -220,15 +167,11 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
220
167
 
221
168
  it "should reexec itself if no agent is available" do
222
169
  expect(daemon).to receive(:reexec)
223
-
224
170
  daemon.restart
225
171
  end
226
172
 
227
173
  it "should reexec itself if the agent is not running" do
228
- expect(agent).to receive(:running?).and_return(false)
229
- daemon.agent = agent
230
174
  expect(daemon).to receive(:reexec)
231
-
232
175
  daemon.restart
233
176
  end
234
177
  end
@@ -247,14 +190,12 @@ describe Puppet::Daemon, :unless => Puppet::Util::Platform.windows? do
247
190
  it "should shut down without exiting" do
248
191
  daemon.argv = %w{foo}
249
192
  expect(daemon).to receive(:stop).with(:exit => false)
250
-
251
193
  daemon.reexec
252
194
  end
253
195
 
254
196
  it "should call 'exec' with the original executable and arguments" do
255
197
  daemon.argv = %w{foo}
256
198
  expect(daemon).to receive(:exec).with($0 + " foo")
257
-
258
199
  daemon.reexec
259
200
  end
260
201
  end
@@ -211,4 +211,21 @@ describe "puppet module search" do
211
211
  end
212
212
  end
213
213
  end
214
+
215
+ it "should include a deprecation warning" do
216
+ stub_request(:get, "https://forgeapi.puppet.com/v3/modules?query=puppetlabs-apache").to_return(status: 200, body: [answers: [], result: :success])
217
+
218
+ subject.search("puppetlabs-apache")
219
+
220
+ expect(@logs).to include(an_object_having_attributes(level: :warning, message: /This action has been deprecated. Please use the Puppet Forge to search for modules./))
221
+ end
222
+
223
+ it "omits the warning when deprecations are disabled" do
224
+ stub_request(:get, "https://forgeapi.puppet.com/v3/modules?query=puppetlabs-apache").to_return(status: 200, body: [answers: [], result: :success])
225
+
226
+ Puppet[:disable_warnings] = 'deprecations'
227
+ subject.search("puppetlabs-apache")
228
+
229
+ expect(@logs).not_to include(an_object_having_attributes(level: :warning))
230
+ end
214
231
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Puppet::FileSystem::Uniquefile do
4
+ include PuppetSpec::Files
5
+
4
6
  it "makes the name of the file available" do
5
7
  Puppet::FileSystem::Uniquefile.open_tmp('foo') do |file|
6
8
  expect(file.path).to match(/foo/)
@@ -73,6 +75,15 @@ describe Puppet::FileSystem::Uniquefile do
73
75
  Puppet::FileSystem::Uniquefile.open_tmp('foo') { |tmp| }
74
76
  end
75
77
 
78
+ it "reports when a parent directory does not exist" do
79
+ dir = tmpdir('uniquefile')
80
+ lock = File.join(dir, 'path', 'to', 'lock')
81
+
82
+ expect {
83
+ Puppet::FileSystem::Uniquefile.open_tmp(lock) { |tmp| }
84
+ }.to raise_error(Errno::ENOENT, %r{No such file or directory - A directory component in .* does not exist or is a dangling symbolic link})
85
+ end
86
+
76
87
  context "Ruby 1.9.3 Tempfile tests" do
77
88
  # the remaining tests in this file are ported directly from the ruby 1.9.3 source,
78
89
  # since most of this file was ported from there
@@ -474,38 +474,38 @@ describe Puppet::HTTP::Client do
474
474
  it "submits credentials for GET requests" do
475
475
  stub_request(:get, uri).with(basic_auth: credentials)
476
476
 
477
- client.get(uri, options: {user: 'user', password: 'pass'})
477
+ client.get(uri, options: {basic_auth: {user: 'user', password: 'pass'}})
478
478
  end
479
479
 
480
480
  it "submits credentials for PUT requests" do
481
481
  stub_request(:put, uri).with(basic_auth: credentials)
482
482
 
483
- client.put(uri, "hello", headers: {'Content-Type' => 'text/plain'}, options: {user: 'user', password: 'pass'})
483
+ client.put(uri, "hello", headers: {'Content-Type' => 'text/plain'}, options: {basic_auth: {user: 'user', password: 'pass'}})
484
484
  end
485
485
 
486
486
  it "returns response containing access denied" do
487
487
  stub_request(:get, uri).with(basic_auth: credentials).to_return(status: [403, "Ye Shall Not Pass"])
488
488
 
489
- response = client.get(uri, options: {user: 'user', password: 'pass'})
489
+ response = client.get(uri, options: {basic_auth: {user: 'user', password: 'pass'}})
490
490
  expect(response.code).to eq(403)
491
491
  expect(response.reason).to eq("Ye Shall Not Pass")
492
492
  expect(response).to_not be_success
493
493
  end
494
494
 
495
- it 'omits basic auth if user is nil' do
495
+ it 'includes basic auth if user is nil' do
496
496
  stub_request(:get, uri).with do |req|
497
- expect(req.headers).to_not include('Authorization')
497
+ expect(req.headers).to include('Authorization')
498
498
  end
499
499
 
500
- client.get(uri, options: {user: nil, password: 'pass'})
500
+ client.get(uri, options: {basic_auth: {user: nil, password: 'pass'}})
501
501
  end
502
502
 
503
- it 'omits basic auth if password is nil' do
503
+ it 'includes basic auth if password is nil' do
504
504
  stub_request(:get, uri).with do |req|
505
- expect(req.headers).to_not include('Authorization')
505
+ expect(req.headers).to include('Authorization')
506
506
  end
507
507
 
508
- client.get(uri, options: {user: 'user', password: nil})
508
+ client.get(uri, options: {basic_auth: {user: 'user', password: nil}})
509
509
  end
510
510
  end
511
511
 
@@ -557,7 +557,7 @@ describe Puppet::HTTP::Client do
557
557
  stub_request(:get, start_url).with(basic_auth: credentials).to_return(redirect_to(url: bar_url))
558
558
  stub_request(:get, bar_url).with(basic_auth: credentials).to_return(status: 200)
559
559
 
560
- client.get(start_url, options: {user: 'user', password: 'pass'})
560
+ client.get(start_url, options: {basic_auth: {user: 'user', password: 'pass'}})
561
561
  end
562
562
 
563
563
  it "redirects given a relative location" do