chef 16.9.29-universal-mingw32 → 16.12.3-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/chef-universal-mingw32.gemspec +1 -1
  4. data/chef.gemspec +10 -1
  5. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
  6. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
  7. data/distro/ruby_bin_folder/AMD64/Newtonsoft.Json.dll +0 -0
  8. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  9. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  10. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  11. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
  12. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
  13. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
  14. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
  15. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
  16. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
  17. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
  18. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
  19. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
  20. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
  21. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
  22. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  23. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
  24. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
  25. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
  26. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
  27. data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
  28. data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
  29. data/distro/ruby_bin_folder/x86/Newtonsoft.Json.dll +0 -0
  30. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  31. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  32. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  33. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
  34. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
  35. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
  36. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
  37. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
  38. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
  39. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
  40. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
  41. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
  42. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
  43. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
  44. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  45. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
  46. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
  47. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
  48. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
  49. data/lib/chef/compliance/default_attributes.rb +6 -2
  50. data/lib/chef/compliance/fetcher/automate.rb +15 -4
  51. data/lib/chef/compliance/runner.rb +8 -3
  52. data/lib/chef/dsl/reboot_pending.rb +1 -1
  53. data/lib/chef/file_access_control/windows.rb +4 -4
  54. data/lib/chef/file_cache.rb +4 -4
  55. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
  56. data/lib/chef/handler/json_file.rb +1 -1
  57. data/lib/chef/knife/bootstrap.rb +54 -4
  58. data/lib/chef/provider/file.rb +1 -1
  59. data/lib/chef/provider/mount.rb +7 -2
  60. data/lib/chef/provider/mount/mount.rb +1 -1
  61. data/lib/chef/provider/package.rb +2 -2
  62. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -1
  63. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  64. data/lib/chef/provider/service/macosx.rb +3 -3
  65. data/lib/chef/resource.rb +27 -3
  66. data/lib/chef/resource/chef_client_cron.rb +1 -1
  67. data/lib/chef/resource/chef_client_launchd.rb +1 -1
  68. data/lib/chef/resource/windows_certificate.rb +47 -17
  69. data/lib/chef/resource_inspector.rb +5 -1
  70. data/lib/chef/shell.rb +2 -2
  71. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  72. data/lib/chef/version.rb +1 -1
  73. data/lib/chef/version_string.rb +1 -1
  74. data/spec/functional/resource/cron_spec.rb +1 -1
  75. data/spec/integration/compliance/compliance_spec.rb +2 -1
  76. data/spec/integration/recipes/resource_action_spec.rb +14 -0
  77. data/spec/spec_helper.rb +1 -0
  78. data/spec/support/platform_helpers.rb +4 -0
  79. data/spec/support/shared/unit/provider/file.rb +14 -0
  80. data/spec/unit/compliance/fetcher/automate_spec.rb +8 -0
  81. data/spec/unit/compliance/runner_spec.rb +54 -5
  82. data/spec/unit/dsl/reboot_pending_spec.rb +2 -2
  83. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
  84. data/spec/unit/knife/bootstrap_spec.rb +42 -3
  85. data/spec/unit/knife/supermarket_share_spec.rb +5 -6
  86. data/spec/unit/provider/mount/mount_spec.rb +52 -0
  87. data/spec/unit/provider/package/dnf/python_helper_spec.rb +7 -1
  88. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  89. data/spec/unit/resource/chef_client_cron_spec.rb +8 -8
  90. data/spec/unit/resource_inspector_spec.rb +7 -2
  91. data/spec/unit/resource_spec.rb +46 -0
  92. metadata +14 -12
@@ -57,12 +57,12 @@ describe Chef::DSL::RebootPending do
57
57
  end
58
58
 
59
59
  it "should return true if /var/run/reboot-required exists" do
60
- allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(true)
60
+ allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(true)
61
61
  expect(recipe.reboot_pending?).to be_truthy
62
62
  end
63
63
 
64
64
  it "should return false if /var/run/reboot-required does not exist" do
65
- allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false)
65
+ allow(File).to receive(:exist?).with("/var/run/reboot-required").and_return(false)
66
66
  expect(recipe.reboot_pending?).to be_falsey
67
67
  end
68
68
  end
@@ -115,7 +115,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
115
115
  # fake code to run through #recipe_snippet
116
116
  source_file = [ "if true", "var = non_existent", "end" ]
117
117
  allow(IO).to receive(:readlines).and_return(source_file)
118
- allow(File).to receive(:exists?).and_return(true)
118
+ allow(File).to receive(:exist?).and_return(true)
119
119
  end
120
120
 
121
121
  it "parses a Windows path" do
@@ -141,7 +141,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
141
141
 
142
142
  context "when the recipe file does not exist" do
143
143
  before do
144
- allow(File).to receive(:exists?).and_return(false)
144
+ allow(File).to receive(:exist?).and_return(false)
145
145
  allow(IO).to receive(:readlines).and_raise(Errno::ENOENT)
146
146
  end
147
147
 
@@ -1726,7 +1726,8 @@ describe Chef::Knife::Bootstrap do
1726
1726
 
1727
1727
  describe "#perform_bootstrap" do
1728
1728
  let(:exit_status) { 0 }
1729
- let(:result_mock) { double("result", exit_status: exit_status, stderr: "A message") }
1729
+ let(:stdout) { "" }
1730
+ let(:result_mock) { double("result", exit_status: exit_status, stderr: "A message", stdout: stdout) }
1730
1731
 
1731
1732
  before do
1732
1733
  allow(connection).to receive(:hostname).and_return "testhost"
@@ -1739,12 +1740,13 @@ describe Chef::Knife::Bootstrap do
1739
1740
  expect(connection)
1740
1741
  .to receive(:run_command)
1741
1742
  .with("sh /path.sh")
1742
- .and_yield("output here")
1743
+ .and_yield("output here", nil)
1743
1744
  .and_return result_mock
1744
1745
 
1745
1746
  expect(knife.ui).to receive(:msg).with(/testhost/)
1746
1747
  knife.perform_bootstrap("/path.sh")
1747
1748
  end
1749
+
1748
1750
  context "when the remote command fails" do
1749
1751
  let(:exit_status) { 1 }
1750
1752
  it "shows an error and exits" do
@@ -1756,6 +1758,25 @@ describe Chef::Knife::Bootstrap do
1756
1758
  expect { knife.perform_bootstrap("/path.sh") }.to raise_error(SystemExit)
1757
1759
  end
1758
1760
  end
1761
+
1762
+ context "when the remote command failed due to su auth error" do
1763
+ let(:exit_status) { 1 }
1764
+ let(:stdout) { "su: Authentication failure" }
1765
+ let(:connection_obj) { double("connection", transport_options: {}) }
1766
+ it "shows an error and exits" do
1767
+ allow(connection).to receive(:connection).and_return(connection_obj)
1768
+ expect(knife.ui).to receive(:info).with(/Bootstrapping.*/)
1769
+ expect(knife).to receive(:bootstrap_command)
1770
+ .with("/path.sh")
1771
+ .and_return("su - USER -c 'sh /path.sh'")
1772
+ expect(connection)
1773
+ .to receive(:run_command)
1774
+ .with("su - USER -c 'sh /path.sh'")
1775
+ .and_yield("output here", nil)
1776
+ .and_raise(Train::UserError)
1777
+ expect { knife.perform_bootstrap("/path.sh") }.to raise_error(Train::UserError)
1778
+ end
1779
+ end
1759
1780
  end
1760
1781
 
1761
1782
  describe "#connect!" do
@@ -1964,7 +1985,25 @@ describe Chef::Knife::Bootstrap do
1964
1985
  context "under Linux" do
1965
1986
  let(:linux_test) { true }
1966
1987
  it "prefixes the command to run under sh" do
1967
- expect(knife.bootstrap_command("bootstrap")).to eq "sh bootstrap"
1988
+ expect(knife.bootstrap_command("bootstrap.sh")).to eq "sh bootstrap.sh"
1989
+ end
1990
+
1991
+ context "with --su-user option" do
1992
+ let(:connection_obj) { double("connection", transport_options: {}) }
1993
+ before do
1994
+ knife.config[:su_user] = "root"
1995
+ allow(connection).to receive(:connection).and_return(connection_obj)
1996
+ end
1997
+ it "prefixes the command to run using su -USER -c" do
1998
+ expect(knife.bootstrap_command("bootstrap.sh")).to eq "su - #{knife.config[:su_user]} -c 'sh bootstrap.sh'"
1999
+ expect(connection_obj.transport_options.key?(:pty)).to eq true
2000
+ end
2001
+
2002
+ it "sudo appended if --sudo option enabled" do
2003
+ knife.config[:use_sudo] = true
2004
+ expect(knife.bootstrap_command("bootstrap.sh")).to eq "sudo su - #{knife.config[:su_user]} -c 'sh bootstrap.sh'"
2005
+ expect(connection_obj.transport_options.key?(:pty)).to eq true
2006
+ end
1968
2007
  end
1969
2008
  end
1970
2009
  end
@@ -46,7 +46,9 @@ describe Chef::Knife::SupermarketShare do
46
46
 
47
47
  allow(@knife).to receive(:shell_out!).and_return(true)
48
48
  @stdout = StringIO.new
49
+ @stderr = StringIO.new
49
50
  allow(@knife.ui).to receive(:stdout).and_return(@stdout)
51
+ allow(@knife.ui).to receive(:stderr).and_return(@stderr)
50
52
  end
51
53
 
52
54
  describe "run" do
@@ -140,7 +142,9 @@ describe Chef::Knife::SupermarketShare do
140
142
  before do
141
143
  allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
142
144
  @knife.config = { dry_run: true }
143
- allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file")
145
+ @so = instance_double("Mixlib::ShellOut")
146
+ allow(@knife).to receive(:shell_out!).and_return(@so)
147
+ allow(@so).to receive(:stdout).and_return("file")
144
148
  end
145
149
 
146
150
  it "should list files in the tarball" do
@@ -151,7 +155,6 @@ describe Chef::Knife::SupermarketShare do
151
155
  end
152
156
 
153
157
  it "does not upload the cookbook" do
154
- allow(@knife).to receive(:shell_out!).and_return(true)
155
158
  expect(@knife).not_to receive(:do_upload)
156
159
  @knife.run
157
160
  end
@@ -164,10 +167,6 @@ describe Chef::Knife::SupermarketShare do
164
167
  @upload_response = double("Net::HTTPResponse")
165
168
  allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response)
166
169
 
167
- @stdout = StringIO.new
168
- @stderr = StringIO.new
169
- allow(@knife.ui).to receive(:stdout).and_return(@stdout)
170
- allow(@knife.ui).to receive(:stderr).and_return(@stderr)
171
170
  allow(File).to receive(:open).and_return(true)
172
171
  end
173
172
 
@@ -66,6 +66,7 @@ describe Chef::Provider::Mount::Mount do
66
66
 
67
67
  describe "when dealing with network mounts" do
68
68
  { "nfs" => "nfsserver:/vol/path",
69
+ "cephfs" => "cephserver:6789:/",
69
70
  "cifs" => "//cifsserver/share" }.each do |type, fs_spec|
70
71
  it "should detect network fs_spec (#{type})" do
71
72
  @new_resource.device fs_spec
@@ -505,6 +506,57 @@ describe Chef::Provider::Mount::Mount do
505
506
  end
506
507
  end
507
508
 
509
+ context "network mount" do
510
+ before(:each) do
511
+ @node = Chef::Node.new
512
+ @events = Chef::EventDispatch::Dispatcher.new
513
+ @run_context = Chef::RunContext.new(@node, {}, @events)
514
+
515
+ @new_resource = Chef::Resource::Mount.new("/tmp/bar")
516
+ @new_resource.device "cephserver:6789:/"
517
+ @new_resource.device_type :device
518
+ @new_resource.fstype "cephfs"
519
+
520
+ @new_resource.supports remount: false
521
+
522
+ @provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
523
+
524
+ allow(::File).to receive(:exists?).with("cephserver:6789:/").and_return true
525
+ allow(::File).to receive(:exists?).with("/tmp/bar").and_return true
526
+ allow(::File).to receive(:realpath).with("cephserver:6789:/").and_return "cephserver:6789:/"
527
+ allow(::File).to receive(:realpath).with("/tmp/bar").and_return "/tmp/foo"
528
+ end
529
+
530
+ before do
531
+ @current_resource = Chef::Resource::Mount.new("/tmp/foo")
532
+ @current_resource.device "cephserver:6789:/"
533
+ @current_resource.device_type :device
534
+ @current_resource.fstype "cephfs"
535
+
536
+ @provider.current_resource = @current_resource
537
+ end
538
+
539
+ it "should enable network mount if enabled isn't true" do
540
+ @current_resource.enabled(false)
541
+
542
+ @fstab = StringIO.new
543
+ allow(::File).to receive(:open).with("/etc/fstab", "a").and_yield(@fstab)
544
+ @provider.enable_fs
545
+ expect(@fstab.string).to match(%r{^cephserver:6789:/\s+/tmp/bar\s+cephfs\s+defaults\s+0\s+2\s*$})
546
+ end
547
+
548
+ it "should not enable network if enabled is true and resources match" do
549
+ @current_resource.enabled(true)
550
+ @current_resource.fstype("cephfs")
551
+ @current_resource.options(["defaults"])
552
+ @current_resource.dump(0)
553
+ @current_resource.pass(2)
554
+ expect(::File).not_to receive(:open).with("/etc/fstab", "a")
555
+
556
+ @provider.enable_fs
557
+ end
558
+ end
559
+
508
560
  # the fstab might contain the mount with the device as a device but the resource has a label.
509
561
  # we should not create two mount lines, but update the existing one
510
562
  # not supported on solaris because it can't cope with a UUID device type
@@ -19,11 +19,17 @@ require "spec_helper"
19
19
 
20
20
  # NOTE: most of the tests of this functionality are baked into the func tests for the dnf package provider
21
21
 
22
- describe Chef::Provider::Package::Dnf::PythonHelper do
22
+ # run this test only for following platforms.
23
+ exclude_test = !(%w{rhel fedora amazon}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
24
+ describe Chef::Provider::Package::Dnf::PythonHelper, :requires_root, external: exclude_test do
23
25
  let(:helper) { Chef::Provider::Package::Dnf::PythonHelper.instance }
24
26
 
25
27
  it "propagates stacktraces on stderr from the forked subprocess", :rhel do
26
28
  allow(helper).to receive(:dnf_command).and_return("ruby -e 'raise \"your hands in the air\"'")
27
29
  expect { helper.package_query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
28
30
  end
31
+
32
+ it "compares EVRAs with dots in the release correctly" do
33
+ expect(helper.compare_versions("0:1.8.29-6.el8.x86_64", "0:1.8.29-6.el8_3.1.x86_64")).to eql(-1)
34
+ end
29
35
  end
@@ -78,7 +78,7 @@ describe Chef::Provider::Service::Macosx do
78
78
  @getpwuid = double("Etc::Passwd", { name: "mikedodge04" })
79
79
  allow(Etc).to receive(:getpwuid).and_return(@getpwuid)
80
80
  allow(node).to receive(:[]).with("platform_version").and_return("10.11.1")
81
- cmd = "launchctl list #{service_label}"
81
+ cmd = "/bin/launchctl list #{service_label}"
82
82
  allow(provider).to receive(:shell_out)
83
83
  .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false)
84
84
  .and_return(double("Status",
@@ -265,7 +265,7 @@ describe Chef::Provider::Service::Macosx do
265
265
  end
266
266
 
267
267
  it "starts service via launchctl if service found" do
268
- cmd = "launchctl load -w " + session + plist
268
+ cmd = "/bin/launchctl load -w " + session + plist
269
269
  expect(provider).to receive(:shell_out)
270
270
  .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
271
271
  .and_return(0)
@@ -297,7 +297,7 @@ describe Chef::Provider::Service::Macosx do
297
297
  end
298
298
 
299
299
  it "stops the service via launchctl if service found" do
300
- cmd = "launchctl unload -w " + plist
300
+ cmd = "/bin/launchctl unload -w " + plist
301
301
  expect(provider).to receive(:shell_out)
302
302
  .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
303
303
  .and_return(0)
@@ -93,41 +93,41 @@ describe Chef::Resource::ChefClientCron do
93
93
 
94
94
  it "creates a valid command if using all default properties" do
95
95
  expect(provider.client_command).to eql(
96
- "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
96
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
97
97
  )
98
98
  end
99
99
 
100
100
  it "uses daemon_options if set" do
101
101
  resource.daemon_options ["--foo 1", "--bar 2"]
102
102
  expect(provider.client_command).to eql(
103
- "/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path} -L /var/log/chef/client.log"
103
+ "/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path} >> /var/log/chef/client.log 2>&1"
104
104
  )
105
105
  end
106
106
 
107
107
  it "uses custom config dir if set" do
108
108
  resource.config_directory "/etc/some_other_dir"
109
- expect(provider.client_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/some_other_dir/client.rb -L /var/log/chef/client.log")
109
+ expect(provider.client_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/some_other_dir/client.rb >> /var/log/chef/client.log 2>&1")
110
110
  end
111
111
 
112
112
  it "uses custom log files / paths if set" do
113
113
  resource.log_file_name "my-client.log"
114
114
  resource.log_directory "/var/log/my-chef/"
115
115
  expect(provider.client_command).to eql(
116
- "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/my-chef/my-client.log"
116
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/my-chef/my-client.log 2>&1"
117
117
  )
118
118
  end
119
119
 
120
120
  it "uses mailto if set" do
121
121
  resource.mailto "bob@example.com"
122
122
  expect(provider.client_command).to eql(
123
- "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\""
123
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1 || echo \"Chef Infra Client execution failed\""
124
124
  )
125
125
  end
126
126
 
127
127
  it "uses custom chef-client binary if set" do
128
128
  resource.chef_binary_path "/usr/local/bin/chef-client"
129
129
  expect(provider.client_command).to eql(
130
- "/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
130
+ "/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
131
131
  )
132
132
  end
133
133
 
@@ -141,7 +141,7 @@ describe Chef::Resource::ChefClientCron do
141
141
  it "sets the license acceptance flag if set" do
142
142
  resource.accept_chef_license true
143
143
  expect(provider.client_command).to eql(
144
- "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept -L /var/log/chef/client.log"
144
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept >> /var/log/chef/client.log 2>&1"
145
145
  )
146
146
  end
147
147
 
@@ -149,7 +149,7 @@ describe Chef::Resource::ChefClientCron do
149
149
  allow(provider).to receive(:which).with("nice").and_return("/usr/bin/nice")
150
150
  resource.nice(-15)
151
151
  expect(provider.client_command).to eql(
152
- "/bin/sleep 123; /usr/bin/nice -n -15 /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
152
+ "/bin/sleep 123; /usr/bin/nice -n -15 /opt/chef/bin/chef-client -c #{root_path} >> /var/log/chef/client.log 2>&1"
153
153
  )
154
154
  end
155
155
  end
@@ -28,7 +28,11 @@ class DummyResource < Chef::Resource
28
28
  introduced "14.0"
29
29
  property :first, String, description: "My First Property", introduced: "14.0"
30
30
 
31
- action :dummy do
31
+ action :dummy, description: "Dummy action" do
32
+ return true
33
+ end
34
+
35
+ action :dummy_no_desc do
32
36
  return true
33
37
  end
34
38
  end
@@ -39,7 +43,8 @@ describe Chef::ResourceInspector do
39
43
 
40
44
  it "returns a hash with required data" do
41
45
  expect(subject[:description]).to eq "A dummy resource"
42
- expect(subject[:actions]).to match_array %i{nothing dummy}
46
+ expect(subject[:actions]).to eq({ nothing: nil, dummy: "Dummy action",
47
+ dummy_no_desc: nil })
43
48
  end
44
49
 
45
50
  context "excluding built in properties" do
@@ -1162,6 +1162,52 @@ describe Chef::Resource do
1162
1162
  end
1163
1163
  end
1164
1164
 
1165
+ describe "#action_description" do
1166
+ class TestResource < ::Chef::Resource
1167
+ action :symbol_action, description: "a symbol test" do; end
1168
+ action "string_action", description: "a string test" do; end
1169
+ action :base_action0 do; end
1170
+ action :base_action1, description: "unmodified base action 1 desc" do; end
1171
+ action :base_action2, description: "unmodified base action 2 desc" do; end
1172
+ action :base_action3, description: "unmodified base action 3 desc" do; end
1173
+ end
1174
+
1175
+ it "returns nil when no description was provided for the action" do
1176
+ expect(TestResource.action_description(:base_action0)).to eql(nil)
1177
+ end
1178
+
1179
+ context "when action definition is a string" do
1180
+ it "returns the description whether a symbol or string is used to look it up" do
1181
+ expect(TestResource.action_description("string_action")).to eql("a string test")
1182
+ expect(TestResource.action_description(:string_action)).to eql("a string test")
1183
+ end
1184
+ end
1185
+
1186
+ context "when action definition is a symbol" do
1187
+ it "returns the description whether a symbol or string is used to look up" do
1188
+ expect(TestResource.action_description("symbol_action")).to eql("a symbol test")
1189
+ expect(TestResource.action_description(:symbol_action)).to eql("a symbol test")
1190
+ end
1191
+ end
1192
+
1193
+ context "when inheriting from an existing resource" do
1194
+ class TestResourceChild < TestResource
1195
+ action :base_action2, description: "modified base action 2 desc" do; end
1196
+ action :base_action3 do; end
1197
+ end
1198
+
1199
+ it "returns original description when a described action is not overridden in child resource" do
1200
+ expect(TestResourceChild.action_description(:base_action1)).to eq "unmodified base action 1 desc"
1201
+ end
1202
+ it "returns original description when the child resource overrides an inherited action but NOT its description" do
1203
+ expect(TestResourceChild.action_description(:base_action3)).to eq "unmodified base action 3 desc"
1204
+ end
1205
+ it "returns new description when the child resource overrides an inherited action and its description" do
1206
+ expect(TestResourceChild.action_description(:base_action2)).to eq "modified base action 2 desc"
1207
+ end
1208
+ end
1209
+ end
1210
+
1165
1211
  describe ".default_action" do
1166
1212
  let(:default_action) {}
1167
1213
  let(:resource_class) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.9.29
4
+ version: 16.12.3
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 16.9.29
19
+ version: 16.12.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 16.9.29
26
+ version: 16.12.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 16.9.29
33
+ version: 16.12.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 16.9.29
40
+ version: 16.12.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -326,16 +326,16 @@ dependencies:
326
326
  name: bcrypt_pbkdf
327
327
  requirement: !ruby/object:Gem::Requirement
328
328
  requirements:
329
- - - '='
329
+ - - "~>"
330
330
  - !ruby/object:Gem::Version
331
- version: 1.1.0.rc2
331
+ version: '1.1'
332
332
  type: :runtime
333
333
  prerelease: false
334
334
  version_requirements: !ruby/object:Gem::Requirement
335
335
  requirements:
336
- - - '='
336
+ - - "~>"
337
337
  - !ruby/object:Gem::Version
338
- version: 1.1.0.rc2
338
+ version: '1.1'
339
339
  - !ruby/object:Gem::Dependency
340
340
  name: highline
341
341
  requirement: !ruby/object:Gem::Requirement
@@ -756,14 +756,14 @@ dependencies:
756
756
  requirements:
757
757
  - - "~>"
758
758
  - !ruby/object:Gem::Version
759
- version: '0.3'
759
+ version: 0.5.0
760
760
  type: :runtime
761
761
  prerelease: false
762
762
  version_requirements: !ruby/object:Gem::Requirement
763
763
  requirements:
764
764
  - - "~>"
765
765
  - !ruby/object:Gem::Version
766
- version: '0.3'
766
+ version: 0.5.0
767
767
  description: A systems integration framework, built to bring the benefits of configuration
768
768
  management to your entire infrastructure.
769
769
  email: adam@chef.io
@@ -852,6 +852,7 @@ files:
852
852
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Contracts.dll
853
853
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Debug.dll
854
854
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.DiagnosticSource.dll
855
+ - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll
855
856
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll
856
857
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.FileVersionInfo.dll
857
858
  - distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Process.dll
@@ -1156,6 +1157,7 @@ files:
1156
1157
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Contracts.dll
1157
1158
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Debug.dll
1158
1159
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.DiagnosticSource.dll
1160
+ - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll
1159
1161
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll
1160
1162
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.FileVersionInfo.dll
1161
1163
  - distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.Process.dll