puppet 6.10.1-x64-mingw32 → 6.11.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 (242) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Gemfile.lock +20 -12
  4. data/ext/project_data.yaml +3 -2
  5. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  6. data/ext/windows/service/daemon.rb +33 -8
  7. data/install.rb +6 -6
  8. data/lib/puppet.rb +8 -0
  9. data/lib/puppet/application.rb +1 -1
  10. data/lib/puppet/application/agent.rb +3 -0
  11. data/lib/puppet/application/apply.rb +2 -2
  12. data/lib/puppet/application/describe.rb +3 -9
  13. data/lib/puppet/application/device.rb +3 -0
  14. data/lib/puppet/application/doc.rb +1 -1
  15. data/lib/puppet/application/lookup.rb +1 -1
  16. data/lib/puppet/application/script.rb +2 -2
  17. data/lib/puppet/application/ssl.rb +25 -21
  18. data/lib/puppet/configurer.rb +42 -0
  19. data/lib/puppet/configurer/downloader.rb +2 -6
  20. data/lib/puppet/context/trusted_information.rb +42 -4
  21. data/lib/puppet/defaults.rb +19 -4
  22. data/lib/puppet/face/module/list.rb +5 -5
  23. data/lib/puppet/face/module/search.rb +1 -1
  24. data/lib/puppet/face/module/uninstall.rb +1 -1
  25. data/lib/puppet/face/module/upgrade.rb +1 -1
  26. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  27. data/lib/puppet/file_system.rb +0 -8
  28. data/lib/puppet/file_system/memory_file.rb +1 -1
  29. data/lib/puppet/file_system/posix.rb +3 -2
  30. data/lib/puppet/forge.rb +3 -3
  31. data/lib/puppet/functions.rb +1 -2
  32. data/lib/puppet/gettext/module_translations.rb +1 -1
  33. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  34. data/lib/puppet/graph/simple_graph.rb +4 -3
  35. data/lib/puppet/http.rb +29 -0
  36. data/lib/puppet/http/client.rb +156 -0
  37. data/lib/puppet/http/errors.rb +30 -0
  38. data/lib/puppet/http/redirector.rb +48 -0
  39. data/lib/puppet/http/resolver.rb +5 -0
  40. data/lib/puppet/http/resolver/settings.rb +5 -0
  41. data/lib/puppet/http/resolver/srv.rb +13 -0
  42. data/lib/puppet/http/response.rb +34 -0
  43. data/lib/puppet/http/retry_after_handler.rb +47 -0
  44. data/lib/puppet/http/service.rb +18 -0
  45. data/lib/puppet/http/service/ca.rb +49 -0
  46. data/lib/puppet/http/session.rb +55 -0
  47. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  48. data/lib/puppet/indirector/hiera.rb +2 -0
  49. data/lib/puppet/indirector/request.rb +1 -1
  50. data/lib/puppet/indirector/resource/ral.rb +1 -3
  51. data/lib/puppet/indirector/resource/validator.rb +1 -1
  52. data/lib/puppet/interface.rb +2 -1
  53. data/lib/puppet/interface/documentation.rb +1 -1
  54. data/lib/puppet/loaders.rb +0 -1
  55. data/lib/puppet/metatype/manager.rb +1 -1
  56. data/lib/puppet/module.rb +1 -1
  57. data/lib/puppet/module/task.rb +20 -4
  58. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  59. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  60. data/lib/puppet/module_tool/metadata.rb +1 -1
  61. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  62. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  63. data/lib/puppet/network/http.rb +2 -6
  64. data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
  65. data/lib/puppet/network/http/connection.rb +10 -12
  66. data/lib/puppet/network/http/pool.rb +2 -0
  67. data/lib/puppet/network/http/site.rb +5 -1
  68. data/lib/puppet/network/resolver.rb +4 -4
  69. data/lib/puppet/node/environment.rb +4 -2
  70. data/lib/puppet/pal/pal_impl.rb +2 -2
  71. data/lib/puppet/parser/ast.rb +1 -1
  72. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  73. data/lib/puppet/parser/functions.rb +1 -1
  74. data/lib/puppet/parser/scope.rb +8 -7
  75. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  76. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  77. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  78. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -7
  79. data/lib/puppet/pops/loader/module_loaders.rb +1 -1
  80. data/lib/puppet/pops/loader/task_instantiator.rb +4 -0
  81. data/lib/puppet/pops/loaders.rb +1 -1
  82. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  83. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  84. data/lib/puppet/pops/merge_strategy.rb +22 -18
  85. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  86. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  87. data/lib/puppet/pops/parser/locator.rb +1 -1
  88. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  89. data/lib/puppet/pops/puppet_stack.rb +52 -48
  90. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  91. data/lib/puppet/pops/types/p_uri_type.rb +1 -1
  92. data/lib/puppet/pops/types/string_converter.rb +10 -10
  93. data/lib/puppet/pops/types/types.rb +3 -3
  94. data/lib/puppet/property.rb +1 -1
  95. data/lib/puppet/property/ensure.rb +1 -1
  96. data/lib/puppet/provider/exec.rb +6 -2
  97. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  98. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  99. data/lib/puppet/provider/package/apt.rb +5 -1
  100. data/lib/puppet/provider/package/dnfmodule.rb +87 -0
  101. data/lib/puppet/provider/package/dpkg.rb +31 -17
  102. data/lib/puppet/provider/package/openbsd.rb +1 -1
  103. data/lib/puppet/provider/package/pip.rb +34 -9
  104. data/lib/puppet/provider/package/portage.rb +1 -1
  105. data/lib/puppet/provider/package/rpm.rb +5 -5
  106. data/lib/puppet/provider/package/windows/package.rb +1 -1
  107. data/lib/puppet/provider/package/yum.rb +1 -1
  108. data/lib/puppet/provider/parsedfile.rb +1 -1
  109. data/lib/puppet/provider/service/daemontools.rb +9 -9
  110. data/lib/puppet/provider/service/openbsd.rb +1 -1
  111. data/lib/puppet/provider/service/rcng.rb +2 -2
  112. data/lib/puppet/provider/service/runit.rb +2 -8
  113. data/lib/puppet/provider/service/systemd.rb +10 -10
  114. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  115. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  116. data/lib/puppet/provider/user/useradd.rb +22 -13
  117. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  118. data/lib/puppet/reference/indirection.rb +2 -2
  119. data/lib/puppet/reference/metaparameter.rb +1 -3
  120. data/lib/puppet/reference/providers.rb +1 -1
  121. data/lib/puppet/reference/type.rb +3 -9
  122. data/lib/puppet/reports.rb +1 -1
  123. data/lib/puppet/resource.rb +1 -1
  124. data/lib/puppet/resource/catalog.rb +1 -1
  125. data/lib/puppet/rest/errors.rb +1 -0
  126. data/lib/puppet/rest/response.rb +1 -0
  127. data/lib/puppet/rest/route.rb +1 -0
  128. data/lib/puppet/rest/routes.rb +3 -0
  129. data/lib/puppet/runtime.rb +25 -0
  130. data/lib/puppet/settings.rb +3 -3
  131. data/lib/puppet/settings/environment_conf.rb +1 -0
  132. data/lib/puppet/ssl/host.rb +1 -1
  133. data/lib/puppet/ssl/oids.rb +1 -1
  134. data/lib/puppet/ssl/state_machine.rb +23 -15
  135. data/lib/puppet/test/test_helper.rb +1 -1
  136. data/lib/puppet/transaction/report.rb +1 -1
  137. data/lib/puppet/trusted_external.rb +13 -0
  138. data/lib/puppet/type.rb +1 -3
  139. data/lib/puppet/type/exec.rb +7 -3
  140. data/lib/puppet/type/file.rb +1 -2
  141. data/lib/puppet/type/file/source.rb +2 -2
  142. data/lib/puppet/type/package.rb +10 -3
  143. data/lib/puppet/type/schedule.rb +1 -1
  144. data/lib/puppet/type/service.rb +1 -1
  145. data/lib/puppet/util.rb +2 -2
  146. data/lib/puppet/util/command_line/trollop.rb +1 -1
  147. data/lib/puppet/util/http_proxy.rb +2 -10
  148. data/lib/puppet/util/log.rb +2 -2
  149. data/lib/puppet/util/log/destinations.rb +2 -2
  150. data/lib/puppet/util/logging.rb +2 -2
  151. data/lib/puppet/util/metric.rb +2 -2
  152. data/lib/puppet/util/platform.rb +15 -4
  153. data/lib/puppet/util/provider_features.rb +2 -4
  154. data/lib/puppet/util/rdoc.rb +1 -1
  155. data/lib/puppet/util/reference.rb +1 -1
  156. data/lib/puppet/util/resource_template.rb +1 -1
  157. data/lib/puppet/util/selinux.rb +3 -1
  158. data/lib/puppet/util/windows/registry.rb +7 -5
  159. data/lib/puppet/vendor.rb +1 -1
  160. data/lib/puppet/vendor/require_vendored.rb +0 -1
  161. data/lib/puppet/version.rb +1 -1
  162. data/lib/puppet/x509/cert_provider.rb +4 -1
  163. data/locales/puppet.pot +279 -203
  164. data/man/man5/puppet.conf.5 +30 -8
  165. data/man/man8/puppet-agent.8 +4 -1
  166. data/man/man8/puppet-apply.8 +1 -1
  167. data/man/man8/puppet-catalog.8 +1 -1
  168. data/man/man8/puppet-config.8 +1 -1
  169. data/man/man8/puppet-describe.8 +1 -1
  170. data/man/man8/puppet-device.8 +1 -1
  171. data/man/man8/puppet-doc.8 +1 -1
  172. data/man/man8/puppet-epp.8 +1 -1
  173. data/man/man8/puppet-facts.8 +1 -1
  174. data/man/man8/puppet-filebucket.8 +1 -1
  175. data/man/man8/puppet-generate.8 +1 -1
  176. data/man/man8/puppet-help.8 +1 -1
  177. data/man/man8/puppet-key.8 +1 -1
  178. data/man/man8/puppet-lookup.8 +1 -1
  179. data/man/man8/puppet-man.8 +1 -1
  180. data/man/man8/puppet-module.8 +1 -1
  181. data/man/man8/puppet-node.8 +1 -1
  182. data/man/man8/puppet-parser.8 +1 -1
  183. data/man/man8/puppet-plugin.8 +1 -1
  184. data/man/man8/puppet-report.8 +1 -1
  185. data/man/man8/puppet-resource.8 +1 -1
  186. data/man/man8/puppet-script.8 +1 -1
  187. data/man/man8/puppet-ssl.8 +1 -1
  188. data/man/man8/puppet-status.8 +1 -1
  189. data/man/man8/puppet.8 +2 -2
  190. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
  191. data/spec/integration/configurer_spec.rb +52 -0
  192. data/spec/lib/puppet/certificate_factory.rb +2 -2
  193. data/spec/spec_helper.rb +24 -0
  194. data/spec/unit/application/device_spec.rb +6 -0
  195. data/spec/unit/application/ssl_spec.rb +4 -7
  196. data/spec/unit/configurer_spec.rb +1 -0
  197. data/spec/unit/context/trusted_information_spec.rb +41 -2
  198. data/spec/unit/http/client_spec.rb +440 -0
  199. data/spec/unit/http/resolver_spec.rb +45 -0
  200. data/spec/unit/http/service/ca_spec.rb +106 -0
  201. data/spec/unit/http/service_spec.rb +32 -0
  202. data/spec/unit/http/session_spec.rb +102 -0
  203. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  204. data/spec/unit/network/http/connection_spec.rb +119 -145
  205. data/spec/unit/network/http/site_spec.rb +7 -0
  206. data/spec/unit/parser/scope_spec.rb +10 -0
  207. data/spec/unit/pops/loaders/loaders_spec.rb +13 -2
  208. data/spec/unit/pops/loaders/module_loaders_spec.rb +37 -0
  209. data/spec/unit/provider/exec_spec.rb +209 -0
  210. data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
  211. data/spec/unit/provider/package/dpkg_spec.rb +238 -78
  212. data/spec/unit/provider/package/pip_spec.rb +51 -6
  213. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  214. data/spec/unit/provider/service/runit_spec.rb +24 -0
  215. data/spec/unit/provider/service/systemd_spec.rb +25 -25
  216. data/spec/unit/provider/user/useradd_spec.rb +46 -0
  217. data/spec/unit/ssl/host_spec.rb +0 -5
  218. data/spec/unit/ssl/state_machine_spec.rb +16 -10
  219. data/spec/unit/type/exec_spec.rb +6 -12
  220. data/spec/unit/type/file_spec.rb +9 -4
  221. data/spec/unit/type/package_spec.rb +5 -0
  222. data/spec/unit/util/execution_spec.rb +16 -0
  223. data/spec/unit/util/http_proxy_spec.rb +79 -27
  224. data/spec/unit/util/log/destinations_spec.rb +7 -3
  225. metadata +54 -25
  226. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  227. data/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
  228. data/lib/puppet/vendor/deep_merge/Gemfile +0 -3
  229. data/lib/puppet/vendor/deep_merge/LICENSE +0 -21
  230. data/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
  231. data/lib/puppet/vendor/deep_merge/README.md +0 -113
  232. data/lib/puppet/vendor/deep_merge/Rakefile +0 -19
  233. data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
  234. data/lib/puppet/vendor/deep_merge/lib/deep_merge.rb +0 -2
  235. data/lib/puppet/vendor/deep_merge/lib/deep_merge/core.rb +0 -210
  236. data/lib/puppet/vendor/deep_merge/lib/deep_merge/deep_merge_hash.rb +0 -28
  237. data/lib/puppet/vendor/deep_merge/lib/deep_merge/rails_compat.rb +0 -27
  238. data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +0 -608
  239. data/lib/puppet/vendor/load_deep_merge.rb +0 -1
  240. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +0 -24
  241. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +0 -24
  242. 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
@@ -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
- expect_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
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
- expect_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
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
- expect_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
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
- expect_any_instance_of(Net::HTTP).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
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
@@ -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
- output.split("\n").each do |line|
159
- log = @logs.shift
160
- expect(log.level).to eq(:err)
161
- expect(log.message).to eq(line)
162
- end
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
- output.split("\n").each do |line|
189
- log = @logs.shift
190
- expect(log.level).to eq(:err)
191
- expect(log.message).to eq(line)
192
- end
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
@@ -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(file).to receive(:recurse_local).and_return(:foo => "bar")
489
- expect(file).to receive(:recurse_remote).with(:foo => "bar").and_return([])
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(file).to receive(:recurse_local).and_return(:foo => "bar")
498
- expect(file).to receive(:recurse_link).with(:foo => "bar").and_return([])
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