chef 17.10.68-universal-mingw32 → 17.10.114-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -4
  3. data/chef-universal-mingw32.gemspec +2 -2
  4. data/chef.gemspec +3 -3
  5. data/lib/chef/client.rb +4 -3
  6. data/lib/chef/mixin/homebrew_user.rb +15 -5
  7. data/lib/chef/mixin/properties.rb +6 -0
  8. data/lib/chef/provider/package/chocolatey.rb +18 -1
  9. data/lib/chef/provider/package/zypper.rb +5 -0
  10. data/lib/chef/provider/service/windows.rb +1 -0
  11. data/lib/chef/provider/user.rb +5 -1
  12. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
  13. data/lib/chef/resource/homebrew_cask.rb +7 -8
  14. data/lib/chef/resource/homebrew_package.rb +1 -1
  15. data/lib/chef/resource/homebrew_tap.rb +5 -5
  16. data/lib/chef/resource/locale.rb +5 -2
  17. data/lib/chef/resource/macos_userdefaults.rb +9 -5
  18. data/lib/chef/resource.rb +2 -1
  19. data/lib/chef/version.rb +1 -1
  20. data/spec/data/trusted_certs/example.crt +29 -20
  21. data/spec/data/trusted_certs/example_no_cn.crt +30 -34
  22. data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
  23. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  24. data/spec/functional/resource/yum_package_spec.rb +1 -1
  25. data/spec/functional/resource/zypper_package_spec.rb +10 -0
  26. data/spec/unit/client_spec.rb +2 -2
  27. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  28. data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
  29. data/spec/unit/provider/package/chocolatey_spec.rb +19 -3
  30. data/spec/unit/provider/user/linux_spec.rb +55 -0
  31. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  32. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  33. data/spec/unit/resource_spec.rb +22 -1
  34. metadata +46 -40
  35. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
  36. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
  37. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
  38. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d9d9d9cbb55bb86e05548927fb83610a617358381e8c6c551a7329accdd98c0
4
- data.tar.gz: 18a8c173eccb6630ca30587f7e2f73fb5fee8c42aed86eed1c5a1b4614f9173c
3
+ metadata.gz: 0c7be97bfc509a17ef34e5db14410f0ef6776e5d0f7c2b318b5f34f8807b336e
4
+ data.tar.gz: a89b9d196345735f2541f59f1c814c2029207447afb27c52b619ecdcca1b2e62
5
5
  SHA512:
6
- metadata.gz: cd1e32e1784340c4aa1ebe99151a5a776e31fa44a674cfb2b7aa1f8bac146ee2d305d32f31447b310776cd8622252dc764fe86a31b4429026682fe71c4dad704
7
- data.tar.gz: 343327a70c71c32574d040decaeebc44842386cd673890ef02db95337334a99c82f0e6cd8ee03e2f1c5cead88c1e0f43a27163e591d12252971d41d63b4a1256
6
+ metadata.gz: 5f6857ffc3db30aefad7f17ce04f7540f38ac2bc8dbe505da89e9b9d0a8677c5dedec6876782483de8024db3fcf43ae79619f2a280333f479ee00791a38f6d6c
7
+ data.tar.gz: 6f5d26697302bf28d520f042f7dfaf044c0e8bea86d267da4180078f544d29dd48d66d0784dfc9586814c59b0a2b449eb20c1b5794ecd8dc7160a6d304da020b
data/Gemfile CHANGED
@@ -17,17 +17,18 @@ end
17
17
 
18
18
  gem "cheffish", "~> 17.0.0"
19
19
 
20
+ gem "ast", "~> 2.4.2"
21
+ gem "rubocop-ast", ">= 1.30.0"
22
+
20
23
  group(:omnibus_package) do
21
24
  gem "appbundler"
22
25
  gem "rb-readline"
23
- gem "inspec-core-bin", ">= 4.24" # need to provide the binaries for inspec
26
+ gem "inspec-core-bin", "~> 5.22.36" # need to provide the binaries for inspec
24
27
  gem "chef-vault"
25
28
  end
26
29
 
27
30
  group(:omnibus_package, :pry) do
28
- # Locked because pry-byebug is broken with 13+.
29
- # some work is ongoing? https://github.com/deivid-rodriguez/pry-byebug/issues/343
30
- gem "pry", "= 0.13.0"
31
+ gem "pry", ">= 0.14.1"
31
32
  # byebug does not install on freebsd on ruby 3.0
32
33
  gem "pry-byebug" unless RUBY_PLATFORM.match?(/freebsd/i)
33
34
  gem "pry-stack_explorer"
@@ -11,10 +11,10 @@ gemspec.add_dependency "win32-mmap", "~> 0.4.1"
11
11
  gemspec.add_dependency "win32-mutex", "~> 0.4.2"
12
12
  gemspec.add_dependency "win32-process", "~> 0.9"
13
13
  gemspec.add_dependency "win32-service", ">= 2.1.5", "< 3.0"
14
- gemspec.add_dependency "wmi-lite", "~> 1.0"
15
14
  gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
15
+ gemspec.add_dependency "win32-certstore", "~> 0.6.15"
16
+ gemspec.add_dependency "wmi-lite", "~> 1.0"
16
17
  gemspec.add_dependency "iso8601", ">= 0.12.1", "< 0.14" # validate 0.14 when it comes out
17
- gemspec.add_dependency "win32-certstore", "~> 0.6.14"
18
18
  gemspec.add_dependency "chef-powershell", "~> 1.0.12" # 0.5+ required for specifying user vs. system store
19
19
  gemspec.extensions << "ext/win32-eventlog/Rakefile"
20
20
  gemspec.files += Dir.glob("{distro,ext}/**/*")
data/chef.gemspec CHANGED
@@ -36,10 +36,10 @@ Gem::Specification.new do |s|
36
36
  s.add_dependency "mixlib-shellout", ">= 3.1.1", "< 4.0"
37
37
  s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
38
38
  s.add_dependency "ohai", "~> 17.0"
39
- s.add_dependency "inspec-core", ">= 4.23"
39
+ s.add_dependency "inspec-core", "~> 5.22.36"
40
40
 
41
- s.add_dependency "ffi", ">= 1.5.0"
42
- s.add_dependency "ffi-yajl", "~> 2.2"
41
+ s.add_dependency "ffi", "~> 1.15.5"
42
+ s.add_dependency "ffi-yajl", ">= 2.2", "< 4.0"
43
43
  s.add_dependency "net-sftp", ">= 2.1.2", "< 5.0" # remote_file resource
44
44
  s.add_dependency "erubis", "~> 2.7" # template resource / cookbook syntax check
45
45
  s.add_dependency "diff-lcs", ">= 1.2.4", "!= 1.4.0", "< 1.6.0" # 1.4 breaks output. Used in lib/chef/util/diff
data/lib/chef/client.rb CHANGED
@@ -330,9 +330,10 @@ class Chef
330
330
  new_date = eol_override
331
331
 
332
332
  # We make a release every year so take the version you're on + 2006 and you get
333
- # the year it goes EOL
334
- eol_year = 2006 + Gem::Version.new(Chef::VERSION).segments.first
335
- cut_off_date = !!new_date ? Time.parse(new_date) : Time.new(eol_year, 5, 01)
333
+ # the year it goes EOL. 1/8/2024 - EOL for Chef-17 is now November 1, 2024
334
+ # eol_year = 2006 + Gem::Version.new(Chef::VERSION).segments.first
335
+ eol_year = "2024"
336
+ cut_off_date = !!new_date ? Time.parse(new_date) : Time.new(eol_year, 11, 30)
336
337
 
337
338
  return if Time.now < cut_off_date
338
339
 
@@ -57,18 +57,28 @@ class Chef
57
57
  @homebrew_owner_username
58
58
  end
59
59
 
60
+ def homebrew_bin_path(brew_bin_path = nil)
61
+ if brew_bin_path && ::File.exist?(brew_bin_path)
62
+ brew_bin_path
63
+ else
64
+ [which("brew"), "/opt/homebrew/bin/brew", "/usr/local/bin/brew", "/home/linuxbrew/.linuxbrew/bin/brew"].uniq.select do |x|
65
+ next if x == false
66
+
67
+ ::File.exist?(x) && ::File.executable?(x)
68
+ end.first || nil
69
+ end
70
+ end
71
+
60
72
  private
61
73
 
62
74
  def calculate_owner
63
- default_brew_path = "/usr/local/bin/brew"
64
- if ::File.exist?(default_brew_path)
75
+ brew_path = homebrew_bin_path
76
+ if brew_path
65
77
  # By default, this follows symlinks which is what we want
66
- owner = ::File.stat(default_brew_path).uid
67
- elsif (brew_path = shell_out("which brew").stdout.strip) && !brew_path.empty?
68
78
  owner = ::File.stat(brew_path).uid
69
79
  else
70
80
  raise Chef::Exceptions::CannotDetermineHomebrewOwner,
71
- 'Could not find the "brew" executable in /usr/local/bin or anywhere on the path.'
81
+ 'Could not find the "brew" executable anywhere on the path.'
72
82
  end
73
83
 
74
84
  Chef::Log.debug "Found Homebrew owner #{Etc.getpwuid(owner).name}; executing `brew` commands as them"
@@ -274,6 +274,12 @@ class Chef
274
274
  result
275
275
  end
276
276
 
277
+ # This method returns list of sensitive properties
278
+ # @return [Array<Property>] All sensitive properties.
279
+ def sensitive_properties
280
+ properties.values.empty? ? [] : properties.values.select(&:sensitive?)
281
+ end
282
+
277
283
  # Returns the name of the name property. Returns nil if there is no name property.
278
284
  #
279
285
  # @return [Symbol] the name property for this resource
@@ -130,6 +130,21 @@ class Chef
130
130
  # install from, but like the rubygem provider's sources which are more like repos.
131
131
  def check_resource_semantics!; end
132
132
 
133
+ def self.get_choco_version
134
+ @get_choco_version ||= powershell_exec!("choco --version").result
135
+ end
136
+
137
+ # Choco V2 uses 'Search' for remote repositories and 'List' for local packages
138
+ def self.query_command
139
+ return "list" if get_choco_version.match?(/^1/)
140
+
141
+ "search"
142
+ end
143
+
144
+ def query_command
145
+ self.class.query_command
146
+ end
147
+
133
148
  private
134
149
 
135
150
  def version_compare(v1, v2)
@@ -225,7 +240,7 @@ class Chef
225
240
  package_name_array.each do |pkg|
226
241
  available_versions =
227
242
  begin
228
- cmd = [ "list", "-r", pkg ]
243
+ cmd = [ query_command, "-r", pkg ]
229
244
  cmd += common_options
230
245
  cmd.push( new_resource.list_options ) if new_resource.list_options
231
246
 
@@ -242,6 +257,8 @@ class Chef
242
257
  # Installed packages in chocolatey as a Hash of names mapped to versions
243
258
  # (names are downcased for case-insensitive matching)
244
259
  #
260
+ # Beginning with Choco 2.0, "list" returns local packages only while "search" returns packages from external package sources
261
+ #
245
262
  # @return [Hash] name-to-version mapping of installed packages
246
263
  def installed_packages
247
264
  @installed_packages ||= Hash[*parse_list_output("list", "-l", "-r").flatten]
@@ -93,6 +93,11 @@ class Chef
93
93
  end
94
94
  current_version ||= latest_version if is_installed
95
95
  current_version
96
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
97
+ # zypper returns a '104' code if info is called for a non-existent package
98
+ return nil if e.message =~ /'104'/
99
+
100
+ raise
96
101
  end
97
102
 
98
103
  def resolve_available_version(package_name, new_version)
@@ -74,6 +74,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
74
74
  current_resource.run_as_user(config_info.service_start_name) if config_info.service_start_name
75
75
  current_resource.display_name(config_info.display_name) if config_info.display_name
76
76
  current_resource.delayed_start(current_delayed_start) if current_delayed_start
77
+ current_resource.description(config_info.description) if new_resource.description
77
78
  end
78
79
 
79
80
  current_resource
@@ -117,7 +117,11 @@ class Chef
117
117
  new_val = new_resource.send(user_attrib)
118
118
  cur_val = current_resource.send(user_attrib)
119
119
  if !new_val.nil? && new_val.to_s != cur_val.to_s
120
- @change_desc << "change #{user_attrib} from #{cur_val} to #{new_val}"
120
+ if user_attrib.to_s == "password" && new_resource.sensitive
121
+ @change_desc << "change #{user_attrib} from ******** to ********"
122
+ else
123
+ @change_desc << "change #{user_attrib} from #{cur_val} to #{new_val}"
124
+ end
121
125
  end
122
126
  end
123
127
 
@@ -177,7 +177,7 @@ class Chef
177
177
  }
178
178
 
179
179
  unit["Service"]["ConditionACPower"] = "true" unless new_resource.run_on_battery
180
- unit["Service"]["CPUQuota"] = new_resource.cpu_quota if new_resource.cpu_quota
180
+ unit["Service"]["CPUQuota"] = "#{new_resource.cpu_quota}%" if new_resource.cpu_quota
181
181
  unit["Service"]["Environment"] = new_resource.environment.collect { |k, v| "\"#{k}=#{v}\"" } unless new_resource.environment.empty?
182
182
  unit
183
183
  end
@@ -46,25 +46,24 @@ class Chef
46
46
  default: true
47
47
 
48
48
  property :homebrew_path, String,
49
- description: "The path to the homebrew binary.",
50
- default: "/usr/local/bin/brew"
49
+ description: "The path to the homebrew binary."
51
50
 
52
51
  property :owner, [String, Integer],
53
52
  description: "The owner of the Homebrew installation.",
54
53
  default: lazy { find_homebrew_username },
55
- default_description: "Calculated default username"\
54
+ default_description: "Calculated default username"
56
55
 
57
56
  action :install, description: "Install an application that is packaged as a Homebrew cask." do
58
57
  if new_resource.install_cask
59
58
  homebrew_tap "homebrew/cask" do
60
- homebrew_path new_resource.homebrew_path
59
+ homebrew_path homebrew_bin_path(new_resource.homebrew_path)
61
60
  owner new_resource.owner
62
61
  end
63
62
  end
64
63
 
65
64
  unless casked?
66
65
  converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
67
- shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
66
+ shell_out!("#{homebrew_bin_path(new_resource.homebrew_path)} install --cask #{new_resource.cask_name} #{new_resource.options}",
68
67
  user: new_resource.owner,
69
68
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
70
69
  cwd: ::Dir.home(new_resource.owner))
@@ -75,14 +74,14 @@ class Chef
75
74
  action :remove, description: "Remove an application that is packaged as a Homebrew cask." do
76
75
  if new_resource.install_cask
77
76
  homebrew_tap "homebrew/cask" do
78
- homebrew_path new_resource.homebrew_path
77
+ homebrew_path homebrew_bin_path(new_resource.homebrew_path)
79
78
  owner new_resource.owner
80
79
  end
81
80
  end
82
81
 
83
82
  if casked?
84
83
  converge_by("uninstall cask #{new_resource.cask_name}") do
85
- shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
84
+ shell_out!("#{homebrew_bin_path(new_resource.homebrew_path)} uninstall --cask #{new_resource.cask_name}",
86
85
  user: new_resource.owner,
87
86
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
88
87
  cwd: ::Dir.home(new_resource.owner))
@@ -100,7 +99,7 @@ class Chef
100
99
  # @return [Boolean]
101
100
  def casked?
102
101
  unscoped_name = new_resource.cask_name.split("/").last
103
- shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
102
+ shell_out!("#{homebrew_bin_path(new_resource.homebrew_path)} list --cask 2>/dev/null",
104
103
  user: new_resource.owner,
105
104
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
106
105
  cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
@@ -62,7 +62,7 @@ class Chef
62
62
  DOC
63
63
 
64
64
  property :homebrew_user, [ String, Integer ],
65
- description: "The name or uid of the Homebrew owner to be used by #{ChefUtils::Dist::Infra::PRODUCT} when executing a command.\n\n#{ChefUtils::Dist::Infra::PRODUCT}, by default, will attempt to execute a Homebrew command as the owner of the `/usr/local/bin/brew` executable. If that executable does not exist, #{ChefUtils::Dist::Infra::PRODUCT} will attempt to find the user by executing `which brew`. If that executable cannot be found, #{ChefUtils::Dist::Infra::PRODUCT} will print an error message: `Could not find the 'brew' executable in /usr/local/bin or anywhere on the path.`.\n\nSet this property to specify the Homebrew owner for situations where Chef Infra Client cannot automatically detect the correct owner.'"
65
+ description: "The name or uid of the Homebrew owner to be used by #{ChefUtils::Dist::Infra::PRODUCT} when executing a command.\n\n#{ChefUtils::Dist::Infra::PRODUCT}, by default, will attempt to execute a Homebrew command as the owner of the `/usr/local/bin/brew` executable on x86_64 machines or `/opt/homebrew/bin/brew` executable on arm64 machines. If that executable does not exist, #{ChefUtils::Dist::Infra::PRODUCT} will attempt to find the user by executing `which brew`. If that executable cannot be found, #{ChefUtils::Dist::Infra::PRODUCT} will print an error message: `Could not find the 'brew' executable in /usr/local/bin, /opt/homebrew/bin, or anywhere on the path.`.\n\nSet this property to specify the Homebrew owner for situations where Chef Infra Client cannot automatically detect the correct owner.'"
66
66
 
67
67
  end
68
68
  end
@@ -42,8 +42,7 @@ class Chef
42
42
  description: "The URL of the tap."
43
43
 
44
44
  property :homebrew_path, String,
45
- description: "The path to the Homebrew binary.",
46
- default: "/usr/local/bin/brew"
45
+ description: "The path to the Homebrew binary."
47
46
 
48
47
  property :owner, String,
49
48
  description: "The owner of the Homebrew installation.",
@@ -53,7 +52,7 @@ class Chef
53
52
  action :tap, description: "Add a Homebrew tap." do
54
53
  unless tapped?(new_resource.tap_name)
55
54
  converge_by("tap #{new_resource.tap_name}") do
56
- shell_out!("#{new_resource.homebrew_path} tap #{new_resource.tap_name} #{new_resource.url || ""}",
55
+ shell_out!("#{homebrew_bin_path(new_resource.homebrew_path)} tap #{new_resource.tap_name} #{new_resource.url || ""}",
57
56
  user: new_resource.owner,
58
57
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
59
58
  cwd: ::Dir.home(new_resource.owner))
@@ -64,7 +63,7 @@ class Chef
64
63
  action :untap, description: "Remove a Homebrew tap." do
65
64
  if tapped?(new_resource.tap_name)
66
65
  converge_by("untap #{new_resource.tap_name}") do
67
- shell_out!("#{new_resource.homebrew_path} untap #{new_resource.tap_name}",
66
+ shell_out!("#{homebrew_bin_path(new_resource.homebrew_path)} untap #{new_resource.tap_name}",
68
67
  user: new_resource.owner,
69
68
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
70
69
  cwd: ::Dir.home(new_resource.owner))
@@ -76,8 +75,9 @@ class Chef
76
75
  #
77
76
  # @return [Boolean]
78
77
  def tapped?(name)
78
+ base_path = ["#{::File.dirname(which("brew"))}/../homebrew", "#{::File.dirname(which("brew"))}/../Homebrew", "/opt/homebrew", "/usr/local/Homebrew", "/home/linuxbrew/.linuxbrew"].uniq.select { |x| Dir.exist?(x) }.first
79
79
  tap_dir = name.gsub("/", "/homebrew-")
80
- ::File.directory?("/usr/local/Homebrew/Library/Taps/#{tap_dir}")
80
+ ::File.directory?("#{base_path}/Library/Taps/#{tap_dir}")
81
81
  end
82
82
  end
83
83
  end
@@ -113,8 +113,11 @@ class Chef
113
113
  end
114
114
 
115
115
  requirements.assert(:all_actions) do |a|
116
- # RHEL/CentOS type platforms don't have locale-gen
117
- a.assertion { which("locale-gen") }
116
+ a.assertion do
117
+ # RHEL/CentOS type platforms don't have locale-gen
118
+ # Windows has locale-gen as part of the install, but not in the path
119
+ which("locale-gen") || windows?
120
+ end
118
121
  a.failure_message(Chef::Exceptions::ProviderNotFound, "The locale resource requires the locale-gen tool")
119
122
  end
120
123
  end
@@ -51,15 +51,17 @@ class Chef
51
51
  end
52
52
  ```
53
53
 
54
- **Specifying the type of a key to skip automatic type detection**
54
+ **Setting a value for specific user and hosts**
55
55
 
56
56
  ```ruby
57
- macos_userdefaults 'Finder expanded save dialogs' do
58
- key 'NSNavPanelExpandedStateForSaveMode'
59
- value 'TRUE'
60
- type 'bool'
57
+ macos_userdefaults 'Enable macOS firewall' do
58
+ key 'globalstate'
59
+ value 1
60
+ user 'jane'
61
+ host :current
61
62
  end
62
63
  ```
64
+
63
65
  DOC
64
66
 
65
67
  property :domain, String,
@@ -80,6 +82,7 @@ class Chef
80
82
 
81
83
  property :host, [String, Symbol],
82
84
  description: "Set either :current, :all or a hostname to set the user default at the host level.",
85
+ default: :all,
83
86
  desired_state: false,
84
87
  introduced: "16.3"
85
88
 
@@ -95,6 +98,7 @@ class Chef
95
98
 
96
99
  property :user, [String, Symbol],
97
100
  description: "The system user that the default will be applied to. Set :current for current user, :all for all users or pass a valid username",
101
+ default: :current,
98
102
  desired_state: false
99
103
 
100
104
  property :sudo, [TrueClass, FalseClass],
data/lib/chef/resource.rb CHANGED
@@ -660,7 +660,8 @@ class Chef
660
660
  text << "#{resource_name}(\"#{name}\") do\n"
661
661
 
662
662
  all_props = {}
663
- self.class.state_properties.map do |p|
663
+
664
+ self.class.sensitive_properties.map do |p|
664
665
 
665
666
  all_props[p.name.to_s] = p.sensitive? ? '"*sensitive value suppressed*"' : value_to_text(p.get(self))
666
667
  rescue Chef::Exceptions::ValidationFailed
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("17.10.68")
26
+ VERSION = Chef::VersionString.new("17.10.114")
27
27
  end
28
28
 
29
29
  #
@@ -1,22 +1,31 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDkjCCAnoCCQDihI8kxGYTFTANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMC
3
- VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMRAwDgYDVQQKEwdZb3VD
4
- b3JwMRMwEQYDVQQLEwpPcGVyYXRpb25zMRYwFAYDVQQDEw1leGFtcGxlLmxvY2Fs
5
- MR0wGwYJKoZIhvcNAQkBFg5tZUBleGFtcGxlLmNvbTAeFw0xMzEwMTcxODAxMzVa
6
- Fw0yMzEwMTUxODAxMzVaMIGKMQswCQYDVQQGEwJVUzELMAkGA1UECBMCV0ExEDAO
7
- BgNVBAcTB1NlYXR0bGUxEDAOBgNVBAoTB1lvdUNvcnAxEzARBgNVBAsTCk9wZXJh
8
- dGlvbnMxFjAUBgNVBAMTDWV4YW1wbGUubG9jYWwxHTAbBgkqhkiG9w0BCQEWDm1l
9
- QGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKBo
10
- U+Bdni0xZK/NCzdLdi2X+TyW5eahbYMx+r1GDcVqCICvrthBCVLVFsQ8rvOHwTPi
11
- AxQJGxb9TLSXRgXQSlH6FLjIUceuOtpan3qYVJ1v7AxY4DgNvYBpbtJz5MQedJnT
12
- g2F+rXzkwaD6CWBqWHeGU0oP3r7bq1AMD6XEsK2w2/zHtG7TEnL45ARv1PsyrU5M
13
- ZAW/XyoMyq1k2Lpv7YR5kAvTq1+4RSt/it2RFE7R0AVbaQ0MeAnllfySiHHHlaOT
14
- FVd/qPSiGISxsUmmzA3Z08+0sfJwkrnJXbLscCBYndd7gMGgtczGjJtul0Ch3GFa
15
- /Pn5McjwF272+usJ1wIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQCzPePWifWNECs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/a725eb6fMnGFVSxQ0DXlPSPQnJ2tsGMAM37fxoPfF9IamrmdD
28
+ Q0Usia+XzBckD0sSG8j50x2of9NS3vFFgWM1Cas55XWzlkDGbIJMlrKOj01bUYNq
29
+ ltmMfavmpMPA86p8QHRmWlQhtgu+OK/8RxmGtQdtBi8Gdk3mNMkokSQCVcDWvNhX
30
+ pVFCGya51orBgbWqxbAsIeiv7Pl85edXm8KolJ389xkXqFvX31hme5KnyBhCcRrv
31
+ EZbXRhY3O58t7SlKWVCnx/JmEkJcRJtZaEReF1LbBayExYNnj/sD
36
32
  -----END CERTIFICATE-----
@@ -22,8 +22,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
22
22
  include Chef::Mixin::ShellOut
23
23
 
24
24
  let(:package_name) { "test-A" }
25
- let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
26
25
  let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
26
+ let(:package_list) do
27
+ if Chef::Provider::Package::Chocolatey.query_command == "list"
28
+ # using result of query_command because that indicates which "search" command to use
29
+ # which coincides with the package list output
30
+ proc { shell_out!("choco search -lo #{Array(package_name).join(" ")}").stdout.chomp }
31
+ else
32
+ proc { shell_out!("choco list #{Array(package_name).join(" ")}").stdout.chomp }
33
+ end
34
+ end
27
35
 
28
36
  let(:run_context) do
29
37
  Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
@@ -54,12 +62,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
54
62
  ENV["Path"] = ENV.delete("Path")
55
63
  end
56
64
 
65
+ after(:each) do
66
+ described_class.instance_variable_set(:@get_choco_version, nil)
67
+ end
68
+
57
69
  context "installing a package" do
58
70
  after { remove_package }
59
71
 
60
72
  it "installs the latest version" do
61
73
  subject.run_action(:install)
62
- expect(package_list.call).to eq("#{package_name}|2.0")
74
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
63
75
  end
64
76
 
65
77
  it "does not install if already installed" do
@@ -69,19 +81,19 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
69
81
  end
70
82
 
71
83
  it "installs version given" do
72
- subject.version "1.0"
84
+ subject.version "1.0.0"
73
85
  subject.run_action(:install)
74
- expect(package_list.call).to eq("#{package_name}|1.0")
86
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
75
87
  end
76
88
 
77
89
  it "installs new version if one is already installed" do
78
- subject.version "1.0"
90
+ subject.version "1.0.0"
79
91
  subject.run_action(:install)
80
- expect(package_list.call).to eq("#{package_name}|1.0")
92
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
81
93
 
82
- subject.version "2.0"
94
+ subject.version "2.0.0"
83
95
  subject.run_action(:install)
84
- expect(package_list.call).to eq("#{package_name}|2.0")
96
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
85
97
  end
86
98
 
87
99
  context "installing multiple packages" do
@@ -89,7 +101,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
89
101
 
90
102
  it "installs both packages" do
91
103
  subject.run_action(:install)
92
- expect(package_list.call).to eq("test-A|2.0\r\ntest-B|1.0")
104
+ expect(package_list.call).to match(/^test-A|2.0.0\r\ntest-B|1.0.0$/)
93
105
  end
94
106
  end
95
107
 
@@ -101,13 +113,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
101
113
  it "installs with an option as a string" do
102
114
  subject.options "--force --confirm"
103
115
  subject.run_action(:install)
104
- expect(package_list.call).to eq("#{package_name}|2.0")
116
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
105
117
  end
106
118
 
107
119
  it "installs with multiple options as a string" do
108
120
  subject.options "--force --confirm"
109
121
  subject.run_action(:install)
110
- expect(package_list.call).to eq("#{package_name}|2.0")
122
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
111
123
  end
112
124
 
113
125
  context "when multiple options passed as string" do
@@ -137,7 +149,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
137
149
  it "installs with multiple options as an array" do
138
150
  subject.options [ "--force", "--confirm" ]
139
151
  subject.run_action(:install)
140
- expect(package_list.call).to eq("#{package_name}|2.0")
152
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
141
153
  end
142
154
  end
143
155
 
@@ -145,24 +157,24 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
145
157
  after { remove_package }
146
158
 
147
159
  it "upgrades to a specific version" do
148
- subject.version "1.0"
160
+ subject.version "1.0.0"
149
161
  subject.run_action(:install)
150
- expect(package_list.call).to eq("#{package_name}|1.0")
162
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
151
163
 
152
- subject.version "1.5"
164
+ subject.version "1.5.0"
153
165
  subject.run_action(:upgrade)
154
- expect(package_list.call).to eq("#{package_name}|1.5")
166
+ expect(package_list.call).to match(/^#{package_name}|1.5.0$/)
155
167
  end
156
168
 
157
169
  it "upgrades to the latest version if no version given" do
158
- subject.version "1.0"
170
+ subject.version "1.0.0"
159
171
  subject.run_action(:install)
160
- expect(package_list.call).to eq("#{package_name}|1.0")
172
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
161
173
 
162
174
  subject2 = Chef::Resource::ChocolateyPackage.new("test-A", run_context)
163
175
  subject2.source package_source
164
176
  subject2.run_action(:upgrade)
165
- expect(package_list.call).to eq("#{package_name}|2.0")
177
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
166
178
  end
167
179
  end
168
180
 
@@ -170,7 +182,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
170
182
  it "removes an installed package" do
171
183
  subject.run_action(:install)
172
184
  remove_package
173
- expect(package_list.call).to eq("")
185
+ expect(package_list.call).to match(/0 packages installed/)
174
186
  end
175
187
  end
176
188
 
@@ -38,12 +38,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
38
38
  expect(resource.domain).to eq("NSGlobalDomain")
39
39
  end
40
40
 
41
- it "nil for the host property" do
42
- expect(resource.host).to be_nil
41
+ it ":all for the host property" do
42
+ expect(resource.host).to eq(:all)
43
43
  end
44
44
 
45
- it "nil for the user property" do
46
- expect(resource.user).to be_nil
45
+ it ":current for the user property" do
46
+ expect(resource.user).to eq(:current)
47
47
  end
48
48
 
49
49
  it ":write for resource action" do
@@ -20,7 +20,7 @@ require "chef/mixin/shell_out"
20
20
 
21
21
  # run this test only for following platforms.
22
22
  exclude_test = !(%w{rhel fedora amazon}.include?(OHAI_SYSTEM[:platform_family]) && !File.exist?("/usr/bin/dnf"))
23
- describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
23
+ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not_rhel6: true do
24
24
  include RecipeDSLHelper
25
25
  include Chef::Mixin::ShellOut
26
26
 
@@ -177,6 +177,15 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
177
177
  expect(zypper_package.updated_by_last_action?).to be true
178
178
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
179
179
  end
180
+
181
+ context "Package doesn't exist" do
182
+ let(:package_name) { "nonexistent_repo" }
183
+ it "does nothing if the package is not installed" do
184
+ zypper_package.run_action(:remove)
185
+ expect(zypper_package.updated_by_last_action?).to be false
186
+ end
187
+
188
+ end
180
189
  end
181
190
 
182
191
  context "with no available version" do
@@ -247,6 +256,7 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
247
256
  expect(shell_out("zypper locks | grep chef_rpm_provides").stdout.chomp).not_to match("chef_rpm_provides")
248
257
  end
249
258
  end
259
+
250
260
  def remove_package
251
261
  pkg_to_remove = Chef::Resource::ZypperPackage.new(package_name, run_context)
252
262
  pkg_to_remove.run_action(:remove)
@@ -313,9 +313,9 @@ describe Chef::Client do
313
313
  stub_const("Chef::VERSION", 15)
314
314
  # added a call to client because Time.now gets invoked multiple times during instantiation. Don't mock Time until after client initialized
315
315
  client
316
- expect(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5))
316
+ expect(Time).to receive(:now).and_return(Time.new(2024, 12, 1, 5))
317
317
  allow(client).to receive(:eol_override).and_return(false)
318
- expect(logger).to receive(:warn).with("This release of Chef Infra Client became end of life (EOL) on May 01, 2021. Please update to a supported release to receive new features, bug fixes, and security updates.")
318
+ expect(logger).to receive(:warn).with("This release of Chef Infra Client became end of life (EOL) on Nov 30, 2024. Please update to a supported release to receive new features, bug fixes, and security updates.")
319
319
  client.warn_if_eol
320
320
  end
321
321
 
@@ -170,7 +170,7 @@ describe Chef::Compliance::Reporter::ChefServerAutomate do
170
170
  "X-Ops-Userid" => "spec-node",
171
171
  "X-Remote-Request-Id" => /.+/,
172
172
  }
173
- ).to_return(status: 200)
173
+ ).to_return(status: 200, body: "OK")
174
174
 
175
175
  expect(reporter.send_report(inspec_report)).to eq(true)
176
176
 
@@ -47,6 +47,8 @@ describe Chef::Mixin::HomebrewUser do
47
47
  let(:user) { nil }
48
48
  let(:brew_owner) { 2001 }
49
49
  let(:default_brew_path) { "/usr/local/bin/brew" }
50
+ let(:default_brew_path_arm) { "/opt/homebrew/bin/brew" }
51
+ let(:default_brew_path_linux) { "/home/linuxbrew/.linuxbrew/bin/brew" }
50
52
  let(:stat_double) do
51
53
  d = double
52
54
  expect(d).to receive(:uid).and_return(brew_owner)
@@ -59,16 +61,38 @@ describe Chef::Mixin::HomebrewUser do
59
61
  expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(name: "name"))
60
62
  end
61
63
 
62
- it "returns the owner of the brew executable when it is at a default location" do
63
- expect(File).to receive(:exist?).with(default_brew_path).and_return(true)
64
- expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double)
64
+ def false_unless_specific_value(object, method, value)
65
+ allow(object).to receive(method).and_return(false)
66
+ allow(object).to receive(method).with(value).and_return(true)
67
+ end
68
+
69
+ it "returns the owner of the brew executable when it is at a default location for x86_64 machines" do
70
+ false_unless_specific_value(File, :exist?, default_brew_path)
71
+ false_unless_specific_value(File, :executable?, default_brew_path)
72
+ allow(File).to receive(:stat).with(default_brew_path).and_return(stat_double)
73
+ expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
74
+ end
75
+
76
+ it "returns the owner of the brew executable when it is at a default location for arm machines" do
77
+ false_unless_specific_value(File, :exist?, default_brew_path_arm)
78
+ false_unless_specific_value(File, :executable?, default_brew_path_arm)
79
+ allow(File).to receive(:stat).with(default_brew_path_arm).and_return(stat_double)
80
+ expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
81
+ end
82
+
83
+ it "returns the owner of the brew executable when it is at a default location for linux machines" do
84
+ false_unless_specific_value(File, :exist?, default_brew_path_linux)
85
+ false_unless_specific_value(File, :executable?, default_brew_path_linux)
86
+ allow(File).to receive(:stat).with(default_brew_path_linux).and_return(stat_double)
65
87
  expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
66
88
  end
67
89
 
68
90
  it "returns the owner of the brew executable when it is not at a default location" do
69
- expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
91
+ allow_any_instance_of(ExampleHomebrewUser).to receive(:which).and_return("/foo")
92
+ false_unless_specific_value(File, :exist?, "/foo")
93
+ false_unless_specific_value(File, :executable?, "/foo")
70
94
  allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("/foo")
71
- expect(File).to receive(:stat).with("/foo").and_return(stat_double)
95
+ allow(File).to receive(:stat).with("/foo").and_return(stat_double)
72
96
  expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
73
97
  end
74
98
 
@@ -78,8 +102,7 @@ describe Chef::Mixin::HomebrewUser do
78
102
  describe "when the homebrew user is not provided" do
79
103
 
80
104
  it "raises an error if no executable is found" do
81
- expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
82
- allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("")
105
+ expect(File).to receive(:exist?).and_return(nil).at_least(:once)
83
106
  expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner)
84
107
  end
85
108
 
@@ -49,6 +49,10 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
49
49
  allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0, 2], timeout: timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
+ after(:each) do
53
+ described_class.instance_variable_set(:@get_choco_version, nil)
54
+ end
55
+
52
56
  def allow_remote_list(package_names, args = nil)
53
57
  remote_list_stdout = <<~EOF
54
58
  Chocolatey v0.9.9.11
@@ -61,9 +65,9 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
61
65
  remote_list_obj = double(stdout: remote_list_stdout)
62
66
  package_names.each do |pkg|
63
67
  if args
64
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
68
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
65
69
  else
66
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
70
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
67
71
  end
68
72
  end
69
73
  end
@@ -78,6 +82,18 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
78
82
  end
79
83
  end
80
84
 
85
+ describe "choco searches change with the version" do
86
+ it "Choco V1 uses List" do
87
+ allow(described_class).to receive(:get_choco_version).and_return("1.4.0")
88
+ expect(provider.query_command).to eql("list")
89
+ end
90
+
91
+ it "Choco V2 uses Search" do
92
+ allow(described_class).to receive(:get_choco_version).and_return("2.1.0")
93
+ expect(provider.query_command).to eql("search")
94
+ end
95
+ end
96
+
81
97
  describe "#candidate_version" do
82
98
  it "should set the candidate_version to the latest version when not pinning" do
83
99
  allow_remote_list(["git"])
@@ -150,7 +166,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
150
166
  new_resource.package_name("package-does-not-exist")
151
167
  new_resource.returns([0])
152
168
  allow(provider).to receive(:shell_out_compacted!)
153
- .with(choco_exe, "list", "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
169
+ .with(choco_exe, described_class.query_command, "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
154
170
  .and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
155
171
  expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
156
172
  end
@@ -70,4 +70,59 @@ describe Chef::Provider::User::Linux do
70
70
  expect( provider.useradd_options ).to eql(["-m"])
71
71
  end
72
72
  end
73
+
74
+ describe "compare_user_linux" do
75
+ before(:each) do
76
+ @new_resource = Chef::Resource::User::LinuxUser.new("notarealuser")
77
+ @current_resource = Chef::Resource::User::LinuxUser.new("notarealuser")
78
+ end
79
+
80
+ let(:mapping) do
81
+ {
82
+ "username" => %w{notarealuser notarealuser},
83
+ "comment" => ["Nota Realuser", "Not a Realuser"],
84
+ "uid" => [1000, 1001],
85
+ "gid" => [1000, 1001],
86
+ "home" => ["/home/notarealuser", "/Users/notarealuser"],
87
+ "shell" => ["/usr/bin/zsh", "/bin/bash"],
88
+ "password" => %w{abcd 12345},
89
+ "sensitive" => [true],
90
+ }
91
+ end
92
+
93
+ %w{uid gid comment home shell password}.each do |property|
94
+ it "should return true if #{property} doesn't match" do
95
+ @new_resource.send(property, mapping[property][0])
96
+ @current_resource.send(property, mapping[property][1])
97
+ expect(provider.compare_user).to eql(true)
98
+ end
99
+ end
100
+
101
+ it "should show a blank for password if sensitive set to true" do
102
+ @new_resource.password mapping["password"][0]
103
+ @current_resource.password mapping["password"][1]
104
+ @new_resource.sensitive true
105
+ @current_resource.sensitive true
106
+ provider.compare_user
107
+ expect(provider.change_desc).to eql(["change password from ******** to ********"])
108
+ end
109
+
110
+ %w{uid gid}.each do |property|
111
+ it "should return false if string #{property} matches fixnum" do
112
+ @new_resource.send(property, "100")
113
+ @current_resource.send(property, 100)
114
+ expect(provider.compare_user).to eql(false)
115
+ end
116
+ end
117
+
118
+ it "should return false if the objects are identical" do
119
+ expect(provider.compare_user).to eql(false)
120
+ end
121
+
122
+ it "should ignore differences in trailing slash in home paths" do
123
+ @new_resource.home "/home/notarealuser"
124
+ @current_resource.home "/home/notarealuser/"
125
+ expect(provider.compare_user).to eql(false)
126
+ end
127
+ end
73
128
  end
@@ -102,7 +102,7 @@ describe Chef::Resource::ChefClientSystemdTimer do
102
102
 
103
103
  it "sets CPUQuota if cpu_quota property is set" do
104
104
  resource.cpu_quota 50
105
- expect(provider.service_content["Service"]["CPUQuota"]).to eq(50)
105
+ expect(provider.service_content["Service"]["CPUQuota"]).to eq("50%")
106
106
  end
107
107
  end
108
108
  end
@@ -39,12 +39,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
39
39
  expect(resource.domain).to eq("NSGlobalDomain")
40
40
  end
41
41
 
42
- it "nil for the host property" do
43
- expect(resource.host).to be_nil
42
+ it ":all for the host property" do
43
+ expect(resource.host).to eq(:all)
44
44
  end
45
45
 
46
- it "nil for the user property" do
47
- expect(resource.user).to be_nil
46
+ it ":current for the user property" do
47
+ expect(resource.user).to eq(:current)
48
48
  end
49
49
 
50
50
  it ":write for resource action" do
@@ -371,6 +371,9 @@ describe Chef::Resource do
371
371
  end
372
372
 
373
373
  describe "to_text" do
374
+
375
+ let(:sensitive_property_masked_value) { "sensitive value suppressed" }
376
+
374
377
  it "prints nice message" do
375
378
  resource_class = Class.new(Chef::Resource) { property :foo, String }
376
379
  resource = resource_class.new("sensitive_property_tests")
@@ -383,7 +386,25 @@ describe Chef::Resource do
383
386
  resource_class = Class.new(Chef::Resource) { property :foo, String, sensitive: true }
384
387
  resource = resource_class.new("sensitive_property_tests")
385
388
  resource.foo = "some value"
386
- expect(resource.to_text).to match(/foo "\*sensitive value suppressed\*"/)
389
+ expect(resource.to_text).to match(/foo "\*#{sensitive_property_masked_value}\*"/)
390
+ end
391
+
392
+ it "suppresses that properties value irrespective of desired state (false) " do
393
+ resource_class = Class.new(Chef::Resource) {
394
+ property :suppressed_content, String, sensitive: true, desired_state: false
395
+ }
396
+ resource = resource_class.new("desired_state_property_tests")
397
+ resource.suppressed_content = "some value"
398
+ expect(resource.to_text).to match(/suppressed_content "\*#{sensitive_property_masked_value}\*"/)
399
+ end
400
+
401
+ it "suppresses that properties value irrespective of desired state (true) " do
402
+ resource_class = Class.new(Chef::Resource) {
403
+ property :desired_state_content, String, sensitive: true, desired_state: true
404
+ }
405
+ resource = resource_class.new("desired_state_property_tests")
406
+ resource.desired_state_content = "some value"
407
+ expect(resource.to_text).to match(/desired_state_content "\*#{sensitive_property_masked_value}\*"/)
387
408
  end
388
409
  end
389
410
 
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: 17.10.68
4
+ version: 17.10.114
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: 2023-05-17 00:00:00.000000000 Z
11
+ date: 2024-01-17 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: 17.10.68
19
+ version: 17.10.114
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: 17.10.68
26
+ version: 17.10.114
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: 17.10.68
33
+ version: 17.10.114
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: 17.10.68
40
+ version: 17.10.114
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -204,44 +204,50 @@ dependencies:
204
204
  name: inspec-core
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">="
207
+ - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: '4.23'
209
+ version: 5.22.36
210
210
  type: :runtime
211
211
  prerelease: false
212
212
  version_requirements: !ruby/object:Gem::Requirement
213
213
  requirements:
214
- - - ">="
214
+ - - "~>"
215
215
  - !ruby/object:Gem::Version
216
- version: '4.23'
216
+ version: 5.22.36
217
217
  - !ruby/object:Gem::Dependency
218
218
  name: ffi
219
219
  requirement: !ruby/object:Gem::Requirement
220
220
  requirements:
221
- - - ">="
221
+ - - "~>"
222
222
  - !ruby/object:Gem::Version
223
- version: 1.5.0
223
+ version: 1.15.5
224
224
  type: :runtime
225
225
  prerelease: false
226
226
  version_requirements: !ruby/object:Gem::Requirement
227
227
  requirements:
228
- - - ">="
228
+ - - "~>"
229
229
  - !ruby/object:Gem::Version
230
- version: 1.5.0
230
+ version: 1.15.5
231
231
  - !ruby/object:Gem::Dependency
232
232
  name: ffi-yajl
233
233
  requirement: !ruby/object:Gem::Requirement
234
234
  requirements:
235
- - - "~>"
235
+ - - ">="
236
236
  - !ruby/object:Gem::Version
237
237
  version: '2.2'
238
+ - - "<"
239
+ - !ruby/object:Gem::Version
240
+ version: '4.0'
238
241
  type: :runtime
239
242
  prerelease: false
240
243
  version_requirements: !ruby/object:Gem::Requirement
241
244
  requirements:
242
- - - "~>"
245
+ - - ">="
243
246
  - !ruby/object:Gem::Version
244
247
  version: '2.2'
248
+ - - "<"
249
+ - !ruby/object:Gem::Version
250
+ version: '4.0'
245
251
  - !ruby/object:Gem::Dependency
246
252
  name: net-sftp
247
253
  requirement: !ruby/object:Gem::Requirement
@@ -601,33 +607,47 @@ dependencies:
601
607
  - !ruby/object:Gem::Version
602
608
  version: '3.0'
603
609
  - !ruby/object:Gem::Dependency
604
- name: wmi-lite
610
+ name: win32-taskscheduler
605
611
  requirement: !ruby/object:Gem::Requirement
606
612
  requirements:
607
613
  - - "~>"
608
614
  - !ruby/object:Gem::Version
609
- version: '1.0'
615
+ version: '2.0'
610
616
  type: :runtime
611
617
  prerelease: false
612
618
  version_requirements: !ruby/object:Gem::Requirement
613
619
  requirements:
614
620
  - - "~>"
615
621
  - !ruby/object:Gem::Version
616
- version: '1.0'
622
+ version: '2.0'
617
623
  - !ruby/object:Gem::Dependency
618
- name: win32-taskscheduler
624
+ name: win32-certstore
619
625
  requirement: !ruby/object:Gem::Requirement
620
626
  requirements:
621
627
  - - "~>"
622
628
  - !ruby/object:Gem::Version
623
- version: '2.0'
629
+ version: 0.6.15
624
630
  type: :runtime
625
631
  prerelease: false
626
632
  version_requirements: !ruby/object:Gem::Requirement
627
633
  requirements:
628
634
  - - "~>"
629
635
  - !ruby/object:Gem::Version
630
- version: '2.0'
636
+ version: 0.6.15
637
+ - !ruby/object:Gem::Dependency
638
+ name: wmi-lite
639
+ requirement: !ruby/object:Gem::Requirement
640
+ requirements:
641
+ - - "~>"
642
+ - !ruby/object:Gem::Version
643
+ version: '1.0'
644
+ type: :runtime
645
+ prerelease: false
646
+ version_requirements: !ruby/object:Gem::Requirement
647
+ requirements:
648
+ - - "~>"
649
+ - !ruby/object:Gem::Version
650
+ version: '1.0'
631
651
  - !ruby/object:Gem::Dependency
632
652
  name: iso8601
633
653
  requirement: !ruby/object:Gem::Requirement
@@ -648,20 +668,6 @@ dependencies:
648
668
  - - "<"
649
669
  - !ruby/object:Gem::Version
650
670
  version: '0.14'
651
- - !ruby/object:Gem::Dependency
652
- name: win32-certstore
653
- requirement: !ruby/object:Gem::Requirement
654
- requirements:
655
- - - "~>"
656
- - !ruby/object:Gem::Version
657
- version: 0.6.14
658
- type: :runtime
659
- prerelease: false
660
- version_requirements: !ruby/object:Gem::Requirement
661
- requirements:
662
- - - "~>"
663
- - !ruby/object:Gem::Version
664
- version: 0.6.14
665
671
  - !ruby/object:Gem::Dependency
666
672
  name: chef-powershell
667
673
  requirement: !ruby/object:Gem::Requirement
@@ -2450,10 +2456,10 @@ files:
2450
2456
  - spec/functional/assets/PkgA.1.0.0.0.bff
2451
2457
  - spec/functional/assets/PkgA.2.0.0.0.bff
2452
2458
  - spec/functional/assets/chefinittest
2453
- - spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg
2454
- - spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
2455
- - spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg
2456
- - spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg
2459
+ - spec/functional/assets/chocolatey_feed/test-A.1.0.0.nupkg
2460
+ - spec/functional/assets/chocolatey_feed/test-A.1.5.0.nupkg
2461
+ - spec/functional/assets/chocolatey_feed/test-A.2.0.0.nupkg
2462
+ - spec/functional/assets/chocolatey_feed/test-B.1.0.0.nupkg
2457
2463
  - spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
2458
2464
  - spec/functional/assets/dummy-2-0.aix6.1.noarch.rpm
2459
2465
  - spec/functional/assets/inittest