chef 14.1.12 → 14.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -6
  3. data/VERSION +1 -1
  4. data/chef.gemspec +2 -3
  5. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +8 -4
  6. data/lib/chef/cookbook/manifest_v0.rb +2 -2
  7. data/lib/chef/cookbook_manifest.rb +3 -2
  8. data/lib/chef/cookbook_version.rb +3 -2
  9. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -2
  10. data/lib/chef/http/auth_credentials.rb +5 -3
  11. data/lib/chef/http/authenticator.rb +6 -3
  12. data/lib/chef/knife.rb +3 -6
  13. data/lib/chef/knife/configure.rb +12 -8
  14. data/lib/chef/knife/raw.rb +6 -1
  15. data/lib/chef/mixin/shell_out.rb +16 -14
  16. data/lib/chef/provider/execute.rb +4 -3
  17. data/lib/chef/provider/git.rb +1 -1
  18. data/lib/chef/provider/package/dnf.rb +5 -5
  19. data/lib/chef/provider/package/windows.rb +7 -0
  20. data/lib/chef/provider/package/yum.rb +7 -7
  21. data/lib/chef/provider/service/freebsd.rb +3 -3
  22. data/lib/chef/provider/service/init.rb +5 -5
  23. data/lib/chef/provider/service/macosx.rb +5 -4
  24. data/lib/chef/provider/service/simple.rb +4 -4
  25. data/lib/chef/provider/service/systemd.rb +13 -13
  26. data/lib/chef/provider/service/upstart.rb +3 -3
  27. data/lib/chef/provider/service/windows.rb +2 -0
  28. data/lib/chef/provider/systemd_unit.rb +4 -4
  29. data/lib/chef/provider/user.rb +18 -1
  30. data/lib/chef/provider/user/aix.rb +40 -8
  31. data/lib/chef/provider/user/dscl.rb +7 -14
  32. data/lib/chef/provider/user/linux.rb +1 -11
  33. data/lib/chef/provider/user/solaris.rb +57 -26
  34. data/lib/chef/provider/user/useradd.rb +4 -1
  35. data/lib/chef/provider/windows_task.rb +1 -0
  36. data/lib/chef/providers.rb +1 -2
  37. data/lib/chef/resource/execute.rb +4 -1
  38. data/lib/chef/resource/gem_package.rb +1 -1
  39. data/lib/chef/resource/hostname.rb +1 -1
  40. data/lib/chef/resource/sysctl.rb +3 -1
  41. data/lib/chef/resource/windows_ad_join.rb +16 -3
  42. data/lib/chef/resource_inspector.rb +13 -0
  43. data/lib/chef/run_context/cookbook_compiler.rb +1 -1
  44. data/lib/chef/server_api.rb +2 -0
  45. data/lib/chef/version.rb +1 -1
  46. data/spec/functional/mixin/shell_out_spec.rb +27 -1
  47. data/spec/functional/resource/execute_spec.rb +2 -2
  48. data/spec/functional/resource/windows_task_spec.rb +1 -1
  49. data/spec/support/shared/functional/securable_resource.rb +1 -1
  50. data/spec/support/shared/unit/execute_resource.rb +1 -1
  51. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
  52. data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +65 -0
  53. data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
  54. data/spec/unit/cookbook_manifest_spec.rb +2 -0
  55. data/spec/unit/dsl/recipe_spec.rb +1 -5
  56. data/spec/unit/http/authenticator_spec.rb +33 -8
  57. data/spec/unit/mixin/shell_out_spec.rb +61 -1
  58. data/spec/unit/provider/apt_update_spec.rb +7 -7
  59. data/spec/unit/provider/execute_spec.rb +16 -15
  60. data/spec/unit/provider/git_spec.rb +3 -3
  61. data/spec/unit/provider/package/windows_spec.rb +12 -0
  62. data/spec/unit/provider/script_spec.rb +2 -2
  63. data/spec/unit/provider/service/arch_service_spec.rb +9 -9
  64. data/spec/unit/provider/service/freebsd_service_spec.rb +6 -6
  65. data/spec/unit/provider/service/init_service_spec.rb +11 -11
  66. data/spec/unit/provider/service/invokercd_service_spec.rb +9 -9
  67. data/spec/unit/provider/service/macosx_spec.rb +11 -11
  68. data/spec/unit/provider/service/openbsd_service_spec.rb +6 -6
  69. data/spec/unit/provider/service/simple_service_spec.rb +4 -4
  70. data/spec/unit/provider/service/systemd_service_spec.rb +16 -16
  71. data/spec/unit/provider/service/upstart_service_spec.rb +12 -12
  72. data/spec/unit/provider/service/windows_spec.rb +5 -0
  73. data/spec/unit/provider/systemd_unit_spec.rb +163 -118
  74. data/spec/unit/provider/user/dscl_spec.rb +2 -9
  75. data/spec/unit/provider/user/solaris_spec.rb +2 -2
  76. data/spec/unit/provider/zypper_repository_spec.rb +3 -3
  77. data/spec/unit/provider_spec.rb +1 -5
  78. data/spec/unit/resource/apt_package_spec.rb +14 -0
  79. data/spec/unit/resource/apt_preference_spec.rb +14 -1
  80. data/spec/unit/resource/apt_repository_spec.rb +12 -3
  81. data/spec/unit/resource/apt_update_spec.rb +9 -0
  82. data/spec/unit/resource/bash_spec.rb +8 -0
  83. data/spec/unit/resource/bff_package_spec.rb +51 -0
  84. data/spec/unit/resource/breakpoint_spec.rb +4 -4
  85. data/spec/unit/resource/build_essential_spec.rb +5 -1
  86. data/spec/unit/resource/cab_package_spec.rb +10 -0
  87. data/spec/unit/resource/chef_gem_spec.rb +14 -0
  88. data/spec/unit/resource/chef_handler_spec.rb +9 -4
  89. data/spec/unit/resource/chocolatey_package_spec.rb +15 -1
  90. data/spec/unit/resource/conditional_spec.rb +3 -3
  91. data/spec/unit/resource/cookbook_file_spec.rb +13 -2
  92. data/spec/unit/resource/cron_spec.rb +2 -7
  93. data/spec/unit/resource/csh_spec.rb +8 -0
  94. data/spec/unit/resource/directory_spec.rb +4 -9
  95. data/spec/unit/resource/dmg_package_spec.rb +8 -4
  96. data/spec/unit/resource/dnf_package_spec.rb +16 -1
  97. data/spec/unit/resource/dpkg_package_spec.rb +18 -0
  98. data/spec/unit/resource/dsc_resource_spec.rb +6 -6
  99. data/spec/unit/resource/dsc_script_spec.rb +39 -39
  100. data/spec/unit/resource/execute_spec.rb +20 -12
  101. data/spec/unit/resource/file_spec.rb +10 -10
  102. data/spec/unit/resource/freebsd_package_spec.rb +16 -0
  103. data/spec/unit/resource/gem_package_spec.rb +27 -0
  104. data/spec/unit/resource/git_spec.rb +17 -2
  105. data/spec/unit/resource/group_spec.rb +18 -17
  106. data/spec/unit/resource/homebrew_cask_spec.rb +9 -4
  107. data/spec/unit/resource/homebrew_package_spec.rb +14 -0
  108. data/spec/unit/resource/homebrew_tap_spec.rb +8 -3
  109. data/spec/unit/resource/hostname_spec.rb +10 -6
  110. data/spec/unit/resource/http_request_spec.rb +14 -0
  111. data/spec/unit/resource/ips_package_spec.rb +15 -3
  112. data/spec/unit/resource/ksh_spec.rb +8 -0
  113. data/spec/unit/resource/launchd_spec.rb +11 -5
  114. data/spec/unit/resource/link_spec.rb +6 -11
  115. data/spec/unit/resource/log_spec.rb +8 -8
  116. data/spec/unit/resource/macos_user_defaults_spec.rb +5 -1
  117. data/spec/unit/resource/macports_package_spec.rb +19 -0
  118. data/spec/unit/resource/mdadm_spec.rb +7 -3
  119. data/spec/unit/resource/mount_spec.rb +15 -18
  120. data/spec/unit/resource/msu_package_spec.rb +10 -0
  121. data/spec/unit/resource/ohai_hint_spec.rb +9 -8
  122. data/spec/unit/resource/ohai_spec.rb +11 -3
  123. data/spec/unit/resource/openbsd_package_spec.rb +14 -0
  124. data/spec/unit/resource/openssl_dhparam.rb +10 -5
  125. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +10 -5
  126. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +9 -5
  127. data/spec/unit/resource/osx_profile_spec.rb +7 -4
  128. data/spec/unit/resource/package_spec.rb +14 -0
  129. data/spec/unit/resource/pacman_package_spec.rb +17 -3
  130. data/spec/unit/resource/paludis_package_spec.rb +36 -0
  131. data/spec/unit/resource/perl_spec.rb +8 -0
  132. data/spec/unit/resource/portage_package_spec.rb +14 -0
  133. data/spec/unit/resource/powershell_package_spec.rb +14 -0
  134. data/spec/unit/resource/python_spec.rb +8 -0
  135. data/spec/unit/resource/reboot_spec.rb +5 -3
  136. data/spec/unit/resource/registry_key_spec.rb +12 -1
  137. data/spec/unit/resource/remote_directory_spec.rb +11 -1
  138. data/spec/unit/resource/remote_file_spec.rb +19 -0
  139. data/spec/unit/resource/rhsm_errata_level_spec.rb +7 -3
  140. data/spec/unit/resource/rhsm_errata_spec.rb +8 -4
  141. data/spec/unit/resource/rhsm_register_spec.rb +6 -1
  142. data/spec/unit/resource/rhsm_repo_spec.rb +9 -4
  143. data/spec/unit/resource/rhsm_subscription_spec.rb +9 -4
  144. data/spec/unit/resource/route_spec.rb +4 -9
  145. data/spec/unit/resource/rpm_package_spec.rb +14 -0
  146. data/spec/unit/resource/ruby_block_spec.rb +12 -8
  147. data/spec/unit/resource/ruby_spec.rb +8 -0
  148. data/spec/unit/resource/scm_spec.rb +16 -8
  149. data/spec/unit/resource/script_spec.rb +8 -0
  150. data/spec/unit/resource/service_spec.rb +15 -0
  151. data/spec/unit/resource/smartos_package_spec.rb +18 -4
  152. data/spec/unit/resource/solaris_package_spec.rb +14 -0
  153. data/spec/unit/resource/subversion_spec.rb +14 -8
  154. data/spec/unit/resource/sudo_spec.rb +11 -4
  155. data/spec/unit/resource/swap_file_spec.rb +4 -5
  156. data/spec/unit/resource/sysctl_spec.rb +8 -10
  157. data/spec/unit/resource/systemd_unit_spec.rb +14 -12
  158. data/spec/unit/resource/template_spec.rb +19 -0
  159. data/spec/unit/resource/{windows_ad_join.rb → windows_ad_join_spec.rb} +12 -6
  160. data/spec/unit/resource/windows_auto_run_spec.rb +9 -9
  161. data/spec/unit/resource/windows_env_spec.rb +8 -16
  162. data/spec/unit/resource/windows_feature.rb +27 -8
  163. data/spec/unit/resource/windows_feature_dism.rb +30 -9
  164. data/spec/unit/resource/windows_feature_powershell.rb +7 -7
  165. data/spec/unit/resource/windows_font_spec.rb +3 -4
  166. data/spec/unit/resource/windows_package_spec.rb +12 -2
  167. data/spec/unit/resource/windows_pagefile_spec.rb +12 -8
  168. data/spec/unit/resource/windows_path_spec.rb +4 -5
  169. data/spec/unit/resource/windows_printer_port_spec.rb +20 -3
  170. data/spec/unit/resource/windows_printer_spec.rb +12 -5
  171. data/spec/unit/resource/windows_service_spec.rb +24 -1
  172. data/spec/unit/resource/windows_shortcut_spec.rb +4 -5
  173. data/spec/unit/resource/yum_repository_spec.rb +48 -2
  174. data/spec/unit/resource/zypper_package_spec.rb +51 -0
  175. data/spec/unit/resource/zypper_repository_spec.rb +56 -11
  176. data/spec/unit/resource_spec.rb +1 -5
  177. metadata +21 -12
  178. data/spec/functional/resource/user/useradd_spec.rb +0 -709
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Stephen Haynes (<sh@nomitor.com>)
3
3
  # Author:: Davide Cavalca (<dcavalca@fb.com>)
4
- # Copyright:: Copyright 2011-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2011-2018, 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");
@@ -36,18 +36,18 @@ describe Chef::Provider::Service::Systemd do
36
36
  let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
37
37
 
38
38
  let(:shell_out_success) do
39
- double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
39
+ double("shell_out", :exitstatus => 0, :error? => false)
40
40
  end
41
41
 
42
42
  let(:shell_out_failure) do
43
- double("shell_out_with_systems_locale", :exitstatus => 1, :error? => true)
43
+ double("shell_out", :exitstatus => 1, :error? => true)
44
44
  end
45
45
 
46
46
  let(:current_resource) { Chef::Resource::Service.new(service_name) }
47
47
 
48
48
  before(:each) do
49
49
  allow(Chef::Resource::Service).to receive(:new).with(service_name).and_return(current_resource)
50
- allow(Etc).to receive(:getpwuid).and_return(OpenStruct.new(uid: 10000))
50
+ allow(Etc).to receive(:getpwnam).and_return(OpenStruct.new(uid: 10000))
51
51
  end
52
52
 
53
53
  describe "load_current_resource" do
@@ -170,19 +170,19 @@ describe Chef::Provider::Service::Systemd do
170
170
 
171
171
  it "should call the start command if one is specified" do
172
172
  allow(new_resource).to receive(:start_command).and_return("/sbin/rsyslog startyousillysally")
173
- expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
173
+ expect(provider).to receive(:shell_out!).with("/sbin/rsyslog startyousillysally", default_env: false)
174
174
  provider.start_service
175
175
  end
176
176
 
177
177
  context "when a user is not specified" do
178
178
  it "should call '#{systemctl_path} --system start service_name' if no start command is specified" do
179
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system start #{service_name_escaped}", {}).and_return(shell_out_success)
179
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --system start #{service_name_escaped}", default_env: false).and_return(shell_out_success)
180
180
  provider.start_service
181
181
  end
182
182
 
183
183
  it "should not call '#{systemctl_path} --system start service_name' if it is already running" do
184
184
  current_resource.running(true)
185
- expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system start #{service_name_escaped}", {})
185
+ expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --system start #{service_name_escaped}", {})
186
186
  provider.start_service
187
187
  end
188
188
  end
@@ -190,14 +190,14 @@ describe Chef::Provider::Service::Systemd do
190
190
  context "when a user is specified" do
191
191
  it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do
192
192
  current_resource.user("joe")
193
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" }).and_return(shell_out_success)
193
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe", default_env: false }).and_return(shell_out_success)
194
194
  provider.start_service
195
195
  end
196
196
 
197
197
  it "should not call '#{systemctl_path} --user start service_name' if it is already running" do
198
198
  current_resource.running(true)
199
199
  current_resource.user("joe")
200
- expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" })
200
+ expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" })
201
201
  provider.start_service
202
202
  end
203
203
  end
@@ -205,13 +205,13 @@ describe Chef::Provider::Service::Systemd do
205
205
  it "should call the restart command if one is specified" do
206
206
  current_resource.running(true)
207
207
  allow(new_resource).to receive(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
208
- expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
208
+ expect(provider).to receive(:shell_out!).with("/sbin/rsyslog restartyousillysally", default_env: false)
209
209
  provider.restart_service
210
210
  end
211
211
 
212
212
  it "should call '#{systemctl_path} --system restart service_name' if no restart command is specified" do
213
213
  current_resource.running(true)
214
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system restart #{service_name_escaped}", {}).and_return(shell_out_success)
214
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --system restart #{service_name_escaped}", default_env: false).and_return(shell_out_success)
215
215
  provider.restart_service
216
216
  end
217
217
 
@@ -220,7 +220,7 @@ describe Chef::Provider::Service::Systemd do
220
220
  it "should call the reload command" do
221
221
  current_resource.running(true)
222
222
  allow(new_resource).to receive(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
223
- expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
223
+ expect(provider).to receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally", default_env: false)
224
224
  provider.reload_service
225
225
  end
226
226
  end
@@ -228,7 +228,7 @@ describe Chef::Provider::Service::Systemd do
228
228
  context "when a reload command is not specified" do
229
229
  it "should call '#{systemctl_path} --system reload service_name' if the service is running" do
230
230
  current_resource.running(true)
231
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system reload #{service_name_escaped}", {}).and_return(shell_out_success)
231
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --system reload #{service_name_escaped}", default_env: false).and_return(shell_out_success)
232
232
  provider.reload_service
233
233
  end
234
234
 
@@ -243,19 +243,19 @@ describe Chef::Provider::Service::Systemd do
243
243
  it "should call the stop command if one is specified" do
244
244
  current_resource.running(true)
245
245
  allow(new_resource).to receive(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
246
- expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
246
+ expect(provider).to receive(:shell_out!).with("/sbin/rsyslog stopyousillysally", default_env: false)
247
247
  provider.stop_service
248
248
  end
249
249
 
250
250
  it "should call '#{systemctl_path} --system stop service_name' if no stop command is specified" do
251
251
  current_resource.running(true)
252
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system stop #{service_name_escaped}", {}).and_return(shell_out_success)
252
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --system stop #{service_name_escaped}", default_env: false).and_return(shell_out_success)
253
253
  provider.stop_service
254
254
  end
255
255
 
256
256
  it "should not call '#{systemctl_path} --system stop service_name' if it is already stopped" do
257
257
  current_resource.running(false)
258
- expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --system stop #{service_name_escaped}", {})
258
+ expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --system stop #{service_name_escaped}", {})
259
259
  provider.stop_service
260
260
  end
261
261
  end
@@ -20,7 +20,7 @@ require "spec_helper"
20
20
 
21
21
  describe Chef::Provider::Service::Upstart do
22
22
  let(:shell_out_success) do
23
- double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
23
+ double("shell_out", :exitstatus => 0, :error? => false)
24
24
  end
25
25
 
26
26
  before(:each) do
@@ -267,19 +267,19 @@ describe Chef::Provider::Service::Upstart do
267
267
  it "should call the start command if one is specified" do
268
268
  @provider.upstart_service_running = false
269
269
  @new_resource.start_command("/sbin/rsyslog startyousillysally")
270
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
270
+ expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog startyousillysally", default_env: false)
271
271
  @provider.start_service()
272
272
  end
273
273
 
274
274
  it "should call '/sbin/start service_name' if no start command is specified" do
275
275
  @provider.upstart_service_running = false
276
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success)
276
+ expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
277
277
  @provider.start_service()
278
278
  end
279
279
 
280
280
  it "should not call '/sbin/start service_name' if it is already running" do
281
281
  @provider.upstart_service_running = true
282
- expect(@provider).not_to receive(:shell_out_with_systems_locale!)
282
+ expect(@provider).not_to receive(:shell_out!)
283
283
  @provider.start_service()
284
284
  end
285
285
 
@@ -288,14 +288,14 @@ describe Chef::Provider::Service::Upstart do
288
288
  @new_resource.parameters({ "OSD_ID" => "2" })
289
289
  @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
290
290
  @provider.current_resource = @current_resource
291
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(shell_out_success)
291
+ expect(@provider).to receive(:shell_out!).with("/sbin/start rsyslog OSD_ID=2", default_env: false).and_return(shell_out_success)
292
292
  @provider.start_service()
293
293
  end
294
294
 
295
295
  it "should call the restart command if one is specified" do
296
296
  allow(@current_resource).to receive(:running).and_return(true)
297
297
  @new_resource.restart_command("/sbin/rsyslog restartyousillysally")
298
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
298
+ expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog restartyousillysally", default_env: false)
299
299
  @provider.restart_service()
300
300
  end
301
301
 
@@ -310,40 +310,40 @@ describe Chef::Provider::Service::Upstart do
310
310
  it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
311
311
  @provider.upstart_service_running = false
312
312
  allow(@current_resource).to receive(:running).and_return(false)
313
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success)
313
+ expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
314
314
  @provider.restart_service()
315
315
  end
316
316
 
317
317
  it "should call the reload command if one is specified" do
318
318
  allow(@current_resource).to receive(:running).and_return(true)
319
319
  @new_resource.reload_command("/sbin/rsyslog reloadyousillysally")
320
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
320
+ expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally", default_env: false)
321
321
  @provider.reload_service()
322
322
  end
323
323
 
324
324
  it "should call '/sbin/reload service_name' if no reload command is specified" do
325
325
  allow(@current_resource).to receive(:running).and_return(true)
326
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(shell_out_success)
326
+ expect(@provider).to receive(:shell_out!).with("/sbin/reload #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
327
327
  @provider.reload_service()
328
328
  end
329
329
 
330
330
  it "should call the stop command if one is specified" do
331
331
  @provider.upstart_service_running = true
332
332
  @new_resource.stop_command("/sbin/rsyslog stopyousillysally")
333
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
333
+ expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog stopyousillysally", default_env: false)
334
334
  @provider.stop_service()
335
335
  end
336
336
 
337
337
  it "should call '/sbin/stop service_name' if no stop command is specified" do
338
338
  @provider.upstart_service_running = true
339
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(shell_out_success)
339
+ expect(@provider).to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
340
340
  @provider.stop_service()
341
341
  end
342
342
 
343
343
  it "should not call '/sbin/stop service_name' if it is already stopped" do
344
344
  @provider.upstart_service_running = false
345
345
  allow(@current_resource).to receive(:running).and_return(false)
346
- expect(@provider).not_to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}")
346
+ expect(@provider).not_to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false)
347
347
  @provider.stop_service()
348
348
  expect(@upstart_service_running).to be_falsey
349
349
  end
@@ -801,6 +801,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
801
801
  provider.action_configure_startup
802
802
  end
803
803
  end
804
+
805
+ it "calls converge_delayed_start" do
806
+ expect(provider).to receive(:converge_delayed_start)
807
+ provider.action_configure_startup
808
+ end
804
809
  end
805
810
 
806
811
  describe Chef::Provider::Service::Windows, "set_start_type" do
@@ -58,23 +58,23 @@ describe Chef::Provider::SystemdUnit do
58
58
  end
59
59
 
60
60
  let(:shell_out_success) do
61
- double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
61
+ double("shell_out", :exitstatus => 0, :error? => false)
62
62
  end
63
63
 
64
64
  let(:shell_out_failure) do
65
- double("shell_out_with_systems_locale", :exitstatus => 1, :error? => true)
65
+ double("shell_out", :exitstatus => 1, :error? => true)
66
66
  end
67
67
 
68
68
  let(:shell_out_masked) do
69
- double("shell_out_with_systems_locale", :exit_status => 0, :error? => false, :stdout => "masked")
69
+ double("shell_out", :exit_status => 0, :error? => false, :stdout => "masked")
70
70
  end
71
71
 
72
72
  let(:shell_out_static) do
73
- double("shell_out_with_systems_locale", :exit_status => 0, :error? => false, :stdout => "static")
73
+ double("shell_out", :exit_status => 0, :error? => false, :stdout => "static")
74
74
  end
75
75
 
76
76
  before(:each) do
77
- allow(Etc).to receive(:getpwuid).and_return(OpenStruct.new(uid: 1000))
77
+ allow(Etc).to receive(:getpwnam).and_return(OpenStruct.new(uid: 1000))
78
78
  allow(Chef::Resource::SystemdUnit).to receive(:new)
79
79
  .with(unit_name)
80
80
  .and_return(current_resource)
@@ -280,49 +280,53 @@ describe Chef::Provider::SystemdUnit do
280
280
  provider.action_create
281
281
  end
282
282
 
283
- it "triggers a daemon-reload when creating a unit with triggers_reload" do
284
- allow(provider).to receive(:manage_unit_file).with(:create)
285
- expect(new_resource.triggers_reload).to eq true
286
- allow(provider).to receive(:shell_out_with_systems_locale!)
287
- expect(provider).to receive(:shell_out_with_systems_locale!)
288
- .with("#{systemctl_path} daemon-reload")
289
- provider.action_create
290
- end
283
+ context "when a user is specified" do
284
+ it "triggers a daemon-reload when creating a unit with triggers_reload" do
285
+ new_resource.user("joe")
286
+ allow(provider).to receive(:manage_unit_file).with(:create)
287
+ expect(new_resource.triggers_reload).to eq true
288
+ allow(provider).to receive(:shell_out!)
289
+ expect(provider).to receive(:shell_out!)
290
+ .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
291
+ provider.action_create
292
+ end
291
293
 
292
- it "triggers a daemon-reload when deleting a unit with triggers_reload" do
293
- allow(File).to receive(:exist?)
294
- .with(unit_path_system)
295
- .and_return(true)
296
- allow(provider).to receive(:manage_unit_file).with(:delete)
297
- expect(new_resource.triggers_reload).to eq true
298
- allow(provider).to receive(:shell_out_with_systems_locale!)
299
- expect(provider).to receive(:shell_out_with_systems_locale!)
300
- .with("#{systemctl_path} daemon-reload")
301
- provider.action_delete
302
- end
294
+ it "triggers a daemon-reload when deleting a unit with triggers_reload" do
295
+ new_resource.user("joe")
296
+ allow(File).to receive(:exist?)
297
+ .with(unit_path_user)
298
+ .and_return(true)
299
+ allow(provider).to receive(:manage_unit_file).with(:delete)
300
+ expect(new_resource.triggers_reload).to eq true
301
+ allow(provider).to receive(:shell_out!)
302
+ expect(provider).to receive(:shell_out!)
303
+ .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
304
+ provider.action_delete
305
+ end
303
306
 
304
- it "does not trigger a daemon-reload when creating a unit without triggers_reload" do
305
- new_resource.triggers_reload(false)
306
- allow(provider).to receive(:manage_unit_file).with(:create)
307
- allow(provider).to receive(:shell_out_with_systems_locale!)
308
- expect(provider).to_not receive(:shell_out_with_systems_locale!)
309
- .with("#{systemctl_path} daemon-reload")
310
- provider.action_create
311
- end
307
+ it "does not trigger a daemon-reload when creating a unit without triggers_reload" do
308
+ new_resource.user("joe")
309
+ new_resource.triggers_reload(false)
310
+ allow(provider).to receive(:manage_unit_file).with(:create)
311
+ allow(provider).to receive(:shell_out!)
312
+ expect(provider).to_not receive(:shell_out!)
313
+ .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
314
+ provider.action_create
315
+ end
312
316
 
313
- it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do
314
- new_resource.triggers_reload(false)
315
- allow(File).to receive(:exist?)
316
- .with(unit_path_system)
317
- .and_return(true)
318
- allow(provider).to receive(:manage_unit_file).with(:delete)
319
- allow(provider).to receive(:shell_out_with_systems_locale!)
320
- expect(provider).to_not receive(:shell_out_with_systems_locale!)
321
- .with("#{systemctl_path} daemon-reload")
322
- provider.action_delete
323
- end
317
+ it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do
318
+ new_resource.user("joe")
319
+ new_resource.triggers_reload(false)
320
+ allow(File).to receive(:exist?)
321
+ .with(unit_path_user)
322
+ .and_return(true)
323
+ allow(provider).to receive(:manage_unit_file).with(:delete)
324
+ allow(provider).to receive(:shell_out!)
325
+ expect(provider).to_not receive(:shell_out!)
326
+ .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
327
+ provider.action_delete
328
+ end
324
329
 
325
- context "when a user is specified" do
326
330
  it "deletes the file when it exists" do
327
331
  new_resource.user("joe")
328
332
  allow(File).to receive(:exist?)
@@ -348,22 +352,63 @@ describe Chef::Provider::SystemdUnit do
348
352
 
349
353
  it "presets the unit" do
350
354
  new_resource.user("joe")
351
- expect(provider).to receive(:shell_out_with_systems_locale!)
352
- .with("#{systemctl_path} --user preset #{unit_name_escaped}", user_cmd_opts)
355
+ expect(provider).to receive(:shell_out!)
356
+ .with("#{systemctl_path} --user preset #{unit_name_escaped}", **user_cmd_opts, default_env: false)
353
357
  .and_return(shell_out_success)
354
358
  provider.action_preset
355
359
  end
356
360
 
357
361
  it "reverts the unit" do
358
362
  new_resource.user("joe")
359
- expect(provider).to receive(:shell_out_with_systems_locale!)
360
- .with("#{systemctl_path} --user revert #{unit_name_escaped}", user_cmd_opts)
363
+ expect(provider).to receive(:shell_out!)
364
+ .with("#{systemctl_path} --user revert #{unit_name_escaped}", **user_cmd_opts, default_env: false)
361
365
  .and_return(shell_out_success)
362
366
  provider.action_revert
363
367
  end
364
368
  end
365
369
 
366
370
  context "when no user is specified" do
371
+ it "triggers a daemon-reload when creating a unit with triggers_reload" do
372
+ allow(provider).to receive(:manage_unit_file).with(:create)
373
+ expect(new_resource.triggers_reload).to eq true
374
+ allow(provider).to receive(:shell_out!)
375
+ expect(provider).to receive(:shell_out!)
376
+ .with("#{systemctl_path} --system daemon-reload", default_env: false)
377
+ provider.action_create
378
+ end
379
+
380
+ it "triggers a daemon-reload when deleting a unit with triggers_reload" do
381
+ allow(File).to receive(:exist?)
382
+ .with(unit_path_system)
383
+ .and_return(true)
384
+ allow(provider).to receive(:manage_unit_file).with(:delete)
385
+ expect(new_resource.triggers_reload).to eq true
386
+ allow(provider).to receive(:shell_out!)
387
+ expect(provider).to receive(:shell_out!)
388
+ .with("#{systemctl_path} --system daemon-reload", default_env: false)
389
+ provider.action_delete
390
+ end
391
+
392
+ it "does not trigger a daemon-reload when creating a unit without triggers_reload" do
393
+ new_resource.triggers_reload(false)
394
+ allow(provider).to receive(:manage_unit_file).with(:create)
395
+ allow(provider).to receive(:shell_out!)
396
+ expect(provider).to_not receive(:shell_out!)
397
+ .with("#{systemctl_path} --system daemon-reload", default_env: false)
398
+ provider.action_create
399
+ end
400
+
401
+ it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do
402
+ new_resource.triggers_reload(false)
403
+ allow(File).to receive(:exist?)
404
+ .with(unit_path_system)
405
+ .and_return(true)
406
+ allow(provider).to receive(:manage_unit_file).with(:delete)
407
+ allow(provider).to receive(:shell_out!)
408
+ expect(provider).to_not receive(:shell_out!)
409
+ .with("#{systemctl_path} --system daemon-reload", default_env: false)
410
+ provider.action_delete
411
+ end
367
412
  it "deletes the file when it exists" do
368
413
  allow(File).to receive(:exist?)
369
414
  .with(unit_path_system)
@@ -386,15 +431,15 @@ describe Chef::Provider::SystemdUnit do
386
431
  end
387
432
 
388
433
  it "presets the unit" do
389
- expect(provider).to receive(:shell_out_with_systems_locale!)
390
- .with("#{systemctl_path} --system preset #{unit_name_escaped}", {})
434
+ expect(provider).to receive(:shell_out!)
435
+ .with("#{systemctl_path} --system preset #{unit_name_escaped}", default_env: false)
391
436
  .and_return(shell_out_success)
392
437
  provider.action_preset
393
438
  end
394
439
 
395
440
  it "reverts the unit" do
396
- expect(provider).to receive(:shell_out_with_systems_locale!)
397
- .with("#{systemctl_path} --system revert #{unit_name_escaped}", {})
441
+ expect(provider).to receive(:shell_out!)
442
+ .with("#{systemctl_path} --system revert #{unit_name_escaped}", default_env: false)
398
443
  .and_return(shell_out_success)
399
444
  provider.action_revert
400
445
  end
@@ -405,8 +450,8 @@ describe Chef::Provider::SystemdUnit do
405
450
  context "when a user is specified" do
406
451
  it "reenables the unit" do
407
452
  current_resource.user(user_name)
408
- expect(provider).to receive(:shell_out_with_systems_locale!)
409
- .with("#{systemctl_path} --user reenable #{unit_name_escaped}", user_cmd_opts)
453
+ expect(provider).to receive(:shell_out!)
454
+ .with("#{systemctl_path} --user reenable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
410
455
  .and_return(shell_out_success)
411
456
  provider.action_reenable
412
457
  end
@@ -414,8 +459,8 @@ describe Chef::Provider::SystemdUnit do
414
459
  it "enables the unit when it is disabled" do
415
460
  current_resource.user(user_name)
416
461
  current_resource.enabled(false)
417
- expect(provider).to receive(:shell_out_with_systems_locale!)
418
- .with("#{systemctl_path} --user enable #{unit_name_escaped}", user_cmd_opts)
462
+ expect(provider).to receive(:shell_out!)
463
+ .with("#{systemctl_path} --user enable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
419
464
  .and_return(shell_out_success)
420
465
  provider.action_enable
421
466
  end
@@ -423,22 +468,22 @@ describe Chef::Provider::SystemdUnit do
423
468
  it "does not enable the unit when it is enabled" do
424
469
  current_resource.user(user_name)
425
470
  current_resource.enabled(true)
426
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
471
+ expect(provider).not_to receive(:shell_out!)
427
472
  provider.action_enable
428
473
  end
429
474
 
430
475
  it "does not enable the unit when it is static" do
431
476
  current_resource.user(user_name)
432
477
  current_resource.static(true)
433
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
478
+ expect(provider).not_to receive(:shell_out!)
434
479
  provider.action_enable
435
480
  end
436
481
 
437
482
  it "disables the unit when it is enabled" do
438
483
  current_resource.user(user_name)
439
484
  current_resource.enabled(true)
440
- expect(provider).to receive(:shell_out_with_systems_locale!)
441
- .with("#{systemctl_path} --user disable #{unit_name_escaped}", user_cmd_opts)
485
+ expect(provider).to receive(:shell_out!)
486
+ .with("#{systemctl_path} --user disable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
442
487
  .and_return(shell_out_success)
443
488
  provider.action_disable
444
489
  end
@@ -446,64 +491,64 @@ describe Chef::Provider::SystemdUnit do
446
491
  it "does not disable the unit when it is disabled" do
447
492
  current_resource.user(user_name)
448
493
  current_resource.enabled(false)
449
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
494
+ expect(provider).not_to receive(:shell_out!)
450
495
  provider.action_disable
451
496
  end
452
497
 
453
498
  it "does not disable the unit when it is static" do
454
499
  current_resource.user(user_name)
455
500
  current_resource.static(true)
456
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
501
+ expect(provider).not_to receive(:shell_out!)
457
502
  provider.action_disable
458
503
  end
459
504
  end
460
505
 
461
506
  context "when no user is specified" do
462
507
  it "reenables the unit" do
463
- expect(provider).to receive(:shell_out_with_systems_locale!)
464
- .with("#{systemctl_path} --system reenable #{unit_name_escaped}", {})
508
+ expect(provider).to receive(:shell_out!)
509
+ .with("#{systemctl_path} --system reenable #{unit_name_escaped}", default_env: false)
465
510
  .and_return(shell_out_success)
466
511
  provider.action_reenable
467
512
  end
468
513
 
469
514
  it "enables the unit when it is disabled" do
470
515
  current_resource.enabled(false)
471
- expect(provider).to receive(:shell_out_with_systems_locale!)
472
- .with("#{systemctl_path} --system enable #{unit_name_escaped}", {})
516
+ expect(provider).to receive(:shell_out!)
517
+ .with("#{systemctl_path} --system enable #{unit_name_escaped}", default_env: false)
473
518
  .and_return(shell_out_success)
474
519
  provider.action_enable
475
520
  end
476
521
 
477
522
  it "does not enable the unit when it is enabled" do
478
523
  current_resource.enabled(true)
479
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
524
+ expect(provider).not_to receive(:shell_out!)
480
525
  provider.action_enable
481
526
  end
482
527
 
483
528
  it "does not enable the unit when it is static" do
484
529
  current_resource.static(true)
485
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
530
+ expect(provider).not_to receive(:shell_out!)
486
531
  provider.action_enable
487
532
  end
488
533
 
489
534
  it "disables the unit when it is enabled" do
490
535
  current_resource.enabled(true)
491
- expect(provider).to receive(:shell_out_with_systems_locale!)
492
- .with("#{systemctl_path} --system disable #{unit_name_escaped}", {})
536
+ expect(provider).to receive(:shell_out!)
537
+ .with("#{systemctl_path} --system disable #{unit_name_escaped}", default_env: false)
493
538
  .and_return(shell_out_success)
494
539
  provider.action_disable
495
540
  end
496
541
 
497
542
  it "does not disable the unit when it is disabled" do
498
543
  current_resource.enabled(false)
499
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
544
+ expect(provider).not_to receive(:shell_out!)
500
545
  provider.action_disable
501
546
  end
502
547
 
503
548
  it "does not disable the unit when it is static" do
504
549
  current_resource.user(user_name)
505
550
  current_resource.static(true)
506
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
551
+ expect(provider).not_to receive(:shell_out!)
507
552
  provider.action_disable
508
553
  end
509
554
  end
@@ -514,8 +559,8 @@ describe Chef::Provider::SystemdUnit do
514
559
  it "masks the unit when it is unmasked" do
515
560
  current_resource.user(user_name)
516
561
  current_resource.masked(false)
517
- expect(provider).to receive(:shell_out_with_systems_locale!)
518
- .with("#{systemctl_path} --user mask #{unit_name_escaped}", user_cmd_opts)
562
+ expect(provider).to receive(:shell_out!)
563
+ .with("#{systemctl_path} --user mask #{unit_name_escaped}", **user_cmd_opts, default_env: false)
519
564
  .and_return(shell_out_success)
520
565
  provider.action_mask
521
566
  end
@@ -523,15 +568,15 @@ describe Chef::Provider::SystemdUnit do
523
568
  it "does not mask the unit when it is masked" do
524
569
  current_resource.user(user_name)
525
570
  current_resource.masked(true)
526
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
571
+ expect(provider).not_to receive(:shell_out!)
527
572
  provider.action_mask
528
573
  end
529
574
 
530
575
  it "unmasks the unit when it is masked" do
531
576
  current_resource.user(user_name)
532
577
  current_resource.masked(true)
533
- expect(provider).to receive(:shell_out_with_systems_locale!)
534
- .with("#{systemctl_path} --user unmask #{unit_name_escaped}", user_cmd_opts)
578
+ expect(provider).to receive(:shell_out!)
579
+ .with("#{systemctl_path} --user unmask #{unit_name_escaped}", **user_cmd_opts, default_env: false)
535
580
  .and_return(shell_out_success)
536
581
  provider.action_unmask
537
582
  end
@@ -539,7 +584,7 @@ describe Chef::Provider::SystemdUnit do
539
584
  it "does not unmask the unit when it is unmasked" do
540
585
  current_resource.user(user_name)
541
586
  current_resource.masked(false)
542
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
587
+ expect(provider).not_to receive(:shell_out!)
543
588
  provider.action_unmask
544
589
  end
545
590
  end
@@ -547,29 +592,29 @@ describe Chef::Provider::SystemdUnit do
547
592
  context "when no user is specified" do
548
593
  it "masks the unit when it is unmasked" do
549
594
  current_resource.masked(false)
550
- expect(provider).to receive(:shell_out_with_systems_locale!)
551
- .with("#{systemctl_path} --system mask #{unit_name_escaped}", {})
595
+ expect(provider).to receive(:shell_out!)
596
+ .with("#{systemctl_path} --system mask #{unit_name_escaped}", default_env: false)
552
597
  .and_return(shell_out_success)
553
598
  provider.action_mask
554
599
  end
555
600
 
556
601
  it "does not mask the unit when it is masked" do
557
602
  current_resource.masked(true)
558
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
603
+ expect(provider).not_to receive(:shell_out!)
559
604
  provider.action_mask
560
605
  end
561
606
 
562
607
  it "unmasks the unit when it is masked" do
563
608
  current_resource.masked(true)
564
- expect(provider).to receive(:shell_out_with_systems_locale!)
565
- .with("#{systemctl_path} --system unmask #{unit_name_escaped}", {})
609
+ expect(provider).to receive(:shell_out!)
610
+ .with("#{systemctl_path} --system unmask #{unit_name_escaped}", default_env: false)
566
611
  .and_return(shell_out_success)
567
612
  provider.action_unmask
568
613
  end
569
614
 
570
615
  it "does not unmask the unit when it is unmasked" do
571
616
  current_resource.masked(false)
572
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
617
+ expect(provider).not_to receive(:shell_out!)
573
618
  provider.action_unmask
574
619
  end
575
620
  end
@@ -580,8 +625,8 @@ describe Chef::Provider::SystemdUnit do
580
625
  it "starts the unit when it is inactive" do
581
626
  current_resource.user(user_name)
582
627
  current_resource.active(false)
583
- expect(provider).to receive(:shell_out_with_systems_locale!)
584
- .with("#{systemctl_path} --user start #{unit_name_escaped}", user_cmd_opts)
628
+ expect(provider).to receive(:shell_out!)
629
+ .with("#{systemctl_path} --user start #{unit_name_escaped}", **user_cmd_opts, default_env: false)
585
630
  .and_return(shell_out_success)
586
631
  provider.action_start
587
632
  end
@@ -589,15 +634,15 @@ describe Chef::Provider::SystemdUnit do
589
634
  it "does not start the unit when it is active" do
590
635
  current_resource.user(user_name)
591
636
  current_resource.active(true)
592
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
637
+ expect(provider).not_to receive(:shell_out!)
593
638
  provider.action_start
594
639
  end
595
640
 
596
641
  it "stops the unit when it is active" do
597
642
  current_resource.user(user_name)
598
643
  current_resource.active(true)
599
- expect(provider).to receive(:shell_out_with_systems_locale!)
600
- .with("#{systemctl_path} --user stop #{unit_name_escaped}", user_cmd_opts)
644
+ expect(provider).to receive(:shell_out!)
645
+ .with("#{systemctl_path} --user stop #{unit_name_escaped}", **user_cmd_opts, default_env: false)
601
646
  .and_return(shell_out_success)
602
647
  provider.action_stop
603
648
  end
@@ -605,7 +650,7 @@ describe Chef::Provider::SystemdUnit do
605
650
  it "does not stop the unit when it is inactive" do
606
651
  current_resource.user(user_name)
607
652
  current_resource.active(false)
608
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
653
+ expect(provider).not_to receive(:shell_out!)
609
654
  provider.action_stop
610
655
  end
611
656
  end
@@ -613,29 +658,29 @@ describe Chef::Provider::SystemdUnit do
613
658
  context "when no user is specified" do
614
659
  it "starts the unit when it is inactive" do
615
660
  current_resource.active(false)
616
- expect(provider).to receive(:shell_out_with_systems_locale!)
617
- .with("#{systemctl_path} --system start #{unit_name_escaped}", {})
661
+ expect(provider).to receive(:shell_out!)
662
+ .with("#{systemctl_path} --system start #{unit_name_escaped}", default_env: false)
618
663
  .and_return(shell_out_success)
619
664
  provider.action_start
620
665
  end
621
666
 
622
667
  it "does not start the unit when it is active" do
623
668
  current_resource.active(true)
624
- expect(provider).to_not receive(:shell_out_with_systems_locale!)
669
+ expect(provider).to_not receive(:shell_out!)
625
670
  provider.action_start
626
671
  end
627
672
 
628
673
  it "stops the unit when it is active" do
629
674
  current_resource.active(true)
630
- expect(provider).to receive(:shell_out_with_systems_locale!)
631
- .with("#{systemctl_path} --system stop #{unit_name_escaped}", {})
675
+ expect(provider).to receive(:shell_out!)
676
+ .with("#{systemctl_path} --system stop #{unit_name_escaped}", default_env: false)
632
677
  .and_return(shell_out_success)
633
678
  provider.action_stop
634
679
  end
635
680
 
636
681
  it "does not stop the unit when it is inactive" do
637
682
  current_resource.active(false)
638
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
683
+ expect(provider).not_to receive(:shell_out!)
639
684
  provider.action_stop
640
685
  end
641
686
  end
@@ -645,8 +690,8 @@ describe Chef::Provider::SystemdUnit do
645
690
  context "when a user is specified" do
646
691
  it "restarts the unit" do
647
692
  current_resource.user(user_name)
648
- expect(provider).to receive(:shell_out_with_systems_locale!)
649
- .with("#{systemctl_path} --user restart #{unit_name_escaped}", user_cmd_opts)
693
+ expect(provider).to receive(:shell_out!)
694
+ .with("#{systemctl_path} --user restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
650
695
  .and_return(shell_out_success)
651
696
  provider.action_restart
652
697
  end
@@ -654,8 +699,8 @@ describe Chef::Provider::SystemdUnit do
654
699
  it "reloads the unit if active" do
655
700
  current_resource.user(user_name)
656
701
  current_resource.active(true)
657
- expect(provider).to receive(:shell_out_with_systems_locale!)
658
- .with("#{systemctl_path} --user reload #{unit_name_escaped}", user_cmd_opts)
702
+ expect(provider).to receive(:shell_out!)
703
+ .with("#{systemctl_path} --user reload #{unit_name_escaped}", **user_cmd_opts, default_env: false)
659
704
  .and_return(shell_out_success)
660
705
  provider.action_reload
661
706
  end
@@ -663,30 +708,30 @@ describe Chef::Provider::SystemdUnit do
663
708
  it "does not reload if the unit is inactive" do
664
709
  current_resource.user(user_name)
665
710
  current_resource.active(false)
666
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
711
+ expect(provider).not_to receive(:shell_out!)
667
712
  provider.action_reload
668
713
  end
669
714
  end
670
715
 
671
716
  context "when no user is specified" do
672
717
  it "restarts the unit" do
673
- expect(provider).to receive(:shell_out_with_systems_locale!)
674
- .with("#{systemctl_path} --system restart #{unit_name_escaped}", {})
718
+ expect(provider).to receive(:shell_out!)
719
+ .with("#{systemctl_path} --system restart #{unit_name_escaped}", default_env: false)
675
720
  .and_return(shell_out_success)
676
721
  provider.action_restart
677
722
  end
678
723
 
679
724
  it "reloads the unit if active" do
680
725
  current_resource.active(true)
681
- expect(provider).to receive(:shell_out_with_systems_locale!)
682
- .with("#{systemctl_path} --system reload #{unit_name_escaped}", {})
726
+ expect(provider).to receive(:shell_out!)
727
+ .with("#{systemctl_path} --system reload #{unit_name_escaped}", default_env: false)
683
728
  .and_return(shell_out_success)
684
729
  provider.action_reload
685
730
  end
686
731
 
687
732
  it "does not reload the unit if inactive" do
688
733
  current_resource.active(false)
689
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
734
+ expect(provider).not_to receive(:shell_out!)
690
735
  provider.action_reload
691
736
  end
692
737
  end
@@ -696,8 +741,8 @@ describe Chef::Provider::SystemdUnit do
696
741
  context "when a user is specified" do
697
742
  it "try-restarts the unit" do
698
743
  current_resource.user(user_name)
699
- expect(provider).to receive(:shell_out_with_systems_locale!)
700
- .with("#{systemctl_path} --user try-restart #{unit_name_escaped}", user_cmd_opts)
744
+ expect(provider).to receive(:shell_out!)
745
+ .with("#{systemctl_path} --user try-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
701
746
  .and_return(shell_out_success)
702
747
  provider.action_try_restart
703
748
  end
@@ -705,8 +750,8 @@ describe Chef::Provider::SystemdUnit do
705
750
 
706
751
  context "when no user is specified" do
707
752
  it "try-restarts the unit" do
708
- expect(provider).to receive(:shell_out_with_systems_locale!)
709
- .with("#{systemctl_path} --system try-restart #{unit_name_escaped}", {})
753
+ expect(provider).to receive(:shell_out!)
754
+ .with("#{systemctl_path} --system try-restart #{unit_name_escaped}", default_env: false)
710
755
  .and_return(shell_out_success)
711
756
  provider.action_try_restart
712
757
  end
@@ -717,8 +762,8 @@ describe Chef::Provider::SystemdUnit do
717
762
  context "when a user is specified" do
718
763
  it "reload-or-restarts the unit" do
719
764
  current_resource.user(user_name)
720
- expect(provider).to receive(:shell_out_with_systems_locale!)
721
- .with("#{systemctl_path} --user reload-or-restart #{unit_name_escaped}", user_cmd_opts)
765
+ expect(provider).to receive(:shell_out!)
766
+ .with("#{systemctl_path} --user reload-or-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
722
767
  .and_return(shell_out_success)
723
768
  provider.action_reload_or_restart
724
769
  end
@@ -726,8 +771,8 @@ describe Chef::Provider::SystemdUnit do
726
771
 
727
772
  context "when no user is specified" do
728
773
  it "reload-or-restarts the unit" do
729
- expect(provider).to receive(:shell_out_with_systems_locale!)
730
- .with("#{systemctl_path} --system reload-or-restart #{unit_name_escaped}", {})
774
+ expect(provider).to receive(:shell_out!)
775
+ .with("#{systemctl_path} --system reload-or-restart #{unit_name_escaped}", default_env: false)
731
776
  .and_return(shell_out_success)
732
777
  provider.action_reload_or_restart
733
778
  end
@@ -738,8 +783,8 @@ describe Chef::Provider::SystemdUnit do
738
783
  context "when a user is specified" do
739
784
  it "reload-or-try-restarts the unit" do
740
785
  current_resource.user(user_name)
741
- expect(provider).to receive(:shell_out_with_systems_locale!)
742
- .with("#{systemctl_path} --user reload-or-try-restart #{unit_name_escaped}", user_cmd_opts)
786
+ expect(provider).to receive(:shell_out!)
787
+ .with("#{systemctl_path} --user reload-or-try-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
743
788
  .and_return(shell_out_success)
744
789
  provider.action_reload_or_try_restart
745
790
  end
@@ -747,8 +792,8 @@ describe Chef::Provider::SystemdUnit do
747
792
 
748
793
  context "when no user is specified" do
749
794
  it "reload-or-try-restarts the unit" do
750
- expect(provider).to receive(:shell_out_with_systems_locale!)
751
- .with("#{systemctl_path} --system reload-or-try-restart #{unit_name_escaped}", {})
795
+ expect(provider).to receive(:shell_out!)
796
+ .with("#{systemctl_path} --system reload-or-try-restart #{unit_name_escaped}", default_env: false)
752
797
  .and_return(shell_out_success)
753
798
  provider.action_reload_or_try_restart
754
799
  end