chef 14.1.12-universal-mingw32 → 14.2.0-universal-mingw32

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
@@ -22,7 +22,7 @@ require "spec_helper"
22
22
  shared_examples_for "an execute resource" do
23
23
 
24
24
  before(:each) do
25
- @resource = execute_resource
25
+ @resource = resource
26
26
  end
27
27
 
28
28
  it "should create a new Chef::Resource::Execute" do
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Daniel DeLeo (<dan@chef.io>)
4
- # Copyright:: Copyright 2008-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2018, Chef Software Inc.
5
5
  #
6
6
  # License:: Apache License, Version 2.0
7
7
  #
@@ -385,7 +385,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
385
385
  expect(Pathname).to receive(:new).with(@new_resource.home).and_return(@new_home_mock)
386
386
  expect(@new_home_mock).to receive(:cleanpath).and_return(home_check["new_resource_home"].last)
387
387
 
388
- expect(provider.updating_home?).to eq(home_check["expected_result"])
388
+ expect(provider.send(:updating_home?)).to eq(home_check["expected_result"])
389
389
  end
390
390
  end
391
391
  it "should return true if the current home does not exist but a home is specified by the new resource" do
@@ -396,7 +396,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
396
396
  @current_resource.home nil
397
397
  @new_resource.home "/home/kitten"
398
398
 
399
- expect(provider.updating_home?).to eq(true)
399
+ expect(provider.send(:updating_home?)).to eq(true)
400
400
  end
401
401
  end
402
402
  end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Author:: Jeremy Miller (<jm@chef.io>)
3
+ # Copyright:: Copyright 2014-2018, Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+ require "lib/chef/chef_fs/data_handler/data_handler_base"
21
+
22
+ describe Chef::ChefFS::DataHandler::DataHandlerBase do
23
+ describe "#normalize_hash" do
24
+ let(:some_item) do
25
+ { "name" => "grizzly",
26
+ "gender" => "female",
27
+ "age" => 3,
28
+ "food" => "honey"
29
+ }
30
+ end
31
+
32
+ let(:item_defaults) do
33
+ { "family" => "ursidae",
34
+ "hibernate" => true,
35
+ "food" => "berries",
36
+ "avg_lifespan_years" => 22
37
+ }
38
+ end
39
+
40
+ let(:normalized) do
41
+ { "name" => "grizzly",
42
+ "gender" => "female",
43
+ "family" => "ursidae",
44
+ "hibernate" => true,
45
+ "avg_lifespan_years" => 22,
46
+ "age" => 3,
47
+ "food" => "honey"
48
+ }
49
+ end
50
+
51
+ let(:handler) { described_class.new }
52
+
53
+ it "normalizes the Hash, filling in default values" do
54
+ expect(handler.normalize_hash(some_item, item_defaults)).to eq(normalized)
55
+ end
56
+
57
+ it "prefers already existing values over default values" do
58
+ expect(handler.normalize_hash(some_item, item_defaults)["food"]).to eq("honey")
59
+ end
60
+
61
+ it "handles being passed a nil value instead of Hash" do
62
+ expect(handler.normalize_hash(nil, item_defaults)).to eq(item_defaults)
63
+ end
64
+ end
65
+ end
@@ -82,7 +82,7 @@ describe Chef::Cookbook::ManifestV0 do
82
82
 
83
83
  it "creates an all_files key and populates it" do
84
84
  result = described_class.from_hash(source_hash)
85
- expect(result[:all_files].map { |f| f["name"] }).to match_array %w{ recipes/default.rb attributes/default.rb README.rdoc }
85
+ expect(result[:all_files].map { |f| f["name"] }).to match_array %w{ recipes/default.rb attributes/default.rb root_files/README.rdoc }
86
86
  end
87
87
 
88
88
  it "deletes unwanted segment types" do
@@ -122,6 +122,8 @@ describe Chef::CookbookManifest do
122
122
  parts = relative_path.split("/")
123
123
  name = if %w{templates files}.include?(parts[0]) && parts.length == 3
124
124
  File.join(parts[0], parts[2])
125
+ elsif parts.length == 1
126
+ "root_files/#{parts[0]}"
125
127
  else
126
128
  relative_path
127
129
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Daniel DeLeo (<dan@chef.io>)
3
- # Copyright:: Copyright 2014-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2014-2018, 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");
@@ -53,10 +53,6 @@ describe Chef::DSL::Recipe do
53
53
  it "responds to shell_out" do
54
54
  expect(recipe.respond_to?(:shell_out!)).to be true
55
55
  end
56
-
57
- it "responds to shell_out" do
58
- expect(recipe.respond_to?(:shell_out_with_systems_locale)).to be true
59
- end
60
56
  end
61
57
 
62
58
  context "when included in a class that defines the required interface directly" do
@@ -20,18 +20,18 @@ require "spec_helper"
20
20
  require "chef/http/authenticator"
21
21
 
22
22
  describe Chef::HTTP::Authenticator do
23
- let(:class_instance) { Chef::HTTP::Authenticator.new }
24
- let(:method) { double("method") }
25
- let(:url) { double("url") }
23
+ let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
24
+ let(:method) { "GET" }
25
+ let(:url) { URI("https://chef.example.com/organizations/test") }
26
26
  let(:headers) { Hash.new }
27
- let(:data) { double("data") }
28
-
29
- before do
30
- allow(class_instance).to receive(:authentication_headers).and_return({})
31
- end
27
+ let(:data) { "" }
32
28
 
33
29
  context "when handle_request is called" do
34
30
  shared_examples_for "merging the server API version into the headers" do
31
+ before do
32
+ allow(class_instance).to receive(:authentication_headers).and_return({})
33
+ end
34
+
35
35
  it "merges the default version of X-Ops-Server-API-Version into the headers" do
36
36
  # headers returned
37
37
  expect(class_instance.handle_request(method, url, headers, data)[2]).
@@ -96,5 +96,30 @@ describe Chef::HTTP::Authenticator do
96
96
  class_instance.handle_request(method, url, headers, data)
97
97
  end
98
98
  end
99
+
100
+ context "when ssh_agent_signing" do
101
+ let(:public_key) { <<-EOH }
102
+ -----BEGIN PUBLIC KEY-----
103
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA49TA0y81ps0zxkOpmf5V
104
+ 4/c4IeR5yVyQFpX3JpxO4TquwnRh8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE
105
+ 6915kXSuk/cWIcNozujLK7tkuPEyYVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXr
106
+ WqYCnhxgOjxocenREYNhZ/OETIeiPbOku47vB4nJK/0GhKBytL2XnsRgfKgDxf42
107
+ BqAi1jglIdeq8lAWZNF9TbNBU21AO1iuT7Pm6LyQujhggPznR5FJhXKRUARXBJZa
108
+ wxpGV4dGtdcahwXNE4601aXPra+xPcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1Q
109
+ YwIDAQAB
110
+ -----END PUBLIC KEY-----
111
+ EOH
112
+
113
+ let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test", raw_key: public_key, ssh_agent_signing: true) }
114
+
115
+ it "sets use_ssh_agent if needed" do
116
+ expect(Mixlib::Authentication::SignedHeaderAuth).to receive(:signing_object).and_wrap_original { |m, *args|
117
+ m.call(*args).tap do |signing_obj|
118
+ expect(signing_obj).to receive(:sign).with(instance_of(OpenSSL::PKey::RSA), use_ssh_agent: true).and_return({})
119
+ end
120
+ }
121
+ class_instance.handle_request(method, url, headers, data)
122
+ end
123
+ end
99
124
  end
100
125
  end
@@ -226,11 +226,71 @@ describe Chef::Mixin::ShellOut do
226
226
 
227
227
  describe "when the last argument is not a Hash" do
228
228
  it "should no longer add environment options and set environment['LC_ALL'] to nil" do
229
- expect(shell_out_obj).to receive(:shell_out_command).with(cmd).and_return(true)
229
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {}).and_return(true)
230
230
  shell_out_obj.shell_out_with_systems_locale(cmd)
231
231
  end
232
232
  end
233
233
  end
234
234
 
235
+ describe "#shell_out default_env: false" do
236
+
237
+ describe "when the last argument is a Hash" do
238
+ describe "and environment is an option" do
239
+ it "should not change environment['LC_ALL'] when set to nil" do
240
+ options = { :environment => { "LC_ALL" => nil } }
241
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
242
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
243
+ end
244
+
245
+ it "should not change environment['LC_ALL'] when set to non-nil" do
246
+ options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
247
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
248
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
249
+ end
250
+
251
+ it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
252
+ options = { :environment => { "HOME" => "/Users/morty" } }
253
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
254
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
255
+ end
256
+ end
257
+
258
+ describe "and env is an option" do
259
+ it "should not change env when set to nil" do
260
+ options = { :env => { "LC_ALL" => nil } }
261
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
262
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
263
+ end
264
+
265
+ it "should not change env when set to non-nil" do
266
+ options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
267
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
268
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
269
+ end
270
+
271
+ it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
272
+ options = { :env => { "HOME" => "/Users/morty" } }
273
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
274
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
275
+ end
276
+ end
277
+
278
+ describe "and no env/environment option is present" do
279
+ it "should no longer add environment option and set environment['LC_ALL'] to nil" do
280
+ options = { :user => "morty" }
281
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
282
+ shell_out_obj.shell_out(cmd, **options, default_env: false)
283
+ end
284
+ end
285
+ end
286
+
287
+ describe "when the last argument is not a Hash" do
288
+ it "should no longer add environment options and set environment['LC_ALL'] to nil" do
289
+ expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {}).and_return(true)
290
+ shell_out_obj.shell_out(cmd, default_env: false)
291
+ end
292
+ end
293
+ end
294
+
235
295
  end
236
296
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Thom May (<thom@chef.io>)
3
- # Copyright:: Copyright (c) 2016-2017, Chef Software Inc.
3
+ # Copyright:: Copyright (c) 2016-2018, 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");
@@ -45,7 +45,7 @@ describe Chef::Provider::AptUpdate do
45
45
  before do
46
46
  FileUtils.rmdir config_dir
47
47
  expect(File.exist?(config_dir)).to be false
48
- allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
48
+ allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything())
49
49
  end
50
50
 
51
51
  it "should create the directory" do
@@ -64,7 +64,7 @@ describe Chef::Provider::AptUpdate do
64
64
  describe "#action_update" do
65
65
  it "should update the apt cache" do
66
66
  provider.load_current_resource
67
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
67
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything())
68
68
  provider.run_action(:update)
69
69
  expect(new_resource).to be_updated_by_last_action
70
70
  end
@@ -79,14 +79,14 @@ describe Chef::Provider::AptUpdate do
79
79
 
80
80
  it "should run if the time stamp is old" do
81
81
  expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 86_500)
82
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
82
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything())
83
83
  provider.run_action(:periodic)
84
84
  expect(new_resource).to be_updated_by_last_action
85
85
  end
86
86
 
87
87
  it "should not run if the time stamp is new" do
88
88
  expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now)
89
- expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
89
+ expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out!).with("apt-get -q update", anything())
90
90
  provider.run_action(:periodic)
91
91
  expect(new_resource).to_not be_updated_by_last_action
92
92
  end
@@ -98,14 +98,14 @@ describe Chef::Provider::AptUpdate do
98
98
 
99
99
  it "should run if the time stamp is old" do
100
100
  expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 500)
101
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
101
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything())
102
102
  provider.run_action(:periodic)
103
103
  expect(new_resource).to be_updated_by_last_action
104
104
  end
105
105
 
106
106
  it "should not run if the time stamp is new" do
107
107
  expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 300)
108
- expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
108
+ expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out!).with("apt-get -q update", anything())
109
109
  provider.run_action(:periodic)
110
110
  expect(new_resource).to_not be_updated_by_last_action
111
111
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Prajakta Purohit (<prajakta@chef.io>)
3
- # Copyright:: Copyright 2008-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2018, 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");
@@ -33,6 +33,7 @@ describe Chef::Provider::Execute do
33
33
  timeout: 3600,
34
34
  returns: 0,
35
35
  log_level: :info,
36
+ default_env: false,
36
37
  log_tag: new_resource.to_s,
37
38
  }
38
39
  end
@@ -76,7 +77,7 @@ describe Chef::Provider::Execute do
76
77
 
77
78
  describe "#action_run" do
78
79
  it "runs shell_out with the default options" do
79
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
80
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
80
81
  expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
81
82
  expect(Chef::Log).not_to receive(:warn)
82
83
  provider.run_action(:run)
@@ -103,7 +104,7 @@ describe Chef::Provider::Execute do
103
104
 
104
105
  it "if you pass a command attribute, it runs the command" do
105
106
  new_resource.command "/usr/argelbargle/bin/oogachacka 12345"
106
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.command, opts)
107
+ expect(provider).to receive(:shell_out!).with(new_resource.command, opts)
107
108
  expect(provider).to receive(:converge_by).with("execute #{new_resource.command}").and_call_original
108
109
  expect(Chef::Log).not_to receive(:warn)
109
110
  provider.run_action(:run)
@@ -114,7 +115,7 @@ describe Chef::Provider::Execute do
114
115
  new_resource.sensitive true
115
116
  # Since the resource is sensitive, it should not have :live_stream set
116
117
  opts.delete(:live_stream)
117
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
118
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
118
119
  expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
119
120
  expect(Chef::Log).not_to receive(:warn)
120
121
  provider.run_action(:run)
@@ -124,7 +125,7 @@ describe Chef::Provider::Execute do
124
125
  it "should do nothing if the sentinel file exists" do
125
126
  new_resource.creates "/foo_resource"
126
127
  expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
127
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
128
+ expect(provider).not_to receive(:shell_out!)
128
129
  expect(Chef::Log).not_to receive(:warn)
129
130
  provider.run_action(:run)
130
131
  expect(new_resource).not_to be_updated
@@ -137,7 +138,7 @@ describe Chef::Provider::Execute do
137
138
  end
138
139
 
139
140
  it "should raise if user specified relative path without cwd for Chef-13" do
140
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
141
+ expect(provider).not_to receive(:shell_out!)
141
142
  expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::Execute)
142
143
  end
143
144
  end
@@ -148,7 +149,7 @@ describe Chef::Provider::Execute do
148
149
  expect(FileTest).not_to receive(:exist?).with(new_resource.creates)
149
150
  expect(FileTest).to receive(:exist?).with(File.join("/tmp", new_resource.creates)).and_return(true)
150
151
  expect(Chef::Log).not_to receive(:warn)
151
- expect(provider).not_to receive(:shell_out_with_systems_locale!)
152
+ expect(provider).not_to receive(:shell_out!)
152
153
 
153
154
  provider.run_action(:run)
154
155
  expect(new_resource).not_to be_updated
@@ -157,7 +158,7 @@ describe Chef::Provider::Execute do
157
158
  it "should not include stdout/stderr in failure exception for sensitive resource" do
158
159
  opts.delete(:live_stream)
159
160
  new_resource.sensitive true
160
- expect(provider).to receive(:shell_out_with_systems_locale!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
161
+ expect(provider).to receive(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
161
162
  expect do
162
163
  provider.run_action(:run)
163
164
  end.to raise_error(Mixlib::ShellOut::ShellCommandFailed, /suppressed for sensitive resource/)
@@ -166,7 +167,7 @@ describe Chef::Provider::Execute do
166
167
  describe "streaming output" do
167
168
  it "should not set the live_stream if sensitive is on" do
168
169
  new_resource.sensitive true
169
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
170
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
170
171
  expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
171
172
  expect(Chef::Log).not_to receive(:warn)
172
173
  provider.run_action(:run)
@@ -183,7 +184,7 @@ describe Chef::Provider::Execute do
183
184
  it "should set the live_stream if the log level is info or above" do
184
185
  nopts = opts
185
186
  nopts[:live_stream] = @live_stream
186
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
187
+ expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
187
188
  expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
188
189
  expect(Chef::Log).not_to receive(:warn)
189
190
  provider.run_action(:run)
@@ -195,7 +196,7 @@ describe Chef::Provider::Execute do
195
196
  new_resource.live_stream true
196
197
  nopts = opts
197
198
  nopts[:live_stream] = @live_stream
198
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
199
+ expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
199
200
  expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
200
201
  expect(Chef::Log).not_to receive(:warn)
201
202
  provider.run_action(:run)
@@ -204,7 +205,7 @@ describe Chef::Provider::Execute do
204
205
 
205
206
  it "should not set the live_stream if the resource is sensitive" do
206
207
  new_resource.sensitive true
207
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
208
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
208
209
  expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
209
210
  expect(Chef::Log).not_to receive(:warn)
210
211
  provider.run_action(:run)
@@ -217,7 +218,7 @@ describe Chef::Provider::Execute do
217
218
  nopts = opts
218
219
  nopts[:live_stream] = STDOUT
219
220
  allow(STDOUT).to receive(:tty?).and_return(true)
220
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
221
+ expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
221
222
  expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
222
223
  expect(Chef::Log).not_to receive(:warn)
223
224
  provider.run_action(:run)
@@ -227,7 +228,7 @@ describe Chef::Provider::Execute do
227
228
  it "should not set the live_stream to STDOUT if we are a TTY, not daemonized, but sensitive" do
228
229
  new_resource.sensitive true
229
230
  allow(STDOUT).to receive(:tty?).and_return(true)
230
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
231
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
231
232
  expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
232
233
  expect(Chef::Log).not_to receive(:warn)
233
234
  provider.run_action(:run)
@@ -237,7 +238,7 @@ describe Chef::Provider::Execute do
237
238
  it "should not set the live_stream to STDOUT if we are a TTY, but daemonized" do
238
239
  Chef::Config[:daemon] = true
239
240
  allow(STDOUT).to receive(:tty?).and_return(true)
240
- expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
241
+ expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
241
242
  expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
242
243
  expect(Chef::Log).not_to receive(:warn)
243
244
  provider.run_action(:run)