puppet 6.10.1 → 6.11.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.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +20 -12
- data/ext/project_data.yaml +3 -2
- data/ext/regexp_nodes/regexp_nodes.rb +4 -4
- data/ext/windows/service/daemon.rb +33 -8
- data/install.rb +6 -6
- data/lib/puppet.rb +8 -0
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +3 -0
- data/lib/puppet/application/apply.rb +2 -2
- data/lib/puppet/application/describe.rb +3 -9
- data/lib/puppet/application/device.rb +3 -0
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/lookup.rb +1 -1
- data/lib/puppet/application/script.rb +2 -2
- data/lib/puppet/application/ssl.rb +25 -21
- data/lib/puppet/configurer.rb +42 -0
- data/lib/puppet/configurer/downloader.rb +2 -6
- data/lib/puppet/context/trusted_information.rb +42 -4
- data/lib/puppet/defaults.rb +19 -4
- data/lib/puppet/face/module/list.rb +5 -5
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +1 -1
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system.rb +0 -8
- data/lib/puppet/file_system/memory_file.rb +1 -1
- data/lib/puppet/file_system/posix.rb +3 -2
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/functions.rb +1 -2
- data/lib/puppet/gettext/module_translations.rb +1 -1
- data/lib/puppet/graph/rb_tree_map.rb +2 -2
- data/lib/puppet/graph/simple_graph.rb +4 -3
- data/lib/puppet/http.rb +29 -0
- data/lib/puppet/http/client.rb +156 -0
- data/lib/puppet/http/errors.rb +30 -0
- data/lib/puppet/http/redirector.rb +48 -0
- data/lib/puppet/http/resolver.rb +5 -0
- data/lib/puppet/http/resolver/settings.rb +5 -0
- data/lib/puppet/http/resolver/srv.rb +13 -0
- data/lib/puppet/http/response.rb +34 -0
- data/lib/puppet/http/retry_after_handler.rb +47 -0
- data/lib/puppet/http/service.rb +18 -0
- data/lib/puppet/http/service/ca.rb +49 -0
- data/lib/puppet/http/session.rb +55 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
- data/lib/puppet/indirector/hiera.rb +2 -0
- data/lib/puppet/indirector/request.rb +1 -1
- data/lib/puppet/indirector/resource/ral.rb +1 -3
- data/lib/puppet/indirector/resource/validator.rb +1 -1
- data/lib/puppet/interface.rb +2 -1
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/loaders.rb +0 -1
- data/lib/puppet/metatype/manager.rb +1 -1
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/module/task.rb +20 -4
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +1 -1
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
- data/lib/puppet/module_tool/tar/mini.rb +1 -1
- data/lib/puppet/network/http.rb +2 -6
- data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
- data/lib/puppet/network/http/connection.rb +10 -12
- data/lib/puppet/network/http/pool.rb +2 -0
- data/lib/puppet/network/http/site.rb +5 -1
- data/lib/puppet/network/resolver.rb +4 -4
- data/lib/puppet/node/environment.rb +4 -2
- data/lib/puppet/pal/pal_impl.rb +2 -2
- data/lib/puppet/parser/ast.rb +1 -1
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/functions.rb +1 -1
- data/lib/puppet/parser/scope.rb +8 -7
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
- data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -7
- data/lib/puppet/pops/loader/module_loaders.rb +1 -1
- data/lib/puppet/pops/loader/task_instantiator.rb +4 -0
- data/lib/puppet/pops/loaders.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/merge_strategy.rb +22 -18
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/pn_parser.rb +17 -16
- data/lib/puppet/pops/puppet_stack.rb +52 -48
- data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
- data/lib/puppet/pops/types/p_uri_type.rb +1 -1
- data/lib/puppet/pops/types/string_converter.rb +10 -10
- data/lib/puppet/pops/types/types.rb +3 -3
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/provider/exec.rb +6 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
- data/lib/puppet/provider/nameservice/pw.rb +2 -2
- data/lib/puppet/provider/package/apt.rb +5 -1
- data/lib/puppet/provider/package/dnfmodule.rb +87 -0
- data/lib/puppet/provider/package/dpkg.rb +31 -17
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +34 -9
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +5 -5
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +9 -9
- data/lib/puppet/provider/service/openbsd.rb +1 -1
- data/lib/puppet/provider/service/rcng.rb +2 -2
- data/lib/puppet/provider/service/runit.rb +2 -8
- data/lib/puppet/provider/service/systemd.rb +10 -10
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +22 -13
- data/lib/puppet/provider/user/windows_adsi.rb +4 -5
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/metaparameter.rb +1 -3
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/reference/type.rb +3 -9
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/rest/errors.rb +1 -0
- data/lib/puppet/rest/response.rb +1 -0
- data/lib/puppet/rest/route.rb +1 -0
- data/lib/puppet/rest/routes.rb +3 -0
- data/lib/puppet/runtime.rb +25 -0
- data/lib/puppet/settings.rb +3 -3
- data/lib/puppet/settings/environment_conf.rb +1 -0
- data/lib/puppet/ssl/host.rb +1 -1
- data/lib/puppet/ssl/oids.rb +1 -1
- data/lib/puppet/ssl/state_machine.rb +23 -15
- data/lib/puppet/test/test_helper.rb +1 -1
- data/lib/puppet/transaction/report.rb +1 -1
- data/lib/puppet/trusted_external.rb +13 -0
- data/lib/puppet/type.rb +1 -3
- data/lib/puppet/type/exec.rb +7 -3
- data/lib/puppet/type/file.rb +1 -2
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/package.rb +10 -3
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/util.rb +2 -2
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/http_proxy.rb +2 -10
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/log/destinations.rb +2 -2
- data/lib/puppet/util/logging.rb +2 -2
- data/lib/puppet/util/metric.rb +2 -2
- data/lib/puppet/util/platform.rb +15 -4
- data/lib/puppet/util/provider_features.rb +2 -4
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +3 -1
- data/lib/puppet/util/windows/registry.rb +7 -5
- data/lib/puppet/vendor.rb +1 -1
- data/lib/puppet/vendor/require_vendored.rb +0 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet/x509/cert_provider.rb +4 -1
- data/locales/puppet.pot +279 -203
- data/man/man5/puppet.conf.5 +30 -8
- data/man/man8/puppet-agent.8 +4 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
- data/spec/integration/configurer_spec.rb +52 -0
- data/spec/lib/puppet/certificate_factory.rb +2 -2
- data/spec/spec_helper.rb +24 -0
- data/spec/unit/application/device_spec.rb +6 -0
- data/spec/unit/application/ssl_spec.rb +4 -7
- data/spec/unit/configurer_spec.rb +1 -0
- data/spec/unit/context/trusted_information_spec.rb +41 -2
- data/spec/unit/http/client_spec.rb +440 -0
- data/spec/unit/http/resolver_spec.rb +45 -0
- data/spec/unit/http/service/ca_spec.rb +106 -0
- data/spec/unit/http/service_spec.rb +32 -0
- data/spec/unit/http/session_spec.rb +102 -0
- data/spec/unit/indirector/resource/ral_spec.rb +4 -4
- data/spec/unit/network/http/connection_spec.rb +119 -145
- data/spec/unit/network/http/site_spec.rb +7 -0
- data/spec/unit/parser/scope_spec.rb +10 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +13 -2
- data/spec/unit/pops/loaders/module_loaders_spec.rb +37 -0
- data/spec/unit/provider/exec_spec.rb +209 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
- data/spec/unit/provider/package/dpkg_spec.rb +238 -78
- data/spec/unit/provider/package/pip_spec.rb +51 -6
- data/spec/unit/provider/service/daemontools_spec.rb +24 -0
- data/spec/unit/provider/service/runit_spec.rb +24 -0
- data/spec/unit/provider/service/systemd_spec.rb +25 -25
- data/spec/unit/provider/user/useradd_spec.rb +46 -0
- data/spec/unit/ssl/host_spec.rb +0 -5
- data/spec/unit/ssl/state_machine_spec.rb +16 -10
- data/spec/unit/type/exec_spec.rb +6 -12
- data/spec/unit/type/file_spec.rb +9 -4
- data/spec/unit/type/package_spec.rb +5 -0
- data/spec/unit/util/execution_spec.rb +16 -0
- data/spec/unit/util/http_proxy_spec.rb +79 -27
- data/spec/unit/util/log/destinations_spec.rb +7 -3
- metadata +45 -22
- data/lib/puppet/pops/loader/null_loader.rb +0 -60
- data/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
- data/lib/puppet/vendor/deep_merge/Gemfile +0 -3
- data/lib/puppet/vendor/deep_merge/LICENSE +0 -21
- data/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/deep_merge/README.md +0 -113
- data/lib/puppet/vendor/deep_merge/Rakefile +0 -19
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
- data/lib/puppet/vendor/deep_merge/lib/deep_merge.rb +0 -2
- data/lib/puppet/vendor/deep_merge/lib/deep_merge/core.rb +0 -210
- data/lib/puppet/vendor/deep_merge/lib/deep_merge/deep_merge_hash.rb +0 -28
- data/lib/puppet/vendor/deep_merge/lib/deep_merge/rails_compat.rb +0 -27
- data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +0 -608
- data/lib/puppet/vendor/load_deep_merge.rb +0 -1
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +0 -24
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +0 -24
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +0 -24
@@ -163,4 +163,28 @@ describe 'Puppet::Type::Service::Provider::Daemontools',
|
|
163
163
|
expect(@provider.status).to eq(:stopped)
|
164
164
|
end
|
165
165
|
end
|
166
|
+
|
167
|
+
context '.instances' do
|
168
|
+
before do
|
169
|
+
allow(provider_class).to receive(:defpath).and_return(path)
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when defpath is nil' do
|
173
|
+
let(:path) { nil }
|
174
|
+
|
175
|
+
it 'returns info message' do
|
176
|
+
expect(Puppet).to receive(:info).with(/daemontools is unsuitable because service directory is nil/)
|
177
|
+
provider_class.instances
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'when defpath does not exist' do
|
182
|
+
let(:path) { '/inexistent_path' }
|
183
|
+
|
184
|
+
it 'returns notice about missing path' do
|
185
|
+
expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
|
186
|
+
provider_class.instances
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
166
190
|
end
|
@@ -136,4 +136,28 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
|
|
136
136
|
expect(@provider.status).to eq(:stopped)
|
137
137
|
end
|
138
138
|
end
|
139
|
+
|
140
|
+
context '.instances' do
|
141
|
+
before do
|
142
|
+
allow(provider_class).to receive(:defpath).and_return(path)
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when defpath is nil' do
|
146
|
+
let(:path) { nil }
|
147
|
+
|
148
|
+
it 'returns info message' do
|
149
|
+
expect(Puppet).to receive(:info).with(/runit is unsuitable because service directory is nil/)
|
150
|
+
provider_class.instances
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'when defpath does not exist' do
|
155
|
+
let(:path) { '/inexistent_path' }
|
156
|
+
|
157
|
+
it 'returns notice about missing path' do
|
158
|
+
expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
|
159
|
+
provider_class.instances
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
139
163
|
end
|
@@ -201,17 +201,17 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
|
|
201
201
|
|
202
202
|
it "should start the service with systemctl start otherwise" do
|
203
203
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
204
|
-
expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
|
204
|
+
expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
|
205
205
|
expect(provider).to receive(:daemon_reload?).and_return('no')
|
206
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
206
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
207
207
|
provider.start
|
208
208
|
end
|
209
209
|
|
210
210
|
it "should show journald logs on failure" do
|
211
211
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
212
|
-
expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
|
212
|
+
expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
|
213
213
|
expect(provider).to receive(:daemon_reload?).and_return('no')
|
214
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
214
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
215
215
|
.and_raise(Puppet::ExecutionFailure, "Failed to start sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
|
216
216
|
journalctl_logs = <<-EOS
|
217
217
|
-- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
|
@@ -233,13 +233,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
233
233
|
|
234
234
|
it "should stop the service with systemctl stop otherwise" do
|
235
235
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
236
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
236
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
237
237
|
provider.stop
|
238
238
|
end
|
239
239
|
|
240
240
|
it "should show journald logs on failure" do
|
241
241
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
242
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
242
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
243
243
|
.and_raise(Puppet::ExecutionFailure, "Failed to stop sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
|
244
244
|
journalctl_logs = <<-EOS
|
245
245
|
-- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
|
@@ -255,13 +255,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
255
255
|
describe "#daemon_reload?" do
|
256
256
|
it "should skip the systemctl daemon_reload if not required by the service" do
|
257
257
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
258
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("no")
|
258
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','show', '--', 'sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("no")
|
259
259
|
provider.daemon_reload?
|
260
260
|
end
|
261
261
|
it "should run a systemctl daemon_reload if the service has been modified" do
|
262
262
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
263
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("yes")
|
264
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','daemon-reload'], :failonfail => false)
|
263
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','show', '--', 'sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("yes")
|
264
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl', '--', 'daemon-reload'], :failonfail => false)
|
265
265
|
provider.daemon_reload?
|
266
266
|
end
|
267
267
|
end
|
@@ -269,42 +269,42 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
269
269
|
describe "#enabled?" do
|
270
270
|
it "should return :true if the service is enabled" do
|
271
271
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
272
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("enabled\n")
|
272
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("enabled\n")
|
273
273
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
|
274
274
|
expect(provider.enabled?).to eq(:true)
|
275
275
|
end
|
276
276
|
|
277
277
|
it "should return :true if the service is static" do
|
278
278
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
279
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("static\n")
|
279
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','--', 'sshd.service'], :failonfail => false).and_return("static\n")
|
280
280
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
|
281
281
|
expect(provider.enabled?).to eq(:true)
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should return :false if the service is disabled" do
|
285
285
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
286
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("disabled\n")
|
286
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("disabled\n")
|
287
287
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
|
288
288
|
expect(provider.enabled?).to eq(:false)
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should return :false if the service is indirect" do
|
292
292
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
293
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("indirect\n")
|
293
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("indirect\n")
|
294
294
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
|
295
295
|
expect(provider.enabled?).to eq(:false)
|
296
296
|
end
|
297
297
|
|
298
298
|
it "should return :false if the service is masked and the resource is attempting to be disabled" do
|
299
299
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => false))
|
300
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
|
300
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
|
301
301
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
|
302
302
|
expect(provider.enabled?).to eq(:false)
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should return :mask if the service is masked and the resource is attempting to be masked" do
|
306
306
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => 'mask'))
|
307
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
|
307
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
|
308
308
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
|
309
309
|
expect(provider.enabled?).to eq(:mask)
|
310
310
|
end
|
@@ -313,8 +313,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
313
313
|
describe "#enable" do
|
314
314
|
it "should run systemctl enable to enable a service" do
|
315
315
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
316
|
-
expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
|
317
|
-
expect(provider).to receive(:systemctl).with(:enable, 'sshd.service')
|
316
|
+
expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
|
317
|
+
expect(provider).to receive(:systemctl).with(:enable, '--', 'sshd.service')
|
318
318
|
provider.enable
|
319
319
|
end
|
320
320
|
end
|
@@ -322,7 +322,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
322
322
|
describe "#disable" do
|
323
323
|
it "should run systemctl disable to disable a service" do
|
324
324
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
325
|
-
expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
|
325
|
+
expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
|
326
326
|
provider.disable
|
327
327
|
end
|
328
328
|
end
|
@@ -333,8 +333,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
333
333
|
# :disable is the only call in the provider that uses a symbol instead of
|
334
334
|
# a string.
|
335
335
|
# This should be made consistent in the future and all tests updated.
|
336
|
-
expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
|
337
|
-
expect(provider).to receive(:systemctl).with(:mask, 'sshd.service')
|
336
|
+
expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
|
337
|
+
expect(provider).to receive(:systemctl).with(:mask, '--', 'sshd.service')
|
338
338
|
provider.mask
|
339
339
|
end
|
340
340
|
end
|
@@ -344,7 +344,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
344
344
|
describe "#status" do
|
345
345
|
it "should return running if if the command returns 0" do
|
346
346
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
347
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
|
347
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-active', '--', 'sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
|
348
348
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
|
349
349
|
expect(provider.status).to eq(:running)
|
350
350
|
end
|
@@ -352,7 +352,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
352
352
|
[-10,-1,3,10].each { |ec|
|
353
353
|
it "should return stopped if the command returns something non-0" do
|
354
354
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
355
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
|
355
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','is-active', '--', 'sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
|
356
356
|
allow($CHILD_STATUS).to receive(:exitstatus).and_return(ec)
|
357
357
|
expect(provider.status).to eq(:stopped)
|
358
358
|
end
|
@@ -371,7 +371,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
371
371
|
it "should use the supplied restart command if specified" do
|
372
372
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
|
373
373
|
expect(provider).to receive(:daemon_reload?).and_return('no')
|
374
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
374
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','restart', '--', 'sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
|
375
375
|
expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
376
376
|
provider.restart
|
377
377
|
end
|
@@ -379,14 +379,14 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
|
|
379
379
|
it "should restart the service with systemctl restart" do
|
380
380
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
381
381
|
expect(provider).to receive(:daemon_reload?).and_return('no')
|
382
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
382
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
383
383
|
provider.restart
|
384
384
|
end
|
385
385
|
|
386
386
|
it "should show journald logs on failure" do
|
387
387
|
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
388
388
|
expect(provider).to receive(:daemon_reload?).and_return('no')
|
389
|
-
expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
389
|
+
expect(provider).to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
|
390
390
|
.and_raise(Puppet::ExecutionFailure, "Failed to restart sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
|
391
391
|
journalctl_logs = <<-EOS
|
392
392
|
-- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
|
@@ -317,6 +317,52 @@ describe Puppet::Type.type(:user).provider(:useradd) do
|
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
320
|
+
describe "#comment" do
|
321
|
+
before { described_class.has_feature :libuser }
|
322
|
+
|
323
|
+
let(:content) { "myuser:x:x:x:local comment:x:x" }
|
324
|
+
|
325
|
+
it "should return the local comment string when forcelocal is true" do
|
326
|
+
resource[:forcelocal] = true
|
327
|
+
allow(File).to receive(:open).with('/etc/passwd').and_yield(content)
|
328
|
+
expect(provider.comment).to eq('local comment')
|
329
|
+
end
|
330
|
+
|
331
|
+
it "should fall back to nameservice comment string when forcelocal is false" do
|
332
|
+
resource[:forcelocal] = false
|
333
|
+
allow(provider).to receive(:get).with(:comment).and_return('remote comment')
|
334
|
+
expect(provider).not_to receive(:localcomment)
|
335
|
+
expect(provider.comment).to eq('remote comment')
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe "#finduser" do
|
340
|
+
before { allow(File).to receive(:open).with('/etc/passwd').and_yield(content) }
|
341
|
+
|
342
|
+
let(:content) { "sample_account:sample_password:sample_uid:sample_gid:sample_gecos:sample_directory:sample_shell" }
|
343
|
+
let(:output) do
|
344
|
+
{
|
345
|
+
account: 'sample_account',
|
346
|
+
password: 'sample_password',
|
347
|
+
uid: 'sample_uid',
|
348
|
+
gid: 'sample_gid',
|
349
|
+
gecos: 'sample_gecos',
|
350
|
+
directory: 'sample_directory',
|
351
|
+
shell: 'sample_shell',
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
[:account, :password, :uid, :gid, :gecos, :directory, :shell].each do |key|
|
356
|
+
it "finds an user by #{key} when asked" do
|
357
|
+
expect(provider.finduser(key, "sample_#{key}")).to eq(output)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
it "returns false when specified key/value pair is not found" do
|
362
|
+
expect(provider.finduser(:account, 'invalid_account')).to eq(false)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
320
366
|
describe "#check_allow_dup" do
|
321
367
|
it "should return an array with a flag if dup is allowed" do
|
322
368
|
resource[:allowdupe] = :true
|
data/spec/unit/ssl/host_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'webmock/rspec'
|
3
2
|
require 'puppet/test_ca'
|
4
3
|
|
5
4
|
require 'puppet/ssl/host'
|
@@ -308,10 +307,6 @@ describe Puppet::SSL::Host, if: !Puppet::Util::Platform.jruby? do
|
|
308
307
|
allow(@host).to receive(:validate_certificate_with_key)
|
309
308
|
allow(@host).to receive(:http_client).and_return(@http)
|
310
309
|
allow(@host).to receive(:ssl_store).and_return(double("ssl store"))
|
311
|
-
|
312
|
-
WebMock.disable_net_connect!
|
313
|
-
allow_any_instance_of(Net::HTTP).to receive(:start)
|
314
|
-
allow_any_instance_of(Net::HTTP).to receive(:finish)
|
315
310
|
end
|
316
311
|
|
317
312
|
let(:ca_cert_response) { @pki[:ca_bundle] }
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'webmock/rspec'
|
3
2
|
require 'puppet_spec/files'
|
4
3
|
|
5
4
|
require 'puppet/ssl'
|
@@ -28,11 +27,6 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
28
27
|
let(:refused_message) { %r{Connection refused|No connection could be made because the target machine actively refused it} }
|
29
28
|
|
30
29
|
before(:each) do
|
31
|
-
WebMock.disable_net_connect!
|
32
|
-
|
33
|
-
allow_any_instance_of(Net::HTTP).to receive(:start)
|
34
|
-
allow_any_instance_of(Net::HTTP).to receive(:finish)
|
35
|
-
|
36
30
|
Puppet[:ssl_lockfile] = tmpfile('ssllock')
|
37
31
|
allow(Kernel).to receive(:sleep)
|
38
32
|
end
|
@@ -304,9 +298,12 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
304
298
|
stub_request(:get, %r{puppet-ca/v1/certificate/ca}).to_return(status: 200, body: cacert_pem)
|
305
299
|
allow(cert_provider).to receive(:save_cacerts)
|
306
300
|
|
307
|
-
|
301
|
+
receive_count = 0
|
302
|
+
allow_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) { receive_count += 1 }
|
308
303
|
|
309
304
|
state.next_state
|
305
|
+
|
306
|
+
expect(receive_count).to eq(2)
|
310
307
|
end
|
311
308
|
|
312
309
|
it 'returns an Error if the server returns 404' do
|
@@ -416,9 +413,12 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
416
413
|
stub_request(:get, %r{puppet-ca/v1/certificate_revocation_list/ca}).to_return(status: 200, body: crl_pem)
|
417
414
|
allow(cert_provider).to receive(:save_crls)
|
418
415
|
|
419
|
-
|
416
|
+
receive_count = 0
|
417
|
+
allow_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER) { receive_count += 1 }
|
420
418
|
|
421
419
|
state.next_state
|
420
|
+
|
421
|
+
expect(receive_count).to eq(2)
|
422
422
|
end
|
423
423
|
|
424
424
|
it 'returns an Error if the server returns 404' do
|
@@ -730,9 +730,12 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
730
730
|
it "verifies the server's certificate when submitting the CSR" do
|
731
731
|
stub_request(:put, %r{puppet-ca/v1/certificate_request/#{Puppet[:certname]}}).to_return(status: 200)
|
732
732
|
|
733
|
-
|
733
|
+
receive_count = 0
|
734
|
+
allow_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER) { receive_count += 1 }
|
734
735
|
|
735
736
|
state.next_state
|
737
|
+
|
738
|
+
expect(receive_count).to eq(2)
|
736
739
|
end
|
737
740
|
end
|
738
741
|
|
@@ -780,9 +783,12 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
780
783
|
allow(cert_provider).to receive(:save_client_cert)
|
781
784
|
allow(cert_provider).to receive(:save_request)
|
782
785
|
|
783
|
-
|
786
|
+
receive_count = 0
|
787
|
+
allow_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER) { receive_count += 1 }
|
784
788
|
|
785
789
|
state.next_state
|
790
|
+
|
791
|
+
expect(receive_count).to eq(2)
|
786
792
|
end
|
787
793
|
|
788
794
|
it 'does not save an invalid client cert' do
|
data/spec/unit/type/exec_spec.rb
CHANGED
@@ -150,16 +150,13 @@ RSpec.describe Puppet::Type.type(:exec) do
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
it "should redact the command on failure" do
|
153
|
+
it "should redact the sensitive 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
|
-
|
159
|
-
|
160
|
-
expect(log.level).to eq(:err)
|
161
|
-
expect(log.message).to eq(line)
|
162
|
-
end
|
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/))
|
163
160
|
end
|
164
161
|
|
165
162
|
it "should log the output on failure when returns is specified as an array" do
|
@@ -177,7 +174,7 @@ RSpec.describe Puppet::Type.type(:exec) do
|
|
177
174
|
end
|
178
175
|
end
|
179
176
|
|
180
|
-
it "should redact the command on failure when returns is specified as an array" do
|
177
|
+
it "should redact the sensitive command on failure when returns is specified as an array" do
|
181
178
|
output = "output1\noutput2\n"
|
182
179
|
|
183
180
|
expect {
|
@@ -185,11 +182,8 @@ RSpec.describe Puppet::Type.type(:exec) do
|
|
185
182
|
:logoutput => :on_failure, :sensitive_parameters => [:command]).refresh
|
186
183
|
}.to raise_error(Puppet::Error, /^\[command redacted\] returned 1 instead of/)
|
187
184
|
|
188
|
-
|
189
|
-
|
190
|
-
expect(log.level).to eq(:err)
|
191
|
-
expect(log.message).to eq(line)
|
192
|
-
end
|
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/))
|
193
187
|
end
|
194
188
|
|
195
189
|
it "shouldn't log the output on success" do
|
data/spec/unit/type/file_spec.rb
CHANGED
@@ -477,6 +477,9 @@ 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
|
+
|
480
483
|
before do
|
481
484
|
file[:recurse] = true
|
482
485
|
@metadata = Puppet::FileServing::Metadata
|
@@ -485,8 +488,9 @@ describe Puppet::Type.type(:file) do
|
|
485
488
|
describe "and a source is set" do
|
486
489
|
it "should pass the already-discovered resources to recurse_remote" do
|
487
490
|
file[:source] = File.expand_path(__FILE__)
|
488
|
-
allow(
|
489
|
-
|
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([])
|
490
494
|
file.recurse
|
491
495
|
end
|
492
496
|
end
|
@@ -494,8 +498,9 @@ describe Puppet::Type.type(:file) do
|
|
494
498
|
describe "and a target is set" do
|
495
499
|
it "should use recurse_link" do
|
496
500
|
file[:target] = File.expand_path(__FILE__)
|
497
|
-
allow(
|
498
|
-
|
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([])
|
499
504
|
file.recurse
|
500
505
|
end
|
501
506
|
end
|