chef 15.3.14-universal-mingw32 → 15.4.45-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/chef.gemspec +2 -2
  3. data/lib/chef/application/solo.rb +1 -1
  4. data/lib/chef/event_dispatch/dispatcher.rb +9 -2
  5. data/lib/chef/formatters/doc.rb +3 -3
  6. data/lib/chef/knife.rb +13 -3
  7. data/lib/chef/knife/bootstrap.rb +28 -4
  8. data/lib/chef/knife/bootstrap/templates/chef-full.erb +7 -8
  9. data/lib/chef/knife/data_bag_secret_options.rb +11 -4
  10. data/lib/chef/knife/download.rb +2 -2
  11. data/lib/chef/knife/exec.rb +9 -1
  12. data/lib/chef/knife/ssh.rb +1 -1
  13. data/lib/chef/knife/ssl_check.rb +1 -1
  14. data/lib/chef/knife/supermarket_list.rb +19 -7
  15. data/lib/chef/knife/supermarket_search.rb +3 -2
  16. data/lib/chef/node/attribute.rb +2 -0
  17. data/lib/chef/node/attribute_collections.rb +8 -0
  18. data/lib/chef/node/immutable_collections.rb +12 -0
  19. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  20. data/lib/chef/node/mixin/immutablize_hash.rb +1 -0
  21. data/lib/chef/provider.rb +14 -8
  22. data/lib/chef/provider/package/chocolatey.rb +11 -3
  23. data/lib/chef/provider/package/dnf/python_helper.rb +8 -3
  24. data/lib/chef/provider/package/windows/exe.rb +2 -2
  25. data/lib/chef/provider/package/windows/msi.rb +3 -3
  26. data/lib/chef/provider/package/yum/python_helper.rb +8 -3
  27. data/lib/chef/provider/service/windows.rb +1 -1
  28. data/lib/chef/resource/apt_repository.rb +19 -13
  29. data/lib/chef/resource/apt_update.rb +15 -1
  30. data/lib/chef/resource/archive_file.rb +10 -1
  31. data/lib/chef/resource/build_essential.rb +14 -1
  32. data/lib/chef/resource/chocolatey_config.rb +17 -1
  33. data/lib/chef/resource/chocolatey_feature.rb +15 -0
  34. data/lib/chef/resource/chocolatey_package.rb +31 -1
  35. data/lib/chef/resource/chocolatey_source.rb +17 -1
  36. data/lib/chef/resource/cookbook_file.rb +1 -1
  37. data/lib/chef/resource/cron_access.rb +22 -1
  38. data/lib/chef/resource/cron_d.rb +46 -1
  39. data/lib/chef/resource/dmg_package.rb +28 -0
  40. data/lib/chef/resource/kernel_module.rb +61 -0
  41. data/lib/chef/resource/sudo.rb +2 -2
  42. data/lib/chef/resource/windows_ad_join.rb +72 -3
  43. data/lib/chef/resource/windows_service.rb +1 -1
  44. data/lib/chef/resource/windows_share.rb +2 -1
  45. data/lib/chef/shell.rb +4 -4
  46. data/lib/chef/shell/ext.rb +2 -2
  47. data/lib/chef/train_transport.rb +1 -1
  48. data/lib/chef/version.rb +1 -1
  49. data/spec/functional/resource/ifconfig_spec.rb +0 -2
  50. data/spec/functional/resource/mount_spec.rb +0 -4
  51. data/spec/functional/util/powershell/cmdlet_spec.rb +2 -2
  52. data/spec/integration/knife/chef_repo_path_spec.rb +4 -2
  53. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +19 -19
  54. data/spec/spec_helper.rb +2 -0
  55. data/spec/unit/formatters/doc_spec.rb +18 -0
  56. data/spec/unit/knife/bootstrap_spec.rb +46 -10
  57. data/spec/unit/knife/supermarket_list_spec.rb +70 -0
  58. data/spec/unit/knife/supermarket_search_spec.rb +85 -0
  59. data/spec/unit/node/attribute_spec.rb +22 -0
  60. data/spec/unit/node/immutable_collections_spec.rb +72 -144
  61. data/spec/unit/provider/package/chocolatey_spec.rb +50 -35
  62. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  63. data/spec/unit/provider/service/windows_spec.rb +23 -3
  64. data/spec/unit/resource/chocolatey_package_spec.rb +17 -2
  65. data/spec/unit/resource/windows_ad_join_spec.rb +4 -0
  66. data/spec/unit/resource/windows_service_spec.rb +5 -0
  67. data/spec/unit/resource/windows_share_spec.rb +7 -0
  68. data/tasks/docs.rb +4 -1
  69. metadata +10 -8
@@ -46,7 +46,7 @@ describe Chef::Provider::Package::Chocolatey do
46
46
  allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
47
47
  allow(provider).to receive(:choco_exe).and_return(choco_exe)
48
48
  local_list_obj = double(stdout: local_list_stdout)
49
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0], timeout: timeout }).and_return(local_list_obj)
49
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0, 2], timeout: timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
52
  def allow_remote_list(package_names, args = nil)
@@ -61,9 +61,9 @@ describe Chef::Provider::Package::Chocolatey do
61
61
  remote_list_obj = double(stdout: remote_list_stdout)
62
62
  package_names.each do |pkg|
63
63
  if args
64
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0], timeout: timeout }).and_return(remote_list_obj)
64
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
65
65
  else
66
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0], timeout: timeout }).and_return(remote_list_obj)
66
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
67
67
  end
68
68
  end
69
69
  end
@@ -146,6 +146,15 @@ describe Chef::Provider::Package::Chocolatey do
146
146
  )
147
147
  end
148
148
 
149
+ it "installing a package that does not exist throws an error" do
150
+ new_resource.package_name("package-does-not-exist")
151
+ new_resource.returns([0])
152
+ allow(provider).to receive(:shell_out_compacted!)
153
+ .with(choco_exe, "list", "-r", "#{new_resource.package_name.first}", { returns: new_resource.returns, timeout: timeout })
154
+ .and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
155
+ expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
156
+ end
157
+
149
158
  it "should set the current_resource.version to nil when the package is not installed" do
150
159
  provider.load_current_resource
151
160
  expect(provider.current_resource.version).to eql([nil])
@@ -186,7 +195,7 @@ describe Chef::Provider::Package::Chocolatey do
186
195
  it "should install a single package" do
187
196
  allow_remote_list(["git"])
188
197
  provider.load_current_resource
189
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
198
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
190
199
  provider.run_action(:install)
191
200
  expect(new_resource).to be_updated_by_last_action
192
201
  end
@@ -197,7 +206,7 @@ describe Chef::Provider::Package::Chocolatey do
197
206
  allow_remote_list(["git"])
198
207
  new_resource.timeout(timeout)
199
208
  provider.load_current_resource
200
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
209
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
201
210
  provider.run_action(:install)
202
211
  expect(new_resource).to be_updated_by_last_action
203
212
  end
@@ -226,7 +235,7 @@ describe Chef::Provider::Package::Chocolatey do
226
235
  new_resource.package_name("ConEmu")
227
236
  new_resource.version("15.10.25.1")
228
237
  provider.load_current_resource
229
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0], timeout: timeout }).and_return(double)
238
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
230
239
  provider.run_action(:install)
231
240
  expect(new_resource).to be_updated_by_last_action
232
241
  end
@@ -239,7 +248,7 @@ describe Chef::Provider::Package::Chocolatey do
239
248
  new_resource.package_name(%w{chocolatey ConEmu})
240
249
  new_resource.version([nil, "15.10.25.1"])
241
250
  provider.load_current_resource
242
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0], timeout: timeout }).and_return(double)
251
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
243
252
  provider.run_action(:install)
244
253
  expect(new_resource).to be_updated_by_last_action
245
254
  end
@@ -249,7 +258,7 @@ describe Chef::Provider::Package::Chocolatey do
249
258
  new_resource.package_name("conemu")
250
259
  new_resource.version("15.10.25.1")
251
260
  provider.load_current_resource
252
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0], timeout: timeout }).and_return(double)
261
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
253
262
  provider.run_action(:install)
254
263
  expect(new_resource).to be_updated_by_last_action
255
264
  end
@@ -259,8 +268,8 @@ describe Chef::Provider::Package::Chocolatey do
259
268
  new_resource.package_name(%w{ConEmu git})
260
269
  new_resource.version(["15.10.25.1", nil])
261
270
  provider.load_current_resource
262
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0], timeout: timeout }).and_return(double)
263
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
271
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "--version", "15.10.25.1", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
272
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
264
273
  provider.run_action(:install)
265
274
  expect(new_resource).to be_updated_by_last_action
266
275
  end
@@ -269,7 +278,7 @@ describe Chef::Provider::Package::Chocolatey do
269
278
  allow_remote_list(%w{git munin-node})
270
279
  new_resource.package_name(%w{git munin-node})
271
280
  provider.load_current_resource
272
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", "munin-node", { returns: [0], timeout: timeout }).and_return(double)
281
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", "munin-node", { returns: [0, 2], timeout: timeout }).and_return(double)
273
282
  provider.run_action(:install)
274
283
  expect(new_resource).to be_updated_by_last_action
275
284
  end
@@ -279,17 +288,17 @@ describe Chef::Provider::Package::Chocolatey do
279
288
  allow_remote_list(["git"], ["-source", "localpackages"])
280
289
  new_resource.source("localpackages")
281
290
  provider.load_current_resource
282
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-source", "localpackages", "git", { returns: [0], timeout: timeout }).and_return(double)
291
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-source", "localpackages", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
283
292
  provider.run_action(:install)
284
293
  expect(new_resource).to be_updated_by_last_action
285
294
  end
286
295
  end
287
296
 
288
297
  it "should pass options into the install command" do
289
- allow_remote_list(["git"], "-force")
298
+ allow_remote_list(["git"])
290
299
  new_resource.options("-force")
291
300
  provider.load_current_resource
292
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-force", "git", { returns: [0], timeout: timeout }).and_return(double)
301
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-force", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
293
302
  provider.run_action(:install)
294
303
  expect(new_resource).to be_updated_by_last_action
295
304
  end
@@ -319,31 +328,37 @@ describe Chef::Provider::Package::Chocolatey do
319
328
  end
320
329
 
321
330
  context "private source" do
322
- it "installing a package without auth options throws an error" do
323
- allow_remote_list(["package-without-auth"], ["-source", "auth_source"])
324
- new_resource.package_name("package-without-auth")
331
+ it "installing a package with valid credentials" do
332
+ allow_remote_list(["git"], ["-source", "auth_source", "--user", "ubuntu", "--password", "ubuntu@123"])
325
333
  new_resource.source("auth_source")
334
+ new_resource.user("ubuntu")
335
+ new_resource.password("ubuntu@123")
326
336
  provider.load_current_resource
327
- expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
337
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-source", "auth_source", "--user", "ubuntu", "--password", "ubuntu@123", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
338
+ provider.run_action(:install)
339
+ expect(new_resource).to be_updated_by_last_action
328
340
  end
329
341
 
330
342
  it "installing a package with invalid credentials throws an error" do
331
- allow_remote_list(["package-invalid-auth"], [ "-source", "auth_source", "-u user -p password"])
343
+ allow_remote_list(["package-invalid-auth"], ["-source", "auth_source", "--user", "ubuntu", "--password", "ubuntu@123"])
332
344
  new_resource.package_name("package-invalid-auth")
333
345
  new_resource.source("auth_source")
334
- new_resource.options("-u user -p password")
346
+ new_resource.user("ubuntu")
347
+ new_resource.password("ubuntu@123")
335
348
  provider.load_current_resource
336
349
  expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
337
350
  end
338
351
 
339
- it "installing a package with valid credentials" do
340
- allow_remote_list(["git"], [ "-source", "auth_source", "-u user -p password" ])
352
+ it "only credentials and list options pass into the list command" do
353
+ allow_remote_list(["git"], ["-source", "auth_source", "--user", "ubuntu", "--password", "ubuntu@123", "--local-only"])
341
354
  new_resource.source("auth_source")
342
- new_resource.options("-u user -p password")
355
+ new_resource.list_options("--local-only")
356
+ new_resource.user("ubuntu")
357
+ new_resource.password("ubuntu@123")
343
358
  provider.load_current_resource
344
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-u user -p password", "-source", "auth_source", "git", { returns: [0], timeout: timeout }).and_return(double)
345
- provider.run_action(:install)
346
- expect(new_resource).to be_updated_by_last_action
359
+ expect(provider.send(:available_packages)).to eql(
360
+ { "chocolatey" => "0.9.9.11", "conemu" => "15.10.25.1", "git" => "2.6.2", "munin-node" => "1.6.1.20130823" }
361
+ )
347
362
  end
348
363
  end
349
364
  end
@@ -352,7 +367,7 @@ describe Chef::Provider::Package::Chocolatey do
352
367
  it "should install a package that is not installed" do
353
368
  allow_remote_list(["git"])
354
369
  provider.load_current_resource
355
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
370
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
356
371
  provider.run_action(:upgrade)
357
372
  expect(new_resource).to be_updated_by_last_action
358
373
  end
@@ -361,7 +376,7 @@ describe Chef::Provider::Package::Chocolatey do
361
376
  allow_remote_list(["ConEmu"])
362
377
  new_resource.package_name("ConEmu")
363
378
  provider.load_current_resource
364
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
379
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
365
380
  provider.run_action(:upgrade)
366
381
  expect(new_resource).to be_updated_by_last_action
367
382
  end
@@ -370,7 +385,7 @@ describe Chef::Provider::Package::Chocolatey do
370
385
  allow_remote_list(["conemu"])
371
386
  new_resource.package_name("conemu")
372
387
  provider.load_current_resource
373
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
388
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
374
389
  provider.run_action(:upgrade)
375
390
  expect(new_resource).to be_updated_by_last_action
376
391
  end
@@ -379,7 +394,7 @@ describe Chef::Provider::Package::Chocolatey do
379
394
  allow_remote_list(["chocolatey"])
380
395
  new_resource.package_name("chocolatey")
381
396
  provider.load_current_resource
382
- expect(provider).not_to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "chocolatey", { returns: [0], timeout: timeout })
397
+ expect(provider).not_to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "chocolatey", { returns: [0, 2], timeout: timeout })
383
398
  provider.run_action(:upgrade)
384
399
  expect(new_resource).not_to be_updated_by_last_action
385
400
  end
@@ -388,7 +403,7 @@ describe Chef::Provider::Package::Chocolatey do
388
403
  allow_remote_list(["git"])
389
404
  new_resource.version("2.6.2")
390
405
  provider.load_current_resource
391
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "--version", "2.6.2", "git", { returns: [0], timeout: timeout })
406
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "--version", "2.6.2", "git", { returns: [0, 2], timeout: timeout })
392
407
  provider.run_action(:upgrade)
393
408
  expect(new_resource).to be_updated_by_last_action
394
409
  end
@@ -396,7 +411,7 @@ describe Chef::Provider::Package::Chocolatey do
396
411
  it "upgrading multiple packages uses a single command" do
397
412
  allow_remote_list(%w{conemu git})
398
413
  new_resource.package_name(%w{conemu git})
399
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", "git", { returns: [0], timeout: timeout }).and_return(double)
414
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", "git", { returns: [0, 2], timeout: timeout }).and_return(double)
400
415
  provider.run_action(:upgrade)
401
416
  expect(new_resource).to be_updated_by_last_action
402
417
  end
@@ -448,7 +463,7 @@ describe Chef::Provider::Package::Chocolatey do
448
463
  allow_remote_list(["ConEmu"])
449
464
  new_resource.package_name("ConEmu")
450
465
  provider.load_current_resource
451
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "ConEmu", { returns: [0], timeout: timeout }).and_return(double)
466
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "ConEmu", { returns: [0, 2], timeout: timeout }).and_return(double)
452
467
  provider.run_action(:remove)
453
468
  expect(new_resource).to be_updated_by_last_action
454
469
  end
@@ -457,7 +472,7 @@ describe Chef::Provider::Package::Chocolatey do
457
472
  allow_remote_list(["conemu"])
458
473
  new_resource.package_name("conemu")
459
474
  provider.load_current_resource
460
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
475
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
461
476
  provider.run_action(:remove)
462
477
  expect(new_resource).to be_updated_by_last_action
463
478
  end
@@ -467,7 +482,7 @@ describe Chef::Provider::Package::Chocolatey do
467
482
  allow_remote_list(%w{git conemu})
468
483
  new_resource.package_name(%w{git conemu})
469
484
  provider.load_current_resource
470
- expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
485
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0, 2], timeout: timeout }).and_return(double)
471
486
  provider.run_action(:remove)
472
487
  expect(new_resource).to be_updated_by_last_action
473
488
  end
@@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do
126
126
  it "removes installed package and quotes uninstall string" do
127
127
  new_resource.timeout = 300
128
128
  allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true)
129
- expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, timeout: 300, returns: [0])
129
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, default_env: false, timeout: 300, returns: [0])
130
130
  provider.remove_package
131
131
  end
132
132
  end
@@ -19,9 +19,17 @@
19
19
 
20
20
  require "spec_helper"
21
21
 
22
- describe Chef::Provider::Service::Windows, "load_current_resource", :windows_only do
22
+ describe Chef::Provider::Service::Windows, "load_current_resource" do
23
23
  include_context "Win32"
24
24
 
25
+ before(:all) do
26
+ Chef::ReservedNames::Win32::Security = Class.new unless windows?
27
+ end
28
+
29
+ after(:all) do
30
+ Chef::ReservedNames::Win32.send(:remove_const, :Security) unless windows?
31
+ end
32
+
25
33
  let(:logger) { double("Mixlib::Log::Child").as_null_object }
26
34
 
27
35
  let(:chef_service_name) { "chef-client" }
@@ -105,7 +113,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
105
113
  allow(Win32::Service).to receive(:exists?).and_return(true)
106
114
  allow(Win32::Service).to receive(:configure).and_return(Win32::Service)
107
115
  allow(Chef::ReservedNames::Win32::Security).to receive(:get_account_right).and_return([])
108
- allow(Chef::ReservedNames::Win32::Security).to receive(:add_account_right).with("LocalSystem", "SeServiceLogonRight").and_return(0)
116
+ allow(Chef::ReservedNames::Win32::Security).to receive(:add_account_right).with("localsystem", "SeServiceLogonRight").and_return(0)
109
117
  end
110
118
 
111
119
  after(:each) do
@@ -293,7 +301,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
293
301
  start_type: 2,
294
302
  error_control: 1,
295
303
  binary_path_name: chef_service_binary_path_name,
296
- service_start_name: "LocalSystem",
304
+ service_start_name: "localsystem",
297
305
  desired_access: 983551
298
306
  )
299
307
  provider.action_create
@@ -384,6 +392,18 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
384
392
  provider.action_configure
385
393
  end
386
394
 
395
+ it "does not configure service when run_as_user case is different" do
396
+ provider.current_resource.run_as_user = "JohnDoe"
397
+ provider.new_resource.run_as_user = "johndoe"
398
+ expect(Win32::Service).not_to receive(:configure)
399
+ provider.action_configure
400
+
401
+ provider.current_resource.run_as_user = "johndoe"
402
+ provider.new_resource.run_as_user = "JohnDoe"
403
+ expect(Win32::Service).not_to receive(:configure)
404
+ provider.action_configure
405
+ end
406
+
387
407
  it "calls converge_delayed_start" do
388
408
  expect(provider).to receive(:converge_delayed_start)
389
409
  provider.action_configure
@@ -77,8 +77,23 @@ describe Chef::Resource::ChocolateyPackage do
77
77
  expect(resource.version).to eql(["1.2.3", "4.5.6"])
78
78
  end
79
79
 
80
- it "the default returns is 0" do
81
- expect(resource.returns).to eql([0])
80
+ it "sets the list_options" do
81
+ resource.list_options("--local-only")
82
+ expect(resource.list_options).to eql("--local-only")
83
+ end
84
+
85
+ it "sets the user" do
86
+ resource.user("ubuntu")
87
+ expect(resource.user).to eql("ubuntu")
88
+ end
89
+
90
+ it "sets the password" do
91
+ resource.password("ubuntu@123")
92
+ expect(resource.password).to eql("ubuntu@123")
93
+ end
94
+
95
+ it "the default returns are 0 and 2" do
96
+ expect(resource.returns).to eql([0, 2])
82
97
  end
83
98
 
84
99
  # Integer, Array
@@ -36,6 +36,10 @@ describe Chef::Resource::WindowsAdJoin do
36
36
  expect { resource.action :join }.not_to raise_error
37
37
  end
38
38
 
39
+ it "supports :leave action" do
40
+ expect { resource.action :leave }.not_to raise_error
41
+ end
42
+
39
43
  it "only accepts FQDNs for the domain_name property" do
40
44
  expect { resource.domain_name "example" }.to raise_error(ArgumentError)
41
45
  end
@@ -105,4 +105,9 @@ describe Chef::Resource::WindowsService, "initialize" do
105
105
  expect(resource.send(prop)).to eq(true)
106
106
  end
107
107
  end
108
+
109
+ it "lowercases run_as_user" do
110
+ resource.run_as_user = "JohnDoe"
111
+ expect(resource.run_as_user).to eq("johndoe")
112
+ end
108
113
  end
@@ -36,4 +36,11 @@ describe Chef::Resource::WindowsShare do
36
36
  expect { resource.action :create }.not_to raise_error
37
37
  expect { resource.action :delete }.not_to raise_error
38
38
  end
39
+
40
+ it "coerces path to a single path separator format" do
41
+ resource.path("C:/chef")
42
+ expect(resource.path).to eql("C:\\chef")
43
+ resource.path("C:\\chef")
44
+ expect(resource.path).to eql("C:\\chef")
45
+ end
39
46
  end
data/tasks/docs.rb CHANGED
@@ -327,7 +327,10 @@ The <%= @name %> resource has the following properties:
327
327
  <% if @properties.empty? %>This resource does not have any properties.\n<% end -%>
328
328
  <%= boilerplate_content %>
329
329
  Examples
330
- ==========================================
330
+ =====================================================
331
+
332
+ The following examples demonstrate various approaches for using resources in recipes:
333
+
331
334
  <%= @examples -%>
332
335
  }
333
336
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.3.14
4
+ version: 15.4.45
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 15.3.14
19
+ version: 15.4.45
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 15.3.14
26
+ version: 15.4.45
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: train-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-winrm
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.2.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.2.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: license-acceptance
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -2385,6 +2385,8 @@ files:
2385
2385
  - spec/unit/knife/status_spec.rb
2386
2386
  - spec/unit/knife/supermarket_download_spec.rb
2387
2387
  - spec/unit/knife/supermarket_install_spec.rb
2388
+ - spec/unit/knife/supermarket_list_spec.rb
2389
+ - spec/unit/knife/supermarket_search_spec.rb
2388
2390
  - spec/unit/knife/supermarket_share_spec.rb
2389
2391
  - spec/unit/knife/supermarket_unshare_spec.rb
2390
2392
  - spec/unit/knife/tag_create_spec.rb