chef 15.8.23 → 15.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +1 -1
  4. data/Rakefile +9 -0
  5. data/lib/chef/application.rb +1 -1
  6. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  7. data/lib/chef/chef_fs/command_line.rb +5 -5
  8. data/lib/chef/cookbook/metadata.rb +5 -4
  9. data/lib/chef/cookbook/synchronizer.rb +1 -0
  10. data/lib/chef/cookbook_loader.rb +1 -1
  11. data/lib/chef/data_collector/config_validation.rb +7 -7
  12. data/lib/chef/deprecated.rb +5 -5
  13. data/lib/chef/dsl/platform_introspection.rb +2 -2
  14. data/lib/chef/dsl/reboot_pending.rb +3 -3
  15. data/lib/chef/http/json_output.rb +1 -1
  16. data/lib/chef/knife.rb +1 -1
  17. data/lib/chef/knife/bootstrap/templates/README.md +2 -2
  18. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  19. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
  20. data/lib/chef/knife/core/ui.rb +1 -1
  21. data/lib/chef/knife/core/windows_bootstrap_context.rb +8 -8
  22. data/lib/chef/knife/data_bag_edit.rb +2 -2
  23. data/lib/chef/knife/edit.rb +1 -1
  24. data/lib/chef/knife/environment_compare.rb +1 -1
  25. data/lib/chef/knife/list.rb +1 -1
  26. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  27. data/lib/chef/provider/group/usermod.rb +2 -5
  28. data/lib/chef/provider/mount/mount.rb +1 -1
  29. data/lib/chef/provider/package/homebrew.rb +1 -2
  30. data/lib/chef/provider/package/rubygems.rb +1 -1
  31. data/lib/chef/provider/package/yum/python_helper.rb +2 -2
  32. data/lib/chef/provider/package/yum/rpm_utils.rb +4 -4
  33. data/lib/chef/provider/package/zypper.rb +2 -1
  34. data/lib/chef/provider/remote_file.rb +2 -2
  35. data/lib/chef/provider/route.rb +4 -4
  36. data/lib/chef/provider/windows_env.rb +3 -3
  37. data/lib/chef/resource.rb +7 -2
  38. data/lib/chef/resource/build_essential.rb +46 -22
  39. data/lib/chef/resource/cron.rb +1 -1
  40. data/lib/chef/resource/cron_d.rb +1 -1
  41. data/lib/chef/resource/execute.rb +1 -1
  42. data/lib/chef/resource/freebsd_package.rb +0 -3
  43. data/lib/chef/resource/homebrew_package.rb +1 -2
  44. data/lib/chef/resource/hostname.rb +2 -2
  45. data/lib/chef/resource/kernel_module.rb +3 -2
  46. data/lib/chef/resource/openbsd_package.rb +0 -3
  47. data/lib/chef/resource/remote_file.rb +1 -1
  48. data/lib/chef/resource/rhsm_errata.rb +9 -2
  49. data/lib/chef/resource/rhsm_errata_level.rb +11 -5
  50. data/lib/chef/resource/rhsm_register.rb +27 -12
  51. data/lib/chef/resource/swap_file.rb +2 -2
  52. data/lib/chef/resource/timezone.rb +2 -2
  53. data/lib/chef/resource/windows_certificate.rb +0 -2
  54. data/lib/chef/resource/windows_share.rb +1 -1
  55. data/lib/chef/shell/ext.rb +1 -1
  56. data/lib/chef/util/diff.rb +3 -3
  57. data/lib/chef/util/selinux.rb +2 -2
  58. data/lib/chef/version.rb +1 -1
  59. data/lib/chef/win32/error.rb +1 -1
  60. data/lib/chef/win32/registry.rb +1 -1
  61. data/lib/chef/win32/system.rb +0 -0
  62. data/spec/data/cookbooks/starter/recipes/default.rb +1 -1
  63. data/spec/data/windows_certificates/base64_test.cer +18 -20
  64. data/spec/data/windows_certificates/othertest.cer +0 -0
  65. data/spec/data/windows_certificates/test.cer +0 -0
  66. data/spec/data/windows_certificates/test.p7b +0 -0
  67. data/spec/data/windows_certificates/test.pem +18 -19
  68. data/spec/data/windows_certificates/test.pfx +0 -0
  69. data/spec/functional/resource/ifconfig_spec.rb +2 -2
  70. data/spec/functional/resource/windows_certificate_spec.rb +9 -9
  71. data/spec/functional/resource/windows_service_spec.rb +1 -2
  72. data/spec/functional/run_lock_spec.rb +7 -1
  73. data/spec/functional/win32/service_manager_spec.rb +1 -1
  74. data/spec/functional/win32/version_info_spec.rb +4 -4
  75. data/spec/integration/client/client_spec.rb +2 -2
  76. data/spec/integration/client/exit_code_spec.rb +1 -0
  77. data/spec/integration/client/ipv6_spec.rb +1 -0
  78. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -0
  79. data/spec/integration/knife/chef_repo_path_spec.rb +1 -0
  80. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -0
  81. data/spec/integration/knife/chefignore_spec.rb +1 -0
  82. data/spec/integration/knife/client_bulk_delete_spec.rb +1 -0
  83. data/spec/integration/knife/client_create_spec.rb +1 -0
  84. data/spec/integration/knife/client_delete_spec.rb +1 -0
  85. data/spec/integration/knife/client_key_create_spec.rb +1 -0
  86. data/spec/integration/knife/client_key_delete_spec.rb +1 -0
  87. data/spec/integration/knife/client_key_list_spec.rb +1 -0
  88. data/spec/integration/knife/client_key_show_spec.rb +1 -0
  89. data/spec/integration/knife/client_list_spec.rb +1 -0
  90. data/spec/integration/knife/client_show_spec.rb +1 -0
  91. data/spec/integration/knife/common_options_spec.rb +1 -0
  92. data/spec/integration/knife/config_get_profile_spec.rb +1 -0
  93. data/spec/integration/knife/config_get_spec.rb +1 -0
  94. data/spec/integration/knife/config_list_profiles_spec.rb +1 -0
  95. data/spec/integration/knife/config_use_profile_spec.rb +1 -0
  96. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -0
  97. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +1 -0
  98. data/spec/integration/knife/cookbook_download_spec.rb +1 -0
  99. data/spec/integration/knife/cookbook_list_spec.rb +1 -0
  100. data/spec/integration/knife/cookbook_show_spec.rb +1 -0
  101. data/spec/integration/knife/cookbook_upload_spec.rb +1 -0
  102. data/spec/integration/knife/data_bag_create_spec.rb +1 -0
  103. data/spec/integration/knife/data_bag_delete_spec.rb +1 -0
  104. data/spec/integration/knife/data_bag_edit_spec.rb +1 -0
  105. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -0
  106. data/spec/integration/knife/data_bag_list_spec.rb +1 -0
  107. data/spec/integration/knife/data_bag_show_spec.rb +1 -0
  108. data/spec/integration/knife/delete_spec.rb +1 -0
  109. data/spec/integration/knife/deps_spec.rb +3 -2
  110. data/spec/integration/knife/diff_spec.rb +1 -0
  111. data/spec/integration/knife/download_spec.rb +1 -0
  112. data/spec/integration/knife/environment_compare_spec.rb +1 -0
  113. data/spec/integration/knife/environment_create_spec.rb +1 -0
  114. data/spec/integration/knife/environment_delete_spec.rb +1 -0
  115. data/spec/integration/knife/environment_from_file_spec.rb +1 -0
  116. data/spec/integration/knife/environment_list_spec.rb +1 -0
  117. data/spec/integration/knife/environment_show_spec.rb +1 -0
  118. data/spec/integration/knife/list_spec.rb +1 -0
  119. data/spec/integration/knife/node_bulk_delete_spec.rb +1 -0
  120. data/spec/integration/knife/node_create_spec.rb +1 -0
  121. data/spec/integration/knife/node_delete_spec.rb +1 -0
  122. data/spec/integration/knife/node_environment_set_spec.rb +1 -0
  123. data/spec/integration/knife/node_from_file_spec.rb +1 -0
  124. data/spec/integration/knife/node_list_spec.rb +1 -0
  125. data/spec/integration/knife/node_run_list_add_spec.rb +1 -0
  126. data/spec/integration/knife/node_run_list_remove_spec.rb +1 -0
  127. data/spec/integration/knife/node_run_list_set_spec.rb +1 -0
  128. data/spec/integration/knife/node_show_spec.rb +1 -0
  129. data/spec/integration/knife/raw_spec.rb +1 -0
  130. data/spec/integration/knife/redirection_spec.rb +1 -0
  131. data/spec/integration/knife/role_bulk_delete_spec.rb +1 -0
  132. data/spec/integration/knife/role_create_spec.rb +1 -0
  133. data/spec/integration/knife/role_delete_spec.rb +1 -0
  134. data/spec/integration/knife/role_from_file_spec.rb +1 -0
  135. data/spec/integration/knife/role_list_spec.rb +1 -0
  136. data/spec/integration/knife/role_show_spec.rb +1 -0
  137. data/spec/integration/knife/search_node_spec.rb +1 -0
  138. data/spec/integration/knife/show_spec.rb +1 -0
  139. data/spec/integration/knife/upload_spec.rb +1 -0
  140. data/spec/integration/recipes/accumulator_spec.rb +1 -0
  141. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -0
  142. data/spec/integration/recipes/lwrp_spec.rb +1 -0
  143. data/spec/integration/recipes/notifies_spec.rb +1 -0
  144. data/spec/integration/recipes/notifying_block_spec.rb +1 -0
  145. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
  146. data/spec/integration/recipes/resource_action_spec.rb +1 -0
  147. data/spec/integration/recipes/unified_mode_spec.rb +1 -0
  148. data/spec/integration/solo/solo_spec.rb +1 -0
  149. data/spec/spec_helper.rb +7 -10
  150. data/spec/support/chef_helpers.rb +1 -1
  151. data/spec/support/key_helpers.rb +0 -2
  152. data/spec/support/platform_helpers.rb +7 -3
  153. data/spec/support/platforms/win32/spec_service.rb +27 -25
  154. data/spec/support/shared/context/config.rb +0 -3
  155. data/spec/support/shared/integration/integration_helper.rb +0 -1
  156. data/spec/support/shared/unit/execute_resource.rb +0 -2
  157. data/spec/support/shared/unit/provider/file.rb +0 -1
  158. data/spec/support/shared/unit/script_resource.rb +2 -4
  159. data/spec/support/shared/unit/windows_script_resource.rb +0 -2
  160. data/spec/unit/cookbook/gem_installer_spec.rb +1 -1
  161. data/spec/unit/cookbook/metadata_spec.rb +1 -10
  162. data/spec/unit/data_collector_spec.rb +1 -1
  163. data/spec/unit/deprecated_spec.rb +3 -3
  164. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +1 -1
  165. data/spec/unit/encrypted_data_bag_item_spec.rb +2 -2
  166. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +3 -3
  167. data/spec/unit/knife_spec.rb +6 -7
  168. data/spec/unit/mixin/shell_out_spec.rb +27 -29
  169. data/spec/unit/provider/file_spec.rb +1 -0
  170. data/spec/unit/resource/build_essential_spec.rb +48 -2
  171. data/spec/unit/resource/data/InstallHistory_with_CLT.plist +92 -0
  172. data/spec/unit/resource/data/InstallHistory_without_CLT.plist +38 -0
  173. data/spec/unit/resource/execute_spec.rb +1 -1
  174. data/spec/unit/resource/rhsm_register_spec.rb +24 -0
  175. data/spec/unit/resource/windows_share_spec.rb +3 -1
  176. data/tasks/rspec.rb +1 -0
  177. metadata +8 -6
@@ -24,7 +24,6 @@ require "chef/json_compat"
24
24
  require "chef/server_api"
25
25
  require "support/shared/integration/knife_support"
26
26
  require "cheffish/rspec/chef_run_support"
27
- require "spec_helper"
28
27
 
29
28
  module Cheffish
30
29
  class BasicChefClient
@@ -17,8 +17,6 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "spec_helper"
21
-
22
20
  shared_examples_for "an execute resource" do
23
21
 
24
22
  before(:each) do
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "spec_helper"
20
19
  require "tmpdir"
21
20
  if windows?
22
21
  require "chef/win32/file"
@@ -17,8 +17,6 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "spec_helper"
21
-
22
20
  shared_examples_for "a script resource" do
23
21
 
24
22
  it "should create a new Chef::Resource::Script" do
@@ -30,7 +28,7 @@ shared_examples_for "a script resource" do
30
28
  expect(script_resource.resource_name).to eql(resource_name)
31
29
  end
32
30
 
33
- it "should set command to nil on the resource", chef: ">= 13" do
31
+ it "should set command to nil on the resource" do
34
32
  expect(script_resource.command).to be nil
35
33
  end
36
34
 
@@ -44,7 +42,7 @@ shared_examples_for "a script resource" do
44
42
  expect(script_resource.flags.strip).to eql("-f")
45
43
  end
46
44
 
47
- it "should raise an exception if users set command on the resource", chef: ">= 13" do
45
+ it "should raise an exception if users set command on the resource" do
48
46
  expect { script_resource.command("foo") }.to raise_error(Chef::Exceptions::Script)
49
47
  end
50
48
 
@@ -16,8 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "spec_helper"
20
-
21
19
  require "support/shared/unit/execute_resource"
22
20
  require "support/shared/unit/script_resource"
23
21
 
@@ -1,5 +1,5 @@
1
1
  require "spec_helper"
2
- require "bundler/dsl"
2
+ require "bundler"
3
3
 
4
4
  describe Chef::Cookbook::GemInstaller do
5
5
  let(:cookbook_collection) do
@@ -267,16 +267,7 @@ describe Chef::Cookbook::Metadata do
267
267
  end
268
268
  end
269
269
 
270
- it "strips out self-dependencies", chef: "< 13" do
271
- metadata.name("foo")
272
- expect(Chef::Log).to receive(:warn).with(
273
- "Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)."
274
- )
275
- metadata.depends("foo")
276
- expect(metadata.dependencies).to eql({})
277
- end
278
-
279
- it "errors on self-dependencies", chef: ">= 13" do
270
+ it "errors on self-dependencies" do
280
271
  metadata.name("foo")
281
272
  expect { metadata.depends("foo") }.to raise_error
282
273
  # FIXME: add the error type
@@ -626,7 +626,7 @@ describe Chef::DataCollector do
626
626
  it "collects deprecation messages" do
627
627
  location = Chef::Log.caller_location
628
628
  events.deprecation(Chef::Deprecated.create(:internal_api, "deprecation warning", location))
629
- expect_converge_message("deprecations" => [{ location: location, message: "deprecation warning", url: "https://docs.chef.io/deprecations_internal_api.html" }])
629
+ expect_converge_message("deprecations" => [{ location: location, message: "deprecation warning", url: "https://docs.chef.io/deprecations_internal_api/" }])
630
630
  send_run_failed_or_completed_event
631
631
  end
632
632
  end
@@ -20,7 +20,7 @@ require "chef/deprecated"
20
20
 
21
21
  describe Chef::Deprecated do
22
22
  class TestDeprecation < Chef::Deprecated::Base
23
- target 999, "test.html"
23
+ target 999, "test"
24
24
  end
25
25
 
26
26
  context "loading a deprecation class" do
@@ -44,11 +44,11 @@ describe Chef::Deprecated do
44
44
  let(:location) { "the location" }
45
45
 
46
46
  it "displays the full URL" do
47
- expect(TestDeprecation.new.url).to eql("https://docs.chef.io/deprecations_test.html")
47
+ expect(TestDeprecation.new.url).to eql("https://docs.chef.io/deprecations_test/")
48
48
  end
49
49
 
50
50
  it "formats a complete deprecation message" do
51
- expect(TestDeprecation.new(message, location).to_s).to eql("Deprecation CHEF-999 from the location\n\n A test message\n\nPlease see https://docs.chef.io/deprecations_test.html for further details and information on how to correct this problem.")
51
+ expect(TestDeprecation.new(message, location).to_s).to eql("Deprecation CHEF-999 from the location\n\n A test message\n\nPlease see https://docs.chef.io/deprecations_test/ for further details and information on how to correct this problem.")
52
52
  end
53
53
  end
54
54
 
@@ -85,7 +85,7 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do
85
85
  end
86
86
  end
87
87
 
88
- context "when encryption version is 3", :aes_256_gcm_only, ruby: "~> 2.0.0" do
88
+ context "when encryption version is 3", :aes_256_gcm_only do
89
89
  include_examples "encryption detected" do
90
90
  let(:version) { 3 }
91
91
  let(:encryptor) { Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor }
@@ -97,7 +97,7 @@ describe Chef::EncryptedDataBagItem::Encryptor do
97
97
  Chef::Config[:data_bag_encrypt_version] = 3
98
98
  end
99
99
 
100
- context "on supported platforms", :aes_256_gcm_only, ruby: "~> 2.0.0" do
100
+ context "on supported platforms", :aes_256_gcm_only do
101
101
 
102
102
  it "creates a version 3 encryptor" do
103
103
  expect(encryptor).to be_a_instance_of(Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor)
@@ -166,7 +166,7 @@ describe Chef::EncryptedDataBagItem::Decryptor do
166
166
 
167
167
  context "when decrypting a version 3 (JSON+aes-256-gcm+random iv+auth tag) encrypted value" do
168
168
 
169
- context "on supported platforms", :aes_256_gcm_only, ruby: "~> 2.0.0" do
169
+ context "on supported platforms", :aes_256_gcm_only do
170
170
 
171
171
  let(:encrypted_value) do
172
172
  Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor.new(plaintext_data, encryption_key).for_encrypted_item
@@ -164,9 +164,9 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
164
164
  expected = <<~EXPECTED
165
165
  echo.chef_server_url "http://chef.example.com:4444"
166
166
  echo.validation_client_name "chef-validator-testing"
167
- echo.file_cache_path "c:/chef/cache"
168
- echo.file_backup_path "c:/chef/backup"
169
- echo.cache_options ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
167
+ echo.file_cache_path "C:/chef/cache"
168
+ echo.file_backup_path "C:/chef/backup"
169
+ echo.cache_options ^({:path =^> "C:/chef/cache/checksums", :skip_expires =^> true}^)
170
170
  echo.# Using default node name ^(fqdn^)
171
171
  echo.log_level :info
172
172
  echo.log_location STDOUT
@@ -418,13 +418,10 @@ describe Chef::Knife do
418
418
 
419
419
  describe "when first created" do
420
420
 
421
- let(:knife) { KnifeSpecs::TestYourself.new(%w{with some args -s scrogramming}) }
422
-
423
- before do
424
- unless KnifeSpecs.const_defined?(:TestYourself)
425
- Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
426
- end
427
- end
421
+ let(:knife) {
422
+ Kernel.load "spec/data/knife_subcommand/test_yourself.rb"
423
+ KnifeSpecs::TestYourself.new(%w{with some args -s scrogramming})
424
+ }
428
425
 
429
426
  it "it parses the options passed to it" do
430
427
  expect(knife.config[:scro]).to eq("scrogramming")
@@ -435,6 +432,8 @@ describe Chef::Knife do
435
432
  end
436
433
 
437
434
  it "does not have lazy dependencies loaded" do
435
+ skip "unstable with randomization... prolly needs more isolation"
436
+
438
437
  expect(knife.class.test_deps_loaded).not_to be_truthy
439
438
  end
440
439
  end
@@ -246,35 +246,33 @@ describe Chef::Mixin::ShellOut do
246
246
  let(:new_resource) { CustomResource.new("foo") }
247
247
  let(:provider) { new_resource.provider_for_action(:install) }
248
248
 
249
- describe "on Chef-15", chef: ">= 15" do
250
- %i{shell_out shell_out!}.each do |method|
251
- stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted!
252
- it "#{method} defaults to 900 seconds" do
253
- expect(provider).to receive(stubbed_method).with("foo", timeout: 900)
254
- provider.send(method, "foo")
255
- end
256
- it "#{method} overrides the default timeout with its options" do
257
- expect(provider).to receive(stubbed_method).with("foo", timeout: 1)
258
- provider.send(method, "foo", timeout: 1)
259
- end
260
- it "#{method} overrides the new_resource.timeout with the timeout option" do
261
- new_resource.timeout(99)
262
- expect(provider).to receive(stubbed_method).with("foo", timeout: 1)
263
- provider.send(method, "foo", timeout: 1)
264
- end
265
- it "#{method} defaults to 900 seconds and preserves options" do
266
- expect(provider).to receive(stubbed_method).with("foo", env: nil, timeout: 900)
267
- provider.send(method, "foo", env: nil)
268
- end
269
- it "#{method} overrides the default timeout with its options and preserves options" do
270
- expect(provider).to receive(stubbed_method).with("foo", timeout: 1, env: nil)
271
- provider.send(method, "foo", timeout: 1, env: nil)
272
- end
273
- it "#{method} overrides the new_resource.timeout with the timeout option and preseves options" do
274
- new_resource.timeout(99)
275
- expect(provider).to receive(stubbed_method).with("foo", timeout: 1, env: nil)
276
- provider.send(method, "foo", timeout: 1, env: nil)
277
- end
249
+ %i{shell_out shell_out!}.each do |method|
250
+ stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted!
251
+ it "#{method} defaults to 900 seconds" do
252
+ expect(provider).to receive(stubbed_method).with("foo", timeout: 900)
253
+ provider.send(method, "foo")
254
+ end
255
+ it "#{method} overrides the default timeout with its options" do
256
+ expect(provider).to receive(stubbed_method).with("foo", timeout: 1)
257
+ provider.send(method, "foo", timeout: 1)
258
+ end
259
+ it "#{method} overrides the new_resource.timeout with the timeout option" do
260
+ new_resource.timeout(99)
261
+ expect(provider).to receive(stubbed_method).with("foo", timeout: 1)
262
+ provider.send(method, "foo", timeout: 1)
263
+ end
264
+ it "#{method} defaults to 900 seconds and preserves options" do
265
+ expect(provider).to receive(stubbed_method).with("foo", env: nil, timeout: 900)
266
+ provider.send(method, "foo", env: nil)
267
+ end
268
+ it "#{method} overrides the default timeout with its options and preserves options" do
269
+ expect(provider).to receive(stubbed_method).with("foo", timeout: 1, env: nil)
270
+ provider.send(method, "foo", timeout: 1, env: nil)
271
+ end
272
+ it "#{method} overrides the new_resource.timeout with the timeout option and preseves options" do
273
+ new_resource.timeout(99)
274
+ expect(provider).to receive(stubbed_method).with("foo", timeout: 1, env: nil)
275
+ provider.send(method, "foo", timeout: 1, env: nil)
278
276
  end
279
277
  end
280
278
  end
@@ -17,6 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
+ require "spec_helper"
20
21
  require "support/shared/unit/provider/file"
21
22
 
22
23
  describe Chef::Provider::File do
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018, Chef Software, Inc.
2
+ # Copyright:: Copyright 2018-2020, Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,23 @@ require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::BuildEssential do
21
21
 
22
- let(:resource) { Chef::Resource::BuildEssential.new("foo") }
22
+ let(:node) { Chef::Node.new }
23
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
24
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
+ let(:resource) { Chef::Resource::BuildEssential.new("foo", run_context) }
26
+ let(:provider) { resource.provider_for_action(:install) }
27
+
28
+ let(:softwareupdate_catalina_and_later) do
29
+ double("shell_out", exitstatus: 0, error!: nil, stdout: "Software Update Tool\n\nFinding available software\nSoftware Update found the following new or updated software:\n* Label: Command Line Tools for Xcode-11.0\n\tTitle: Command Line Tools for Xcode, Version: 11.0, Size: 224868K, Recommended: YES, \n")
30
+ end
31
+
32
+ let(:softwareupdate_catalina_and_later_no_cli) do
33
+ double("shell_out", exitstatus: 0, error!: nil, stdout: "Software Update Tool\n\nFinding available software\nSoftware Update found the following new or updated software:\n* Label: Chef Infra Client\n\tTitle: Chef Infra Client, Version: 17.0.208, Size: 224868K, Recommended: YES, \n")
34
+ end
35
+
36
+ let(:softwareupdate_pre_catalina) do
37
+ double("shell_out", exitstatus: 0, error!: nil, stdout: "Software Update Tool\n\nFinding available software\nSoftware Update found the following new or updated software:\n * Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0\n")
38
+ end
23
39
 
24
40
  it "has a resource name of :build_essential" do
25
41
  expect(resource.resource_name).to eql(:build_essential)
@@ -40,4 +56,34 @@ describe Chef::Resource::BuildEssential do
40
56
  expect(resource.name).to eql("")
41
57
  end
42
58
  end
59
+
60
+ describe "#xcode_cli_installed?" do
61
+ it "returns true if the CLI is in the InstallHistory plist" do
62
+ allow(::File).to receive(:open).with("/Library/Receipts/InstallHistory.plist", "r").and_return(::File.join(::File.dirname(__FILE__), "data/InstallHistory_with_CLT.plist"))
63
+ expect(provider.xcode_cli_installed?).to eql(true)
64
+ end
65
+
66
+ it "returns false if the pkgutil doesn't list the package" do
67
+ allow(::File).to receive(:open).with("/Library/Receipts/InstallHistory.plist", "r").and_return(::File.join(::File.dirname(__FILE__), "data/InstallHistory_without_CLT.plist"))
68
+ expect(provider.xcode_cli_installed?).to eql(false)
69
+ end
70
+ end
71
+
72
+ describe "#xcode_cli_package_label" do
73
+ it "returns a package name on macOS < 10.15" do
74
+ allow(provider).to receive(:shell_out).with("softwareupdate", "--list").and_return(softwareupdate_pre_catalina)
75
+ expect(provider.xcode_cli_package_label).to eql("Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0")
76
+ end
77
+
78
+ it "returns a package name on macOS 10.15+" do
79
+ allow(provider).to receive(:shell_out).with("softwareupdate", "--list").and_return(softwareupdate_catalina_and_later)
80
+ expect(provider.xcode_cli_package_label).to eql("Command Line Tools for Xcode-11.0")
81
+ end
82
+
83
+ it "returns nil if no update is listed" do
84
+ allow(provider).to receive(:shell_out).with("softwareupdate", "--list").and_return(softwareupdate_catalina_and_later_no_cli)
85
+ expect(provider.xcode_cli_package_label).to be_nil
86
+ end
87
+
88
+ end
43
89
  end
@@ -0,0 +1,92 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <array>
5
+ <dict>
6
+ <key>contentType</key>
7
+ <string>config-data</string>
8
+ <key>date</key>
9
+ <date>2019-10-07T20:09:37Z</date>
10
+ <key>displayName</key>
11
+ <string>XProtectPlistConfigData</string>
12
+ <key>displayVersion</key>
13
+ <string>2106</string>
14
+ <key>packageIdentifiers</key>
15
+ <array>
16
+ <string>com.apple.pkg.XProtectPlistConfigData_10_15.16U4081</string>
17
+ </array>
18
+ <key>processName</key>
19
+ <string>softwareupdated</string>
20
+ </dict>
21
+ <dict>
22
+ <key>contentType</key>
23
+ <string>config-data</string>
24
+ <key>date</key>
25
+ <date>2019-10-07T20:09:37Z</date>
26
+ <key>displayName</key>
27
+ <string>Gatekeeper Configuration Data</string>
28
+ <key>displayVersion</key>
29
+ <string>181</string>
30
+ <key>packageIdentifiers</key>
31
+ <array>
32
+ <string>com.apple.pkg.GatekeeperConfigData.16U1873</string>
33
+ </array>
34
+ <key>processName</key>
35
+ <string>softwareupdated</string>
36
+ </dict>
37
+ <dict>
38
+ <key>contentType</key>
39
+ <string>config-data</string>
40
+ <key>date</key>
41
+ <date>2019-10-07T20:09:37Z</date>
42
+ <key>displayName</key>
43
+ <string>MRTConfigData</string>
44
+ <key>displayVersion</key>
45
+ <string>1.50</string>
46
+ <key>packageIdentifiers</key>
47
+ <array>
48
+ <string>com.apple.pkg.MRTConfigData_10_15.16U4082</string>
49
+ </array>
50
+ <key>processName</key>
51
+ <string>softwareupdated</string>
52
+ </dict>
53
+ <dict>
54
+ <key>date</key>
55
+ <date>2019-10-09T02:37:33Z</date>
56
+ <key>displayName</key>
57
+ <string>Chef Infra Client</string>
58
+ <key>displayVersion</key>
59
+ <string></string>
60
+ <key>packageIdentifiers</key>
61
+ <array>
62
+ <string>com.getchef.pkg.chef</string>
63
+ </array>
64
+ <key>processName</key>
65
+ <string>installer</string>
66
+ </dict>
67
+ <dict>
68
+ <key>date</key>
69
+ <date>2019-10-09T02:47:02Z</date>
70
+ <key>displayName</key>
71
+ <string>Command Line Tools for Xcode</string>
72
+ <key>displayVersion</key>
73
+ <string>11.0</string>
74
+ <key>packageIdentifiers</key>
75
+ <array>
76
+ <string>com.apple.pkg.CLTools_Executables</string>
77
+ <string>com.apple.pkg.CLTools_SDK_macOS1015</string>
78
+ <string>com.apple.pkg.CLTools_SDK_macOS1014</string>
79
+ <string>com.apple.pkg.CLTools_macOS_SDK</string>
80
+ <string>com.apple.pkg.DevSDK</string>
81
+ <string>com.apple.pkg.DevSDK_OSX109</string>
82
+ <string>com.apple.pkg.DevSDK_OSX1010</string>
83
+ <string>com.apple.pkg.DevSDK_OSX1011</string>
84
+ <string>com.apple.pkg.DevSDK_OSX1012</string>
85
+ <string>com.apple.pkg.DevSDK_macOS1013_Public</string>
86
+ <string>com.apple.pkg.macOS_SDK_headers_for_macOS_10.14</string>
87
+ </array>
88
+ <key>processName</key>
89
+ <string>softwareupdated</string>
90
+ </dict>
91
+ </array>
92
+ </plist>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <array>
5
+ <dict>
6
+ <key>contentType</key>
7
+ <string>config-data</string>
8
+ <key>date</key>
9
+ <date>2019-09-30T20:36:29Z</date>
10
+ <key>displayName</key>
11
+ <string>Gatekeeper Configuration Data</string>
12
+ <key>displayVersion</key>
13
+ <string>181</string>
14
+ <key>packageIdentifiers</key>
15
+ <array>
16
+ <string>com.apple.pkg.GatekeeperConfigData.16U1873</string>
17
+ </array>
18
+ <key>processName</key>
19
+ <string>softwareupdated</string>
20
+ </dict>
21
+ <dict>
22
+ <key>contentType</key>
23
+ <string>config-data</string>
24
+ <key>date</key>
25
+ <date>2019-09-30T20:36:29Z</date>
26
+ <key>displayName</key>
27
+ <string>MRTConfigData</string>
28
+ <key>displayVersion</key>
29
+ <string>1.49</string>
30
+ <key>packageIdentifiers</key>
31
+ <array>
32
+ <string>com.apple.pkg.MRTConfigData_10_15.16U4080</string>
33
+ </array>
34
+ <key>processName</key>
35
+ <string>softwareupdated</string>
36
+ </dict>
37
+ </array>
38
+ </plist>