chef 15.2.20-universal-mingw32 → 15.3.14-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/chef.gemspec +3 -2
  4. data/lib/chef/application.rb +1 -1
  5. data/lib/chef/application/base.rb +7 -0
  6. data/lib/chef/application/client.rb +6 -2
  7. data/lib/chef/application/solo.rb +7 -1
  8. data/lib/chef/cookbook/gem_installer.rb +7 -2
  9. data/lib/chef/exceptions.rb +12 -0
  10. data/lib/chef/knife/bootstrap.rb +8 -1
  11. data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
  12. data/lib/chef/knife/bootstrap/train_connector.rb +3 -3
  13. data/lib/chef/knife/cookbook_metadata_from_file.rb +1 -1
  14. data/lib/chef/node.rb +0 -2
  15. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  16. data/lib/chef/policy_builder/policyfile.rb +4 -3
  17. data/lib/chef/provider.rb +4 -2
  18. data/lib/chef/provider/ifconfig.rb +5 -3
  19. data/lib/chef/provider/package/chocolatey.rb +12 -22
  20. data/lib/chef/provider/user.rb +1 -1
  21. data/lib/chef/provider/user/dscl.rb +2 -2
  22. data/lib/chef/provider/user/mac.rb +628 -0
  23. data/lib/chef/providers.rb +1 -0
  24. data/lib/chef/resource.rb +28 -20
  25. data/lib/chef/resource/chocolatey_feature.rb +1 -1
  26. data/lib/chef/resource/chocolatey_package.rb +2 -2
  27. data/lib/chef/resource/cron_d.rb +1 -1
  28. data/lib/chef/resource/ohai.rb +1 -1
  29. data/lib/chef/resource/resource_notification.rb +17 -13
  30. data/lib/chef/resource/ruby_block.rb +1 -1
  31. data/lib/chef/resource/service.rb +1 -1
  32. data/lib/chef/resource/user.rb +1 -0
  33. data/lib/chef/resource/user/dscl_user.rb +1 -1
  34. data/lib/chef/resource/user/mac_user.rb +119 -0
  35. data/lib/chef/resource/windows_ad_join.rb +1 -1
  36. data/lib/chef/resource_collection.rb +6 -0
  37. data/lib/chef/resources.rb +1 -0
  38. data/lib/chef/run_context.rb +61 -27
  39. data/lib/chef/runner.rb +50 -12
  40. data/lib/chef/version.rb +1 -1
  41. data/spec/functional/resource/chocolatey_package_spec.rb +19 -1
  42. data/spec/functional/resource/user/mac_user_spec.rb +207 -0
  43. data/spec/integration/client/client_spec.rb +22 -0
  44. data/spec/integration/knife/raw_spec.rb +39 -19
  45. data/spec/integration/knife/redirection_spec.rb +22 -13
  46. data/spec/integration/knife/serve_spec.rb +1 -2
  47. data/spec/integration/recipes/unified_mode_spec.rb +876 -0
  48. data/spec/spec_helper.rb +1 -0
  49. data/spec/support/platform_helpers.rb +10 -0
  50. data/spec/support/shared/integration/integration_helper.rb +1 -2
  51. data/spec/unit/application/client_spec.rb +5 -6
  52. data/spec/unit/application/solo_spec.rb +3 -8
  53. data/spec/unit/application_spec.rb +1 -1
  54. data/spec/unit/cookbook/gem_installer_spec.rb +22 -1
  55. data/spec/unit/knife/bootstrap/train_connector_spec.rb +20 -7
  56. data/spec/unit/knife/bootstrap_spec.rb +13 -5
  57. data/spec/unit/provider/ifconfig_spec.rb +11 -0
  58. data/spec/unit/provider/package/chocolatey_spec.rb +34 -30
  59. data/spec/unit/provider/user/dscl_spec.rb +1 -0
  60. data/spec/unit/provider/user/mac_spec.rb +38 -0
  61. data/spec/unit/provider/user_spec.rb +38 -22
  62. data/tasks/docs.rb +14 -10
  63. metadata +25 -13
  64. data/spec/support/shared/integration/app_server_support.rb +0 -39
@@ -145,6 +145,7 @@ RSpec.configure do |config|
145
145
  config.filter_run_excluding not_supported_on_windows: true if windows?
146
146
  config.filter_run_excluding not_supported_on_macos: true if mac_osx?
147
147
  config.filter_run_excluding macos_only: true unless mac_osx?
148
+ config.filter_run_excluding macos_1014: true unless mac_osx_1014?
148
149
  config.filter_run_excluding not_supported_on_aix: true if aix?
149
150
  config.filter_run_excluding not_supported_on_solaris: true if solaris?
150
151
  config.filter_run_excluding not_supported_on_gce: true if gce?
@@ -3,6 +3,7 @@ require "chef/mixin/shell_out"
3
3
  require "ohai/mixin/http_helper"
4
4
  require "ohai/mixin/gce_metadata"
5
5
  require "chef/mixin/powershell_out"
6
+ require "chef/version_class"
6
7
 
7
8
  class ShellHelpers
8
9
  extend Chef::Mixin::ShellOut
@@ -110,6 +111,15 @@ def mac_osx_106?
110
111
  false
111
112
  end
112
113
 
114
+ def mac_osx_1014?
115
+ if mac_osx?
116
+ ver = Chef::Version.new(ohai[:platform_version])
117
+ return ver.major == 10 && ver.minor == 14
118
+ end
119
+
120
+ false
121
+ end
122
+
113
123
  def mac_osx?
114
124
  if File.exists? "/usr/bin/sw_vers"
115
125
  result = ShellHelpers.shell_out("/usr/bin/sw_vers")
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: John Keiser (<jkeiser@chef.io>)
3
3
  # Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
4
- # Copyright:: Copyright 2012-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2012-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,6 @@ require "chef/config"
23
23
  require "chef/json_compat"
24
24
  require "chef/server_api"
25
25
  require "support/shared/integration/knife_support"
26
- require "support/shared/integration/app_server_support"
27
26
  require "cheffish/rspec/chef_run_support"
28
27
  require "spec_helper"
29
28
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  # Author:: AJ Christensen (<aj@junglist.gen.nz>)
3
- # Copyright:: Copyright 2008-2018, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,7 +85,6 @@ describe Chef::Application::Client, "reconfigure" do
85
85
 
86
86
  allow(app).to receive(:trap)
87
87
  allow(app).to receive(:configure_logging).and_return(true)
88
- Chef::Config[:interval] = 10
89
88
 
90
89
  Chef::Config[:once] = false
91
90
 
@@ -162,7 +161,7 @@ describe Chef::Application::Client, "reconfigure" do
162
161
  it_behaves_like "sets the configuration", "--no-fork", client_fork: false
163
162
  end
164
163
 
165
- context "with an interval" do
164
+ context "with an interval", :unix_only do
166
165
  it_behaves_like "sets the configuration", "--interval 1800", client_fork: true
167
166
  end
168
167
 
@@ -322,7 +321,7 @@ describe Chef::Application::Client, "reconfigure" do
322
321
  Chef::Config[:splay] = nil
323
322
  end
324
323
 
325
- it "should terminal with message when interval is given" do
324
+ it "should terminate with message when interval is given" do
326
325
  Chef::Config[:interval] = 600
327
326
  allow(ChefConfig).to receive(:windows?).and_return(false)
328
327
  expect(Chef::Application).to receive(:fatal!).with(
@@ -340,8 +339,8 @@ Enable .* interval runs by setting `:client_fork = true` in your config file or
340
339
  allow(ChefConfig).to receive(:windows?).and_return(true)
341
340
  end
342
341
 
343
- it "should not terminate" do
344
- expect(Chef::Application).not_to receive(:fatal!)
342
+ it "should terminate" do
343
+ expect(Chef::Application).to receive(:fatal!)
345
344
  app.reconfigure
346
345
  end
347
346
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: AJ Christensen (<aj@junglist.gen.nz>)
3
- # Copyright:: Copyright 2008-2018, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -64,18 +64,13 @@ describe Chef::Application::Solo do
64
64
  end
65
65
 
66
66
  it "should terminate with message" do
67
- expect(Chef::Application).to receive(:fatal!).with(
68
- /Unforked .* interval runs are disabled by default\.
69
- Configuration settings:
70
- interval = 600 seconds
71
- Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./
72
- )
67
+ expect(Chef::Application).to receive(:fatal!).with(/interval runs are (disabled|not supported)/)
73
68
  app.reconfigure
74
69
  end
75
70
  end
76
71
  end
77
72
 
78
- describe "when in daemonized mode and no interval has been set" do
73
+ describe "when in daemonized mode and no interval has been set", :unix_only do
79
74
  before do
80
75
  Chef::Config[:daemonize] = true
81
76
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: AJ Christensen (<aj@junglist.gen.nz>)
3
3
  # Author:: Mark Mzyk (mmzyk@chef.io)
4
- # Copyright:: Copyright 2008-2018, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -59,23 +59,25 @@ describe Chef::Cookbook::GemInstaller do
59
59
  expect(File).to receive(:open).and_yield(gemfile)
60
60
  expect(gemfile).to receive(:path).and_return("")
61
61
  expect(IO).to receive(:read).and_return("")
62
- expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
63
62
 
64
63
  end
65
64
 
66
65
  it "generates a valid Gemfile" do
66
+ expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
67
67
  expect { gem_installer.install }.to_not raise_error
68
68
 
69
69
  expect { bundler_dsl }.to_not raise_error
70
70
  end
71
71
 
72
72
  it "generate a Gemfile with all constraints" do
73
+ expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
73
74
  expect { gem_installer.install }.to_not raise_error
74
75
 
75
76
  expect(bundler_dsl.dependencies.find { |d| d.name == "httpclient" }.requirements_list.length).to eql(2)
76
77
  end
77
78
 
78
79
  it "generates a valid Gemfile when Chef::Config[:rubygems_url] is set to a String" do
80
+ expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
79
81
  Chef::Config[:rubygems_url] = "https://www.rubygems.org"
80
82
  expect { gem_installer.install }.to_not raise_error
81
83
 
@@ -83,10 +85,29 @@ describe Chef::Cookbook::GemInstaller do
83
85
  end
84
86
 
85
87
  it "generates a valid Gemfile when Chef::Config[:rubygems_url] is set to an Array" do
88
+ expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
86
89
  Chef::Config[:rubygems_url] = [ "https://www.rubygems.org" ]
87
90
 
88
91
  expect { gem_installer.install }.to_not raise_error
89
92
 
90
93
  expect(bundler_dsl.dependencies.find { |d| d.name == "httpclient" }.requirements_list.length).to eql(2)
91
94
  end
95
+
96
+ it "skip metadata installation when Chef::Config[:skip_gem_metadata_installation] is set to true" do
97
+ Chef::Config[:skip_gem_metadata_installation] = true
98
+ expect(gem_installer.install).to_not receive(:shell_out!)
99
+ end
100
+
101
+ it "install metadata when Chef::Config[:skip_gem_metadata_installation] is not true" do
102
+ expect(gem_installer).to receive(:shell_out!).and_return(shell_out)
103
+ expect(Chef::Log).to receive(:info).and_return("")
104
+ expect(gem_installer.install).to be_nil
105
+ end
106
+
107
+ it "install from local cache when Chef::Config[:gem_installer_bundler_options] is set to local" do
108
+ Chef::Config[:gem_installer_bundler_options] = "--local"
109
+ expect(gem_installer).to receive(:shell_out!).with(["bundle", "install", "--local"], any_args).and_return(shell_out)
110
+ expect(Chef::Log).to receive(:info).and_return("")
111
+ expect(gem_installer.install).to be_nil
112
+ end
92
113
  end
@@ -162,16 +162,29 @@ describe Chef::Knife::Bootstrap::TrainConnector do
162
162
  allow(SecureRandom).to receive(:alphanumeric).with(6).and_return(random)
163
163
  end
164
164
 
165
- it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do
166
- expected_command = "mkdir -p #{dir} && sudo chown user1 '#{dir}'"
167
- expect(subject).to receive(:run_command!).with(expected_command)
168
- .and_return double("result", stdout: "\r\n")
169
- expect(subject.temp_dir).to eq(dir)
165
+ context "uses the *nix command to create the temp dir and sets ownership to logged-in" do
166
+ it "with sudo privilege" do
167
+ subject.config[:sudo] = true
168
+ expected_command1 = "mkdir -p '#{dir}'"
169
+ expected_command2 = "chown user1 '#{dir}'"
170
+ expect(subject).to receive(:run_command!).with(expected_command1)
171
+ .and_return double("result", stdout: "\r\n")
172
+ expect(subject).to receive(:run_command!).with(expected_command2)
173
+ .and_return double("result", stdout: "\r\n")
174
+ expect(subject.temp_dir).to eq(dir)
175
+ end
176
+
177
+ it "without sudo privilege" do
178
+ expected_command = "mkdir -p '#{dir}'"
179
+ expect(subject).to receive(:run_command!).with(expected_command)
180
+ .and_return double("result", stdout: "\r\n")
181
+ expect(subject.temp_dir).to eq(dir)
182
+ end
170
183
  end
171
184
 
172
185
  context "with noise in stderr" do
173
- it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do
174
- expected_command = "mkdir -p #{dir} && sudo chown user1 '#{dir}'"
186
+ it "uses the *nix command to create the temp dir" do
187
+ expected_command = "mkdir -p '#{dir}'"
175
188
  expect(subject).to receive(:run_command!).with(expected_command)
176
189
  .and_return double("result", stdout: "sudo: unable to resolve host hostname.localhost\r\n" + "#{dir}\r\n")
177
190
  expect(subject.temp_dir).to eq(dir)
@@ -1021,7 +1021,6 @@ describe Chef::Knife::Bootstrap do
1021
1021
  verify_host_key: nil,
1022
1022
  port: 9999,
1023
1023
  non_interactive: true,
1024
- pty: true,
1025
1024
  }
1026
1025
  end
1027
1026
 
@@ -1076,7 +1075,6 @@ describe Chef::Knife::Bootstrap do
1076
1075
  verify_host_key: nil, # Config
1077
1076
  port: 12, # cli
1078
1077
  non_interactive: true,
1079
- pty: true,
1080
1078
  }
1081
1079
  end
1082
1080
 
@@ -1128,7 +1126,6 @@ describe Chef::Knife::Bootstrap do
1128
1126
  sudo_password: "blah",
1129
1127
  verify_host_key: true,
1130
1128
  non_interactive: true,
1131
- pty: true,
1132
1129
  }
1133
1130
  end
1134
1131
  it "generates a config hash using the CLI options and pulling nothing from Chef::Config" do
@@ -1152,7 +1149,6 @@ describe Chef::Knife::Bootstrap do
1152
1149
  sudo: false,
1153
1150
  verify_host_key: "always",
1154
1151
  non_interactive: true,
1155
- pty: true,
1156
1152
  connection_timeout: 60,
1157
1153
  }
1158
1154
  end
@@ -1504,7 +1500,6 @@ describe Chef::Knife::Bootstrap do
1504
1500
  let(:default_opts) do
1505
1501
  {
1506
1502
  non_interactive: true,
1507
- pty: true,
1508
1503
  forward_agent: false,
1509
1504
  connection_timeout: 60,
1510
1505
  }
@@ -2003,6 +1998,19 @@ describe Chef::Knife::Bootstrap do
2003
1998
  expect(connection).to receive(:connect!)
2004
1999
  knife.do_connect({})
2005
2000
  end
2001
+
2002
+ context "when sshd confgiured with requiretty" do
2003
+ let(:pty_err_msg) { "Sudo requires a TTY. Please see the README on how to configure sudo to allow for non-interactive usage." }
2004
+ let(:expected_error) { Train::UserError.new(pty_err_msg, :sudo_no_tty) }
2005
+ before do
2006
+ allow(connection).to receive(:connect!).and_raise(expected_error)
2007
+ end
2008
+ it "retry with pty true request option" do
2009
+ expect(Chef::Knife::Bootstrap::TrainConnector).to receive(:new).and_return(connection).exactly(2).times
2010
+ expect(knife.ui).to receive(:warn).with("#{pty_err_msg} - trying with pty request")
2011
+ expect { knife.do_connect({}) }.to raise_error(expected_error)
2012
+ end
2013
+ end
2006
2014
  end
2007
2015
 
2008
2016
  describe "validate_winrm_transport_opts!" do
@@ -94,6 +94,17 @@ describe Chef::Provider::Ifconfig do
94
94
  expect(@new_resource).not_to be_updated
95
95
  end
96
96
 
97
+ it "should add a bridge interface" do
98
+ allow(@provider).to receive(:load_current_resource)
99
+ @new_resource.device "br-1234"
100
+ command = "ifconfig br-1234 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
101
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
102
+ expect(@provider).to receive(:generate_config)
103
+
104
+ @provider.run_action(:add)
105
+ expect(@new_resource).to be_updated
106
+ end
107
+
97
108
  # We are not testing this case with the assumption that anyone writing the cookbook would not make a typo == lo
98
109
  # it "should add a blank command if the #{@new_resource.device} == lo" do
99
110
  # end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -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], timeout: timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
52
  def allow_remote_list(package_names, args = nil)
@@ -60,7 +60,11 @@ describe Chef::Provider::Package::Chocolatey do
60
60
  EOF
61
61
  remote_list_obj = double(stdout: remote_list_stdout)
62
62
  package_names.each do |pkg|
63
- allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { returns: [0], timeout: timeout }).and_return(remote_list_obj)
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)
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)
67
+ end
64
68
  end
65
69
  end
66
70
 
@@ -182,7 +186,7 @@ describe Chef::Provider::Package::Chocolatey do
182
186
  it "should install a single package" do
183
187
  allow_remote_list(["git"])
184
188
  provider.load_current_resource
185
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
189
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
186
190
  provider.run_action(:install)
187
191
  expect(new_resource).to be_updated_by_last_action
188
192
  end
@@ -193,7 +197,7 @@ describe Chef::Provider::Package::Chocolatey do
193
197
  allow_remote_list(["git"])
194
198
  new_resource.timeout(timeout)
195
199
  provider.load_current_resource
196
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
200
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
197
201
  provider.run_action(:install)
198
202
  expect(new_resource).to be_updated_by_last_action
199
203
  end
@@ -222,7 +226,7 @@ describe Chef::Provider::Package::Chocolatey do
222
226
  new_resource.package_name("ConEmu")
223
227
  new_resource.version("15.10.25.1")
224
228
  provider.load_current_resource
225
- 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)
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)
226
230
  provider.run_action(:install)
227
231
  expect(new_resource).to be_updated_by_last_action
228
232
  end
@@ -235,7 +239,7 @@ describe Chef::Provider::Package::Chocolatey do
235
239
  new_resource.package_name(%w{chocolatey ConEmu})
236
240
  new_resource.version([nil, "15.10.25.1"])
237
241
  provider.load_current_resource
238
- 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)
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)
239
243
  provider.run_action(:install)
240
244
  expect(new_resource).to be_updated_by_last_action
241
245
  end
@@ -245,7 +249,7 @@ describe Chef::Provider::Package::Chocolatey do
245
249
  new_resource.package_name("conemu")
246
250
  new_resource.version("15.10.25.1")
247
251
  provider.load_current_resource
248
- 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)
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)
249
253
  provider.run_action(:install)
250
254
  expect(new_resource).to be_updated_by_last_action
251
255
  end
@@ -255,8 +259,8 @@ describe Chef::Provider::Package::Chocolatey do
255
259
  new_resource.package_name(%w{ConEmu git})
256
260
  new_resource.version(["15.10.25.1", nil])
257
261
  provider.load_current_resource
258
- 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)
259
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
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)
260
264
  provider.run_action(:install)
261
265
  expect(new_resource).to be_updated_by_last_action
262
266
  end
@@ -265,27 +269,27 @@ describe Chef::Provider::Package::Chocolatey do
265
269
  allow_remote_list(%w{git munin-node})
266
270
  new_resource.package_name(%w{git munin-node})
267
271
  provider.load_current_resource
268
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double)
272
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "git", "munin-node", { returns: [0], timeout: timeout }).and_return(double)
269
273
  provider.run_action(:install)
270
274
  expect(new_resource).to be_updated_by_last_action
271
275
  end
272
276
 
273
277
  context "when passing a source argument" do
274
278
  it "should pass options into the install command" do
275
- allow_remote_list(["git"], " -source localpackages")
279
+ allow_remote_list(["git"], ["-source", "localpackages"])
276
280
  new_resource.source("localpackages")
277
281
  provider.load_current_resource
278
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { returns: [0], timeout: timeout }).and_return(double)
282
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-source", "localpackages", "git", { returns: [0], timeout: timeout }).and_return(double)
279
283
  provider.run_action(:install)
280
284
  expect(new_resource).to be_updated_by_last_action
281
285
  end
282
286
  end
283
287
 
284
288
  it "should pass options into the install command" do
285
- allow_remote_list(["git"], " -force")
289
+ allow_remote_list(["git"], "-force")
286
290
  new_resource.options("-force")
287
291
  provider.load_current_resource
288
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { returns: [0], timeout: timeout }).and_return(double)
292
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "install", "-y", "-force", "git", { returns: [0], timeout: timeout }).and_return(double)
289
293
  provider.run_action(:install)
290
294
  expect(new_resource).to be_updated_by_last_action
291
295
  end
@@ -306,7 +310,7 @@ describe Chef::Provider::Package::Chocolatey do
306
310
 
307
311
  context "alternate source" do
308
312
  it "installing a package that does not exist throws an error" do
309
- allow_remote_list(["package-does-not-exist"], " -source alternate_source")
313
+ allow_remote_list(["package-does-not-exist"], ["-source", "alternate_source"])
310
314
  new_resource.package_name("package-does-not-exist")
311
315
  new_resource.source("alternate_source")
312
316
  provider.load_current_resource
@@ -316,7 +320,7 @@ describe Chef::Provider::Package::Chocolatey do
316
320
 
317
321
  context "private source" do
318
322
  it "installing a package without auth options throws an error" do
319
- allow_remote_list(["package-without-auth"], " -source auth_source")
323
+ allow_remote_list(["package-without-auth"], ["-source", "auth_source"])
320
324
  new_resource.package_name("package-without-auth")
321
325
  new_resource.source("auth_source")
322
326
  provider.load_current_resource
@@ -324,7 +328,7 @@ describe Chef::Provider::Package::Chocolatey do
324
328
  end
325
329
 
326
330
  it "installing a package with invalid credentials throws an error" do
327
- allow_remote_list(["package-invalid-auth"], " -source auth_source -u user -p password")
331
+ allow_remote_list(["package-invalid-auth"], [ "-source", "auth_source", "-u user -p password"])
328
332
  new_resource.package_name("package-invalid-auth")
329
333
  new_resource.source("auth_source")
330
334
  new_resource.options("-u user -p password")
@@ -333,11 +337,11 @@ describe Chef::Provider::Package::Chocolatey do
333
337
  end
334
338
 
335
339
  it "installing a package with valid credentials" do
336
- allow_remote_list(["git"], " -source auth_source -u user -p password")
340
+ allow_remote_list(["git"], [ "-source", "auth_source", "-u user -p password" ])
337
341
  new_resource.source("auth_source")
338
342
  new_resource.options("-u user -p password")
339
343
  provider.load_current_resource
340
- 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)
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)
341
345
  provider.run_action(:install)
342
346
  expect(new_resource).to be_updated_by_last_action
343
347
  end
@@ -348,7 +352,7 @@ describe Chef::Provider::Package::Chocolatey do
348
352
  it "should install a package that is not installed" do
349
353
  allow_remote_list(["git"])
350
354
  provider.load_current_resource
351
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { returns: [0], timeout: timeout }).and_return(double)
355
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "git", { returns: [0], timeout: timeout }).and_return(double)
352
356
  provider.run_action(:upgrade)
353
357
  expect(new_resource).to be_updated_by_last_action
354
358
  end
@@ -357,7 +361,7 @@ describe Chef::Provider::Package::Chocolatey do
357
361
  allow_remote_list(["ConEmu"])
358
362
  new_resource.package_name("ConEmu")
359
363
  provider.load_current_resource
360
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
364
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
361
365
  provider.run_action(:upgrade)
362
366
  expect(new_resource).to be_updated_by_last_action
363
367
  end
@@ -366,7 +370,7 @@ describe Chef::Provider::Package::Chocolatey do
366
370
  allow_remote_list(["conemu"])
367
371
  new_resource.package_name("conemu")
368
372
  provider.load_current_resource
369
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
373
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
370
374
  provider.run_action(:upgrade)
371
375
  expect(new_resource).to be_updated_by_last_action
372
376
  end
@@ -375,7 +379,7 @@ describe Chef::Provider::Package::Chocolatey do
375
379
  allow_remote_list(["chocolatey"])
376
380
  new_resource.package_name("chocolatey")
377
381
  provider.load_current_resource
378
- expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { returns: [0], timeout: timeout })
382
+ expect(provider).not_to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "chocolatey", { returns: [0], timeout: timeout })
379
383
  provider.run_action(:upgrade)
380
384
  expect(new_resource).not_to be_updated_by_last_action
381
385
  end
@@ -384,7 +388,7 @@ describe Chef::Provider::Package::Chocolatey do
384
388
  allow_remote_list(["git"])
385
389
  new_resource.version("2.6.2")
386
390
  provider.load_current_resource
387
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { returns: [0], timeout: timeout })
391
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "--version", "2.6.2", "git", { returns: [0], timeout: timeout })
388
392
  provider.run_action(:upgrade)
389
393
  expect(new_resource).to be_updated_by_last_action
390
394
  end
@@ -392,7 +396,7 @@ describe Chef::Provider::Package::Chocolatey do
392
396
  it "upgrading multiple packages uses a single command" do
393
397
  allow_remote_list(%w{conemu git})
394
398
  new_resource.package_name(%w{conemu git})
395
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { returns: [0], timeout: timeout }).and_return(double)
399
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "upgrade", "-y", "conemu", "git", { returns: [0], timeout: timeout }).and_return(double)
396
400
  provider.run_action(:upgrade)
397
401
  expect(new_resource).to be_updated_by_last_action
398
402
  end
@@ -413,7 +417,7 @@ describe Chef::Provider::Package::Chocolatey do
413
417
 
414
418
  context "alternate source" do
415
419
  it "installing a package that does not exist throws an error" do
416
- allow_remote_list(["package-does-not-exist"], " -source alternate_source")
420
+ allow_remote_list(["package-does-not-exist"], ["-source", "alternate_source"])
417
421
  new_resource.package_name("package-does-not-exist")
418
422
  new_resource.source("alternate_source")
419
423
  provider.load_current_resource
@@ -444,7 +448,7 @@ describe Chef::Provider::Package::Chocolatey do
444
448
  allow_remote_list(["ConEmu"])
445
449
  new_resource.package_name("ConEmu")
446
450
  provider.load_current_resource
447
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { returns: [0], timeout: timeout }).and_return(double)
451
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "ConEmu", { returns: [0], timeout: timeout }).and_return(double)
448
452
  provider.run_action(:remove)
449
453
  expect(new_resource).to be_updated_by_last_action
450
454
  end
@@ -453,7 +457,7 @@ describe Chef::Provider::Package::Chocolatey do
453
457
  allow_remote_list(["conemu"])
454
458
  new_resource.package_name("conemu")
455
459
  provider.load_current_resource
456
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
460
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
457
461
  provider.run_action(:remove)
458
462
  expect(new_resource).to be_updated_by_last_action
459
463
  end
@@ -463,7 +467,7 @@ describe Chef::Provider::Package::Chocolatey do
463
467
  allow_remote_list(%w{git conemu})
464
468
  new_resource.package_name(%w{git conemu})
465
469
  provider.load_current_resource
466
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
470
+ expect(provider).to receive(:shell_out_compacted!).with(choco_exe, "uninstall", "-y", "conemu", { returns: [0], timeout: timeout }).and_return(double)
467
471
  provider.run_action(:remove)
468
472
  expect(new_resource).to be_updated_by_last_action
469
473
  end