chef 12.17.44 → 12.18.31

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 +0 -1
  3. data/README.md +3 -2
  4. data/Rakefile +9 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +17 -17
  7. data/distro/common/html/knife_environment.html +4 -8
  8. data/distro/common/man/man1/knife-environment.1 +4 -16
  9. data/distro/powershell/chef/chef.psm1 +139 -24
  10. data/lib/chef/application.rb +5 -4
  11. data/lib/chef/application/windows_service_manager.rb +6 -4
  12. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  13. data/lib/chef/chef_fs/command_line.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
  17. data/lib/chef/cookbook/chefignore.rb +1 -1
  18. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  19. data/lib/chef/cookbook/metadata.rb +2 -2
  20. data/lib/chef/cookbook_loader.rb +1 -1
  21. data/lib/chef/data_collector.rb +24 -13
  22. data/lib/chef/data_collector/messages.rb +8 -6
  23. data/lib/chef/data_collector/messages/helpers.rb +1 -1
  24. data/lib/chef/deprecated.rb +30 -0
  25. data/lib/chef/dsl/platform_introspection.rb +2 -2
  26. data/lib/chef/encrypted_data_bag_item.rb +1 -1
  27. data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
  28. data/lib/chef/environment.rb +1 -1
  29. data/lib/chef/exceptions.rb +5 -5
  30. data/lib/chef/file_access_control/unix.rb +5 -5
  31. data/lib/chef/formatters/error_description.rb +1 -1
  32. data/lib/chef/http/basic_client.rb +1 -1
  33. data/lib/chef/http/json_input.rb +2 -2
  34. data/lib/chef/knife.rb +1 -1
  35. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  36. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  37. data/lib/chef/knife/core/ui.rb +1 -1
  38. data/lib/chef/mixin/command.rb +1 -0
  39. data/lib/chef/mixin/deep_merge.rb +1 -1
  40. data/lib/chef/mixin/shell_out.rb +58 -3
  41. data/lib/chef/mixin/which.rb +5 -9
  42. data/lib/chef/mixin/wide_string.rb +1 -1
  43. data/lib/chef/node.rb +1 -1
  44. data/lib/chef/node/attribute.rb +4 -5
  45. data/lib/chef/node_map.rb +18 -2
  46. data/lib/chef/platform/provider_handler_map.rb +2 -2
  47. data/lib/chef/platform/provider_mapping.rb +5 -0
  48. data/lib/chef/platform/resource_handler_map.rb +2 -2
  49. data/lib/chef/provider/env/windows.rb +1 -1
  50. data/lib/chef/provider/git.rb +1 -1
  51. data/lib/chef/provider/group.rb +41 -46
  52. data/lib/chef/provider/group/aix.rb +12 -19
  53. data/lib/chef/provider/group/dscl.rb +46 -43
  54. data/lib/chef/provider/group/gpasswd.rb +7 -7
  55. data/lib/chef/provider/group/groupadd.rb +29 -34
  56. data/lib/chef/provider/group/groupmod.rb +26 -31
  57. data/lib/chef/provider/group/pw.rb +28 -31
  58. data/lib/chef/provider/group/suse.rb +9 -9
  59. data/lib/chef/provider/group/usermod.rb +10 -11
  60. data/lib/chef/provider/group/windows.rb +18 -20
  61. data/lib/chef/provider/ifconfig.rb +52 -63
  62. data/lib/chef/provider/ifconfig/aix.rb +23 -28
  63. data/lib/chef/provider/ifconfig/debian.rb +23 -22
  64. data/lib/chef/provider/ifconfig/redhat.rb +12 -12
  65. data/lib/chef/provider/mount/mount.rb +1 -1
  66. data/lib/chef/provider/osx_profile.rb +4 -2
  67. data/lib/chef/provider/package.rb +16 -7
  68. data/lib/chef/provider/package/chocolatey.rb +3 -1
  69. data/lib/chef/provider/package/dnf.rb +183 -0
  70. data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
  71. data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
  72. data/lib/chef/provider/package/dnf/version.rb +56 -0
  73. data/lib/chef/provider/package/easy_install.rb +1 -1
  74. data/lib/chef/provider/package/freebsd/base.rb +1 -1
  75. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  76. data/lib/chef/provider/package/powershell.rb +3 -3
  77. data/lib/chef/provider/package/windows.rb +1 -1
  78. data/lib/chef/provider/package/zypper.rb +1 -1
  79. data/lib/chef/provider/route.rb +186 -184
  80. data/lib/chef/provider/service/arch.rb +2 -2
  81. data/lib/chef/provider/service/freebsd.rb +1 -1
  82. data/lib/chef/provider/service/gentoo.rb +2 -2
  83. data/lib/chef/provider/service/insserv.rb +2 -2
  84. data/lib/chef/provider/service/macosx.rb +2 -2
  85. data/lib/chef/provider/service/openbsd.rb +1 -1
  86. data/lib/chef/provider/service/redhat.rb +2 -2
  87. data/lib/chef/provider/support/yum_repo.erb +10 -3
  88. data/lib/chef/provider/user.rb +17 -20
  89. data/lib/chef/provider/user/aix.rb +23 -24
  90. data/lib/chef/provider/user/dscl.rb +56 -53
  91. data/lib/chef/provider/user/linux.rb +13 -16
  92. data/lib/chef/provider/user/pw.rb +26 -30
  93. data/lib/chef/provider/user/solaris.rb +11 -12
  94. data/lib/chef/provider/user/useradd.rb +20 -22
  95. data/lib/chef/provider/user/windows.rb +19 -22
  96. data/lib/chef/provider_resolver.rb +4 -2
  97. data/lib/chef/providers.rb +1 -0
  98. data/lib/chef/resource.rb +7 -0
  99. data/lib/chef/resource/chocolatey_package.rb +1 -0
  100. data/lib/chef/resource/dnf_package.rb +64 -0
  101. data/lib/chef/resource/file/verification.rb +6 -4
  102. data/lib/chef/resource/yum_package.rb +18 -14
  103. data/lib/chef/resource/yum_repository.rb +1 -1
  104. data/lib/chef/resource_reporter.rb +11 -0
  105. data/lib/chef/resources.rb +1 -0
  106. data/lib/chef/scan_access_control.rb +4 -4
  107. data/lib/chef/util/dsc/resource_store.rb +1 -1
  108. data/lib/chef/version.rb +1 -1
  109. data/lib/chef/win32/memory.rb +1 -1
  110. data/lib/chef/win32/security.rb +2 -2
  111. data/lib/chef/win32/security/sid.rb +2 -2
  112. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
  113. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
  114. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
  115. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
  116. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
  117. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
  118. data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
  119. data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
  120. data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
  121. data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
  122. data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
  123. data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
  124. data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
  125. data/spec/functional/resource/dnf_package_spec.rb +686 -0
  126. data/spec/functional/resource/dsc_script_spec.rb +1 -0
  127. data/spec/functional/resource/user/useradd_spec.rb +10 -1
  128. data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
  129. data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
  130. data/spec/integration/recipes/resource_load_spec.rb +3 -3
  131. data/spec/spec_helper.rb +5 -3
  132. data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
  133. data/spec/support/lib/chef/resource/cat.rb +1 -0
  134. data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
  135. data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
  136. data/spec/support/lib/chef/resource/with_state.rb +2 -0
  137. data/spec/support/lib/chef/resource/zen_master.rb +1 -0
  138. data/spec/unit/cookbook/metadata_spec.rb +3 -3
  139. data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
  140. data/spec/unit/data_collector_spec.rb +56 -0
  141. data/spec/unit/decorator/lazy_spec.rb +1 -1
  142. data/spec/unit/environment_spec.rb +1 -1
  143. data/spec/unit/lwrp_spec.rb +3 -4
  144. data/spec/unit/node_spec.rb +23 -2
  145. data/spec/unit/platform_spec.rb +1 -0
  146. data/spec/unit/provider/group/dscl_spec.rb +29 -29
  147. data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
  148. data/spec/unit/provider/group/groupadd_spec.rb +31 -30
  149. data/spec/unit/provider/group/groupmod_spec.rb +16 -16
  150. data/spec/unit/provider/group/pw_spec.rb +11 -11
  151. data/spec/unit/provider/group/suse_spec.rb +5 -5
  152. data/spec/unit/provider/group/usermod_spec.rb +15 -15
  153. data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
  154. data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
  155. data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
  156. data/spec/unit/provider/ifconfig_spec.rb +18 -19
  157. data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
  158. data/spec/unit/provider/package/msu_spec.rb +1 -1
  159. data/spec/unit/provider/route_spec.rb +21 -21
  160. data/spec/unit/provider/user/dscl_spec.rb +54 -57
  161. data/spec/unit/provider/user/linux_spec.rb +5 -5
  162. data/spec/unit/provider/user/pw_spec.rb +26 -22
  163. data/spec/unit/provider/user/windows_spec.rb +4 -4
  164. data/spec/unit/provider/user_spec.rb +19 -21
  165. data/spec/unit/provider_resolver_spec.rb +1 -0
  166. data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
  167. data/spec/unit/resource/dnf_package_spec.rb +99 -0
  168. data/spec/unit/resource/remote_file_spec.rb +2 -2
  169. data/spec/unit/resource/yum_package_spec.rb +20 -0
  170. data/spec/unit/resource_reporter_spec.rb +24 -0
  171. data/spec/unit/resource_spec.rb +2 -0
  172. data/spec/unit/runner_spec.rb +1 -0
  173. data/tasks/bin/bundle-platform +1 -1
  174. data/tasks/gemfile_util.rb +2 -2
  175. data/tasks/templates/prerelease.md.erb +1 -10
  176. data/tasks/templates/release.md.erb +1 -9
  177. metadata +24 -5
  178. data/lib/chef/platform/handler_map.rb +0 -40
@@ -76,6 +76,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
76
76
  let(:env_value2) { "value2" }
77
77
  let(:dsc_test_run_context) do
78
78
  node = Chef::Node.new
79
+ node.automatic["os"] = "windows"
79
80
  node.automatic["platform"] = "windows"
80
81
  node.automatic["platform_version"] = "6.1"
81
82
  node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
@@ -119,7 +119,7 @@ describe Chef::Provider::User::Useradd, metadata do
119
119
  break if status.exitstatus != 8
120
120
 
121
121
  sleep 1
122
- max_retries = max_retries - 1
122
+ max_retries -= 1
123
123
  rescue UserNotFound
124
124
  break
125
125
  end
@@ -645,6 +645,15 @@ describe Chef::Provider::User::Useradd, metadata do
645
645
  expect(@error).to be_a(Mixlib::ShellOut::ShellCommandFailed)
646
646
  expect(@error.message).to include("Cannot unlock the password")
647
647
  end
648
+ elsif %w{rhel}.include?(OHAI_SYSTEM["platform_family"]) &&
649
+ OHAI_SYSTEM["platform_version"].to_f == 6.8
650
+ # usermod -U returns following message for rhel68 on s390x platforms
651
+ # usermod: unlocking the user's password would result in a passwordless account.
652
+ #You should set a password with usermod -p to unlock this user's password.
653
+ it "errors out trying to unlock the user" do
654
+ expect(@error).to be_a(Mixlib::ShellOut::ShellCommandFailed)
655
+ expect(@error.message).to include("You should set a password")
656
+ end
648
657
  else
649
658
 
650
659
  # borked on all other platforms:
@@ -843,7 +843,7 @@ EOM
843
843
 
844
844
  context "when data_bag_path and chef_repo_path are set, and nothing else" do
845
845
  before :each do
846
- %w{client cookbook environment node role user}.each do |object_name|
846
+ %w{client cookbook environment node role user}.each do |object_name|
847
847
  Chef::Config.delete("#{object_name}_path".to_sym)
848
848
  end
849
849
  Chef::Config.data_bag_path = File.join(Chef::Config.chef_repo_path, "data_bags")
@@ -903,7 +903,7 @@ EOM
903
903
  include_context "default config options"
904
904
 
905
905
  before :each do
906
- %w{client cookbook environment node role user}.each do |object_name|
906
+ %w{client cookbook environment node role user}.each do |object_name|
907
907
  Chef::Config.delete("#{object_name}_path".to_sym)
908
908
  end
909
909
  Chef::Config.delete(:chef_repo_path)
@@ -1425,6 +1425,7 @@ describe "Recipe DSL methods" do
1425
1425
  end
1426
1426
 
1427
1427
  it "my_resource fails to find a provider (and calls provides)" do
1428
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
1428
1429
  my_resource = self.my_resource
1429
1430
  expect_converge do
1430
1431
  instance_eval("#{my_resource} 'foo'")
@@ -1435,6 +1436,7 @@ describe "Recipe DSL methods" do
1435
1436
 
1436
1437
  context "that does not provide :my_resource" do
1437
1438
  it "my_resource fails to find a provider (and calls provides)" do
1439
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
1438
1440
  my_resource = self.my_resource
1439
1441
  expect_converge do
1440
1442
  instance_eval("#{my_resource} 'foo'")
@@ -1510,6 +1512,7 @@ describe "Recipe DSL methods" do
1510
1512
  end
1511
1513
 
1512
1514
  it "looks up the provider in Chef::Provider converting the resource name from snake case to camel case" do
1515
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
1513
1516
  resource = nil
1514
1517
  recipe = converge do
1515
1518
  resource = lw_resource_with_hw_provider_test_case("blah") {}
@@ -48,7 +48,7 @@ describe "Resource.load_current_value" do
48
48
  x "loaded #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
49
49
  select { |name, p| p.is_set?(self) }.
50
50
  map { |name, p| "#{name}=#{p.get(self)}" }.
51
- join(", ") })"
51
+ join(", ")})"
52
52
  end
53
53
  end
54
54
 
@@ -175,7 +175,7 @@ describe "Resource.load_current_value" do
175
175
  y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
176
176
  select { |name, p| p.is_set?(self) }.
177
177
  map { |name, p| "#{name}=#{p.get(self)}" }.
178
- join(", ") })"
178
+ join(", ")})"
179
179
  end
180
180
  end
181
181
 
@@ -193,7 +193,7 @@ describe "Resource.load_current_value" do
193
193
  y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
194
194
  select { |name, p| p.is_set?(self) }.
195
195
  map { |name, p| "#{name}=#{p.get(self)}" }.
196
- join(", ") })"
196
+ join(", ")})"
197
197
  end
198
198
  end
199
199
 
@@ -218,9 +218,11 @@ RSpec.configure do |config|
218
218
  end
219
219
 
220
220
  # raise if anyone commits any test to CI with :focus set on it
221
- config.before(:example, :focus) do
222
- raise "This example was committed with `:focus` and should not have been"
223
- end if ENV["CI"]
221
+ if ENV["CI"]
222
+ config.before(:example, :focus) do
223
+ raise "This example was committed with `:focus` and should not have been"
224
+ end
225
+ end
224
226
 
225
227
  config.before(:suite) do
226
228
  ARGV.clear
@@ -19,6 +19,7 @@
19
19
  class Chef
20
20
  class Provider
21
21
  class SnakeOil < Chef::Provider
22
+ provides :cat
22
23
 
23
24
  def load_current_resource
24
25
  true
@@ -19,6 +19,7 @@
19
19
  class Chef
20
20
  class Resource
21
21
  class Cat < Chef::Resource
22
+ provides :cat
22
23
 
23
24
  attr_accessor :action
24
25
 
@@ -19,6 +19,7 @@
19
19
  class Chef
20
20
  class Resource
21
21
  class OneTwoThreeFour < Chef::Resource
22
+ provides :one_two_three_four
22
23
 
23
24
  attr_reader :i_can_count
24
25
 
@@ -19,6 +19,8 @@
19
19
  class Chef
20
20
  class Resource
21
21
  class OpenldapIncluder < Chef::Resource::LWRPBase
22
+ provides :openldap_includer
23
+
22
24
  allowed_actions :run
23
25
  default_action :run
24
26
  end
@@ -22,6 +22,8 @@ require "chef/json_compat"
22
22
  class Chef
23
23
  class Resource
24
24
  class WithState < Chef::Resource
25
+ provides :with_state
26
+
25
27
  attr_accessor :state
26
28
  end
27
29
  end
@@ -22,6 +22,7 @@ require "chef/json_compat"
22
22
  class Chef
23
23
  class Resource
24
24
  class ZenMaster < Chef::Resource
25
+ provides :zen_master
25
26
  allowed_actions :win, :score
26
27
 
27
28
  attr_reader :peace
@@ -206,7 +206,7 @@ describe Chef::Cookbook::Metadata do
206
206
  :issues_url => "http://example.com/issues",
207
207
  :privacy => true,
208
208
  }
209
- params.sort { |a, b| a.to_s <=> b.to_s }.each do |field, field_value|
209
+ params.sort_by(&:to_s).each do |field, field_value|
210
210
  describe field do
211
211
  it "should be set-able via #{field}" do
212
212
  expect(metadata.send(field, field_value)).to eql(field_value)
@@ -240,7 +240,7 @@ describe Chef::Cookbook::Metadata do
240
240
  :provides => [ :providing, "foo::bar", "<= 0.2" ],
241
241
  :replaces => [ :replacing, "foo::bar", "= 0.2.1" ],
242
242
  }
243
- dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
243
+ dep_types.sort_by(&:to_s).each do |dep, dep_args|
244
244
  check_with = dep_args.shift
245
245
  describe dep do
246
246
  it "should be set-able via #{dep}" do
@@ -261,7 +261,7 @@ describe Chef::Cookbook::Metadata do
261
261
  :provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
262
262
  :replaces => [ :replacing, "foo::bar", "=0.2.1", "= 0.2.1" ],
263
263
  }
264
- dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
264
+ dep_types.sort_by(&:to_s).each do |dep, dep_args|
265
265
  check_with = dep_args.shift
266
266
  normalized_version = dep_args.pop
267
267
  describe dep do
@@ -72,6 +72,13 @@ describe Chef::DataCollector::Messages::Helpers do
72
72
  expect(TestMessage.chef_server_organization).to eq("unknown_organization")
73
73
  end
74
74
  end
75
+
76
+ context "when the organization in the URL contains hyphens" do
77
+ it "returns the full org name" do
78
+ Chef::Config[:chef_server_url] = "http://mycompany.com/organizations/myorg-test"
79
+ expect(TestMessage.chef_server_organization).to eq("myorg-test")
80
+ end
81
+ end
75
82
  end
76
83
 
77
84
  describe "#collector_source" do
@@ -682,4 +682,60 @@ describe Chef::DataCollector::Reporter do
682
682
  end
683
683
  end
684
684
  end
685
+
686
+ describe "#detect_unprocessed_resources" do
687
+ context "when resources do not override core methods" do
688
+ it "adds resource reports for any resources that have not yet been processed" do
689
+ resource_a = Chef::Resource::Service.new("processed service")
690
+ resource_b = Chef::Resource::Service.new("unprocessed service")
691
+
692
+ resource_a.action = [ :enable, :start ]
693
+ resource_b.action = :start
694
+
695
+ run_context = Chef::RunContext.new(Chef::Node.new, Chef::CookbookCollection.new, nil)
696
+ run_context.resource_collection.insert(resource_a)
697
+ run_context.resource_collection.insert(resource_b)
698
+
699
+ allow(reporter).to receive(:run_context).and_return(run_context)
700
+
701
+ # process the actions for resource_a, but not resource_b
702
+ reporter.resource_up_to_date(resource_a, :enable)
703
+ reporter.resource_completed(resource_a)
704
+ reporter.resource_up_to_date(resource_a, :start)
705
+ reporter.resource_completed(resource_a)
706
+ expect(reporter.all_resource_reports.size).to eq(2)
707
+
708
+ # detect unprocessed resources, which should find that resource_b has not yet been processed
709
+ reporter.send(:detect_unprocessed_resources)
710
+ expect(reporter.all_resource_reports.size).to eq(3)
711
+ end
712
+ end
713
+
714
+ context "when a resource overrides a core method, such as #hash" do
715
+ it "does not raise an exception" do
716
+ resource_a = Chef::Resource::Service.new("processed service")
717
+ resource_b = Chef::Resource::Service.new("unprocessed service")
718
+
719
+ resource_a.action = :start
720
+ resource_b.action = :start
721
+
722
+ run_context = Chef::RunContext.new(Chef::Node.new, Chef::CookbookCollection.new, nil)
723
+ run_context.resource_collection.insert(resource_a)
724
+ run_context.resource_collection.insert(resource_b)
725
+
726
+ allow(reporter).to receive(:run_context).and_return(run_context)
727
+
728
+ # override the #hash method on resource_a to return a String instead of
729
+ # a Fixnum. Without the fix in chef/chef#5604, this would raise an
730
+ # exception when getting added to the Set/Hash.
731
+ resource_a.define_singleton_method(:hash) { "a string" }
732
+
733
+ # process the actions for resource_a, but not resource_b
734
+ reporter.resource_up_to_date(resource_a, :start)
735
+ reporter.resource_completed(resource_a)
736
+
737
+ expect { reporter.send(:detect_unprocessed_resources) }.not_to raise_error
738
+ end
739
+ end
740
+ end
685
741
  end
@@ -21,7 +21,7 @@ require "spec_helper"
21
21
  describe Chef::Decorator::Lazy do
22
22
  let(:decorator) do
23
23
  @a = 0
24
- Chef::Decorator::Lazy.new { @a = @a + 1 }
24
+ Chef::Decorator::Lazy.new { @a += 1 }
25
25
  end
26
26
 
27
27
  it "decorates an object" do
@@ -295,7 +295,7 @@ describe Chef::Environment do
295
295
  Chef::Config[:solo_legacy_mode] = false
296
296
  end
297
297
 
298
- it "should raise and exception" do
298
+ it "should raise an exception" do
299
299
  expect do
300
300
  Chef::Environment.validate_cookbook_version("= 1.2.3.4")
301
301
  end.to raise_error Chef::Exceptions::IllegalVersionConstraint,
@@ -413,8 +413,7 @@ describe "LWRP" do
413
413
  resource = get_lwrp(:lwrp_foo).new("morpheus", run_context)
414
414
  resource.monkey("bob")
415
415
  resource.provider(get_lwrp_provider(:lwrp_monkey_name_printer))
416
-
417
- provider = Chef::Platform.provider_for_resource(resource, :twiddle_thumbs)
416
+ provider = resource.provider_for_action(:twiddle_thumbs)
418
417
  provider.action_twiddle_thumbs
419
418
  end
420
419
 
@@ -520,7 +519,7 @@ describe "LWRP" do
520
519
  resource.monkey("bob")
521
520
  resource.provider(get_lwrp_provider(:lwrp_monkey_name_printer))
522
521
 
523
- provider = Chef::Platform.provider_for_resource(resource, :twiddle_thumbs)
522
+ provider = resource.provider_for_action(:twiddle_thumbs)
524
523
  provider.action_twiddle_thumbs
525
524
 
526
525
  expect(provider.monkey_name).to eq("my monkey's name is 'bob'")
@@ -531,7 +530,7 @@ describe "LWRP" do
531
530
  resource.monkey("bob")
532
531
  resource.provider(get_lwrp_provider(:lwrp_embedded_resource_accesses_providers_scope))
533
532
 
534
- provider = Chef::Platform.provider_for_resource(resource, :twiddle_thumbs)
533
+ provider = resource.provider_for_action(:twiddle_thumbs)
535
534
  #provider = @runner.build_provider(resource)
536
535
  provider.action_twiddle_thumbs
537
536
 
@@ -337,14 +337,35 @@ describe Chef::Node do
337
337
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
338
338
  expect(Chef).to receive(:deprecated).with(:attributes, /set is deprecated/)
339
339
  node.set[:snoopy][:is_a_puppy] = true
340
- expect(node[:snoopy][:is_a_puppy]).to eq(true)
340
+ expect(node.normal[:snoopy][:is_a_puppy]).to eq(true)
341
341
  end
342
342
 
343
343
  it "set_unless is a deprecated alias for normal_unless" do
344
344
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
345
345
  expect(Chef).to receive(:deprecated).with(:attributes, /set_unless is deprecated/)
346
346
  node.set_unless[:snoopy][:is_a_puppy] = false
347
- expect(node[:snoopy][:is_a_puppy]).to eq(false)
347
+ expect(node.normal[:snoopy][:is_a_puppy]).to eq(false)
348
+ end
349
+
350
+ it "normal_unless sets a value even if default or override attrs are set" do
351
+ node.default[:decontamination] = true
352
+ node.override[:decontamination] = false
353
+ node.normal_unless[:decontamination] = "foo"
354
+ expect(node.normal[:decontamination]).to eql("foo")
355
+ end
356
+
357
+ it "default_unless sets a value even if normal or override attrs are set" do
358
+ node.normal[:decontamination] = true
359
+ node.override[:decontamination] = false
360
+ node.default_unless[:decontamination] = "foo"
361
+ expect(node.default[:decontamination]).to eql("foo")
362
+ end
363
+
364
+ it "override_unless sets a value even if default or normal attrs are set" do
365
+ node.default[:decontamination] = true
366
+ node.normal[:decontamination] = false
367
+ node.override_unless[:decontamination] = "foo"
368
+ expect(node.override[:decontamination]).to eql("foo")
348
369
  end
349
370
  end
350
371
 
@@ -31,6 +31,7 @@ describe Chef::Platform do
31
31
  end
32
32
 
33
33
  before(:each) do
34
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
34
35
  Chef::Platform.platforms = {
35
36
  :darwin => {
36
37
  ">= 10.11" => {
@@ -28,12 +28,12 @@ describe Chef::Provider::Group::Dscl do
28
28
  @provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context)
29
29
  @provider.current_resource = @current_resource
30
30
 
31
- @status = double(:stdout => "\n", :stderr => "", :exitstatus => 0)
31
+ @status = double(stdout: "\n", stderr: "", exitstatus: 0)
32
32
  allow(@provider).to receive(:shell_out).and_return(@status)
33
33
  end
34
34
 
35
35
  it "should run shell_out with the supplied array of arguments appended to the dscl command" do
36
- expect(@provider).to receive(:shell_out).with("dscl . -cmd /Path arg1 arg2")
36
+ expect(@provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "arg1", "arg2")
37
37
  @provider.dscl("cmd", "/Path", "arg1", "arg2")
38
38
  end
39
39
 
@@ -51,24 +51,24 @@ describe Chef::Provider::Group::Dscl do
51
51
  end
52
52
 
53
53
  it "should run dscl with the supplied cmd /Path args" do
54
- expect(@provider).to receive(:dscl).with("cmd /Path args")
55
- @provider.safe_dscl("cmd /Path args")
54
+ expect(@provider).to receive(:dscl).with(*"cmd /Path args".split(" "))
55
+ @provider.safe_dscl(*"cmd /Path args".split(" "))
56
56
  end
57
57
 
58
58
  describe "with the dscl command returning a non zero exit status for a delete" do
59
59
  before do
60
- @status = double("Process::Status", :exitstatus => 1)
60
+ @status = double("Process::Status", exitstatus: 1)
61
61
  allow(@provider).to receive(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
62
62
  end
63
63
 
64
64
  it "should return an empty string of standard output for a delete" do
65
- safe_dscl_retval = @provider.safe_dscl("delete /Path args")
65
+ safe_dscl_retval = @provider.safe_dscl(*"delete /Path args".split(" "))
66
66
  expect(safe_dscl_retval).to be_a_kind_of(String)
67
67
  expect(safe_dscl_retval).to eq("")
68
68
  end
69
69
 
70
70
  it "should raise an exception for any other command" do
71
- expect { @provider.safe_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::Group)
71
+ expect { @provider.safe_dscl(*"cmd /Path arguments".split(" ")) }.to raise_error(Chef::Exceptions::Group)
72
72
  end
73
73
  end
74
74
 
@@ -78,13 +78,13 @@ describe Chef::Provider::Group::Dscl do
78
78
  end
79
79
 
80
80
  it "should raise an exception" do
81
- expect { @provider.safe_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::Group)
81
+ expect { @provider.safe_dscl(*"cmd /Path arguments".split(" ")) }.to raise_error(Chef::Exceptions::Group)
82
82
  end
83
83
  end
84
84
 
85
85
  describe "with the dscl command returning a zero exit status" do
86
86
  it "should return the third array element, the string of standard output" do
87
- safe_dscl_retval = @provider.safe_dscl("cmd /Path args")
87
+ safe_dscl_retval = @provider.safe_dscl(*"cmd /Path args".split(" "))
88
88
  expect(safe_dscl_retval).to be_a_kind_of(String)
89
89
  expect(safe_dscl_retval).to eq("stdout")
90
90
  end
@@ -99,7 +99,7 @@ describe Chef::Provider::Group::Dscl do
99
99
  end
100
100
 
101
101
  it "should run safe_dscl with list /Groups gid" do
102
- expect(@provider).to receive(:safe_dscl).with("list /Groups gid")
102
+ expect(@provider).to receive(:safe_dscl).with(*"list /Groups gid".split(" "))
103
103
  @provider.get_free_gid
104
104
  end
105
105
 
@@ -121,7 +121,7 @@ describe Chef::Provider::Group::Dscl do
121
121
  end
122
122
 
123
123
  it "should run safe_dscl with list /Groups gid" do
124
- expect(@provider).to receive(:safe_dscl).with("list /Groups gid")
124
+ expect(@provider).to receive(:safe_dscl).with(*"list /Groups gid".split(" "))
125
125
  @provider.gid_used?(500)
126
126
  end
127
127
 
@@ -171,8 +171,8 @@ describe Chef::Provider::Group::Dscl do
171
171
  describe "with a valid gid number which is not already in use" do
172
172
  it "should run safe_dscl with create /Groups/group PrimaryGroupID gid" do
173
173
  allow(@provider).to receive(:get_free_gid).and_return(50)
174
- expect(@provider).to receive(:safe_dscl).with("list /Groups gid")
175
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj PrimaryGroupID 50").and_return(true)
174
+ expect(@provider).to receive(:safe_dscl).with(*"list /Groups gid".split(" "))
175
+ expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "PrimaryGroupID", 50).and_return(true)
176
176
  @provider.set_gid
177
177
  end
178
178
  end
@@ -193,8 +193,8 @@ describe Chef::Provider::Group::Dscl do
193
193
  end
194
194
 
195
195
  it "should run safe_dscl with create /Groups/group GroupMembership to clear the Group's UID list" do
196
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj GroupMembers ''").and_return(true)
197
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj GroupMembership ''").and_return(true)
196
+ expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "GroupMembers", "").and_return(true)
197
+ expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "GroupMembership", "").and_return(true)
198
198
  @provider.set_members
199
199
  end
200
200
  end
@@ -211,9 +211,9 @@ describe Chef::Provider::Group::Dscl do
211
211
  end
212
212
 
213
213
  it "should run safe_dscl with append /Groups/group GroupMembership and group members all, your, base" do
214
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj GroupMembers ''").and_return(true)
215
- expect(@provider).to receive(:safe_dscl).with("append /Groups/aj GroupMembership all your base").and_return(true)
216
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj GroupMembership ''").and_return(true)
214
+ expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "GroupMembers", "").and_return(true)
215
+ expect(@provider).to receive(:safe_dscl).with(*"append /Groups/aj GroupMembership all your base".split(" ")).and_return(true)
216
+ expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "GroupMembership", "").and_return(true)
217
217
  @provider.set_members
218
218
  end
219
219
  end
@@ -232,20 +232,20 @@ describe Chef::Provider::Group::Dscl do
232
232
  end
233
233
 
234
234
  describe "when loading the current system state" do
235
- before (:each) do
235
+ before(:each) do
236
236
  @provider.action = :create
237
237
  @provider.load_current_resource
238
238
  @provider.define_resource_requirements
239
239
  end
240
240
 
241
241
  it "raises an error if the required binary /usr/bin/dscl doesn't exist" do
242
- expect(File).to receive(:exists?).with("/usr/bin/dscl").and_return(false)
242
+ expect(File).to receive(:exist?).with("/usr/bin/dscl").and_return(false)
243
243
 
244
244
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
245
245
  end
246
246
 
247
247
  it "doesn't raise an error if /usr/bin/dscl exists" do
248
- allow(File).to receive(:exists?).and_return(true)
248
+ allow(File).to receive(:exist?).and_return(true)
249
249
  expect { @provider.process_resource_requirements }.not_to raise_error
250
250
  end
251
251
  end
@@ -254,8 +254,8 @@ describe Chef::Provider::Group::Dscl do
254
254
  it "creates the group, password field, gid, and sets group membership" do
255
255
  expect(@provider).to receive(:set_gid).and_return(true)
256
256
  expect(@provider).to receive(:set_members).and_return(true)
257
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj Password '*'")
258
- expect(@provider).to receive(:safe_dscl).with("create /Groups/aj")
257
+ expect(@provider).to receive(:safe_dscl).with(*"create /Groups/aj Password *".split(" "))
258
+ expect(@provider).to receive(:safe_dscl).with(*"create /Groups/aj".split(" "))
259
259
  @provider.create_group
260
260
  end
261
261
  end
@@ -265,8 +265,8 @@ describe Chef::Provider::Group::Dscl do
265
265
  @current_resource.group_name("oldval")
266
266
  @new_resource.group_name("newname")
267
267
  expect(@provider).to receive(:set_members).and_return(true)
268
- expect(@provider).to receive(:safe_dscl).with("create /Groups/newname")
269
- expect(@provider).to receive(:safe_dscl).with("create /Groups/newname Password '*'")
268
+ expect(@provider).to receive(:safe_dscl).with(*"create /Groups/newname".split(" "))
269
+ expect(@provider).to receive(:safe_dscl).with(*"create /Groups/newname Password *".split(" "))
270
270
  @provider.manage_group
271
271
  end
272
272
 
@@ -287,7 +287,7 @@ describe Chef::Provider::Group::Dscl do
287
287
 
288
288
  describe "remove_group" do
289
289
  it "should run safe_dscl with delete /Groups/group and with the new resources group name" do
290
- expect(@provider).to receive(:safe_dscl).with("delete /Groups/aj").and_return(true)
290
+ expect(@provider).to receive(:safe_dscl).with(*"delete /Groups/aj".split(" ")).and_return(true)
291
291
  @provider.remove_group
292
292
  end
293
293
  end
@@ -315,17 +315,17 @@ RecordName: com.apple.aj
315
315
  RecordType: dsRecTypeStandard:Groups
316
316
  GroupMembership: waka bar
317
317
  EOF
318
- allow(@provider).to receive(:safe_dscl).with("read /Groups/aj").and_return(@output)
318
+ allow(@provider).to receive(:safe_dscl).with(*"read /Groups/aj".split(" ")).and_return(@output)
319
319
  @current_resource = @provider.load_current_resource
320
320
 
321
321
  end
322
322
 
323
323
  it "should parse gid properly" do
324
- allow(File).to receive(:exists?).and_return(true)
324
+ allow(File).to receive(:exist?).and_return(true)
325
325
  expect(@current_resource.gid).to eq("999")
326
326
  end
327
327
  it "should parse members properly" do
328
- allow(File).to receive(:exists?).and_return(true)
328
+ allow(File).to receive(:exist?).and_return(true)
329
329
  expect(@current_resource.members).to eq(%w{waka bar})
330
330
  end
331
331
  end