summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md16
-rw-r--r--Gemfile.lock14
-rw-r--r--VERSION2
-rwxr-xr-xbin/chef-resource-inspector26
-rw-r--r--chef-config/lib/chef-config/config.rb4
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/application/client.rb10
-rw-r--r--lib/chef/application/solo.rb10
-rw-r--r--lib/chef/config.rb3
-rw-r--r--lib/chef/dsl/reboot_pending.rb9
-rw-r--r--lib/chef/mixin/from_file.rb5
-rw-r--r--lib/chef/platform/query_helpers.rb12
-rw-r--r--lib/chef/policy_builder/policyfile.rb10
-rw-r--r--lib/chef/provider.rb41
-rw-r--r--lib/chef/provider/apt_repository.rb12
-rw-r--r--lib/chef/provider/package/portage.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb1
-rw-r--r--lib/chef/resource/build_essential.rb7
-rw-r--r--lib/chef/resource/chef_gem.rb2
-rw-r--r--lib/chef/resource/file.rb6
-rw-r--r--lib/chef/resource/gem_package.rb2
-rw-r--r--lib/chef/resource/hostname.rb15
-rw-r--r--lib/chef/resource/ips_package.rb2
-rw-r--r--lib/chef/resource/macos_userdefaults.rb27
-rw-r--r--lib/chef/resource/macosx_service.rb2
-rw-r--r--lib/chef/resource/macports_package.rb3
-rw-r--r--lib/chef/resource/mdadm.rb9
-rw-r--r--lib/chef/resource/ohai.rb6
-rw-r--r--lib/chef/resource/ohai_hint.rb12
-rw-r--r--lib/chef/resource/openssl_rsa_private_key.rb4
-rw-r--r--lib/chef/resource/osx_profile.rb15
-rw-r--r--lib/chef/resource/portage_package.rb10
-rw-r--r--lib/chef/resource/registry_key.rb28
-rw-r--r--lib/chef/resource/rhsm_errata.rb3
-rw-r--r--lib/chef/resource/rhsm_errata_level.rb3
-rw-r--r--lib/chef/resource/rhsm_register.rb24
-rw-r--r--lib/chef/resource/rhsm_repo.rb3
-rw-r--r--lib/chef/resource/rhsm_subscription.rb3
-rw-r--r--lib/chef/resource/windows_env.rb2
-rw-r--r--lib/chef/resource/windows_feature.rb7
-rw-r--r--lib/chef/resource/windows_feature_dism.rb4
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb6
-rw-r--r--lib/chef/resource/windows_pagefile.rb6
-rw-r--r--lib/chef/resource/windows_printer.rb7
-rw-r--r--lib/chef/resource/windows_printer_port.rb4
-rw-r--r--lib/chef/resource/windows_service.rb4
-rw-r--r--lib/chef/resource/zypper_package.rb2
-rw-r--r--lib/chef/resource/zypper_repository.rb12
-rw-r--r--lib/chef/resource_inspector.rb89
-rw-r--r--lib/chef/version.rb2
-rw-r--r--lib/chef/win32/eventlog.rb2
-rw-r--r--lib/chef/win32/security.rb40
-rw-r--r--lib/chef/win32/security/sid.rb3
-rw-r--r--lib/chef/win32/version.rb17
-rw-r--r--spec/data/mixin/invalid_data.rb3
-rw-r--r--spec/data/mixin/real_data.rb2
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb4
-rw-r--r--spec/functional/mixin/from_file_spec.rb82
-rw-r--r--spec/functional/resource/link_spec.rb8
-rw-r--r--spec/functional/resource/powershell_script_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb1
-rw-r--r--spec/functional/win32/versions_spec.rb16
-rw-r--r--spec/integration/client/client_spec.rb100
-rw-r--r--spec/integration/recipes/resource_action_spec.rb95
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/platform_helpers.rb5
-rw-r--r--spec/support/shared/functional/file_resource.rb2
-rw-r--r--spec/unit/application/client_spec.rb50
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb13
-rw-r--r--spec/unit/platform/query_helpers_spec.rb13
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb76
-rw-r--r--spec/unit/provider/apt_repository_spec.rb12
-rw-r--r--spec/unit/provider/link_spec.rb2
-rw-r--r--spec/unit/provider/remote_directory_spec.rb2
-rw-r--r--spec/unit/resource/portage_package_spec.rb6
-rw-r--r--spec/unit/resource/registry_key_spec.rb6
-rw-r--r--spec/unit/resource_inspector_spec.rb60
-rw-r--r--spec/unit/win32/security_spec.rb8
78 files changed, 686 insertions, 456 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 35771006b5..4240821c07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,25 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
-<!-- latest_release 14.0.108 -->
-## [v14.0.108](https://github.com/chef/chef/tree/v14.0.108) (2018-03-05)
+<!-- latest_release 14.0.118 -->
+## [v14.0.118](https://github.com/chef/chef/tree/v14.0.118) (2018-03-06)
#### Merged Pull Requests
-- Set properties in git resource using our resource DSL [#6902](https://github.com/chef/chef/pull/6902) ([tas50](https://github.com/tas50))
+- remove deprecated property namespace collisions [#6952](https://github.com/chef/chef/pull/6952) ([lamont-granquist](https://github.com/lamont-granquist))
<!-- latest_release -->
<!-- release_rollup since=13.7.16 -->
### Changes since 13.7.16 release
#### Merged Pull Requests
+- remove deprecated property namespace collisions [#6952](https://github.com/chef/chef/pull/6952) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.0.118 -->
+- Added source_file to FromFile [#6938](https://github.com/chef/chef/pull/6938) ([zfjagann](https://github.com/zfjagann)) <!-- 14.0.117 -->
+- Avoid compile time error in apt_repository [#6953](https://github.com/chef/chef/pull/6953) ([tas50](https://github.com/tas50)) <!-- 14.0.116 -->
+- Remove support for Windows 2003 [#6923](https://github.com/chef/chef/pull/6923) ([tas50](https://github.com/tas50)) <!-- 14.0.115 -->
+- add a utility to dump info about resources [#6896](https://github.com/chef/chef/pull/6896) ([thommay](https://github.com/thommay)) <!-- 14.0.114 -->
+- Don&#39;t use supervisor process for one-shot / command-line runs [#6914](https://github.com/chef/chef/pull/6914) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.0.113 -->
+- Add attribute hoisting into core [#6927](https://github.com/chef/chef/pull/6927) ([jonlives](https://github.com/jonlives)) <!-- 14.0.112 -->
+- Add more description fields, style fixes, add missing requires [#6943](https://github.com/chef/chef/pull/6943) ([tas50](https://github.com/tas50)) <!-- 14.0.111 -->
+- registry_key: Properly limit allowed values for architecture [#6947](https://github.com/chef/chef/pull/6947) ([tas50](https://github.com/tas50)) <!-- 14.0.110 -->
+- Modernize provides in the portage_package resource [#6903](https://github.com/chef/chef/pull/6903) ([tas50](https://github.com/tas50)) <!-- 14.0.109 -->
- Set properties in git resource using our resource DSL [#6902](https://github.com/chef/chef/pull/6902) ([tas50](https://github.com/tas50)) <!-- 14.0.108 -->
- Use the existing helper method for package resource classes that don&#39;t support allow_downgrade [#6942](https://github.com/chef/chef/pull/6942) ([coderanger](https://github.com/coderanger)) <!-- 14.0.107 -->
- Apt repo cleanup and testing expansion [#6498](https://github.com/chef/chef/pull/6498) ([tas50](https://github.com/tas50)) <!-- 14.0.106 -->
diff --git a/Gemfile.lock b/Gemfile.lock
index 2e2c2b71ae..b7449c117b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -8,10 +8,10 @@ GIT
GIT
remote: https://github.com/chef/ohai.git
- revision: 159c9046b14e86969d1e2373c4e28cb67ef3bc08
+ revision: 3627eb769d3dd25098cf0cb34a4090c2e2e0b0df
branch: master
specs:
- ohai (14.0.21)
+ ohai (14.0.22)
chef-config (>= 12.8, < 15)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
@@ -27,10 +27,10 @@ GIT
PATH
remote: .
specs:
- chef (14.0.108)
+ chef (14.0.118)
addressable
bundler (>= 1.10)
- chef-config (= 14.0.108)
+ chef-config (= 14.0.118)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -57,10 +57,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (14.0.108-universal-mingw32)
+ chef (14.0.118-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 14.0.108)
+ chef-config (= 14.0.118)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -102,7 +102,7 @@ PATH
PATH
remote: chef-config
specs:
- chef-config (14.0.108)
+ chef-config (14.0.118)
addressable
fuzzyurl
mixlib-config (~> 2.0)
diff --git a/VERSION b/VERSION
index cb8ce5177b..7407529436 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.0.108 \ No newline at end of file
+14.0.118 \ No newline at end of file
diff --git a/bin/chef-resource-inspector b/bin/chef-resource-inspector
new file mode 100755
index 0000000000..6a7eac0c32
--- /dev/null
+++ b/bin/chef-resource-inspector
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# ./chef-resource-inspector - Find information about a resource
+#
+# Copyright:: Copyright (c) 2018, Chef Software, Inc
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Encoding.default_external = Encoding::UTF_8
+
+$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+
+require "chef/resource_inspector"
+
+ResourceInspector.start
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index d5badcc58f..9d11ba9dc4 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -4,7 +4,7 @@
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (<mmzyk@chef.io>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -440,7 +440,7 @@ module ChefConfig
default :splay, nil
default :why_run, false
default :color, false
- default :client_fork, true
+ default :client_fork, nil
default :ez, false
default :enable_reporting, true
default :enable_reporting_url_fatals, false
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 7fba40a798..b84975edca 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "14.0.108"
+ VERSION = "14.0.118"
end
#
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 0834e5f037..706ba93ca0 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -2,7 +2,7 @@
# Author:: AJ Christensen (<aj@chef.io)
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -228,8 +228,7 @@ class Chef::Application::Client < Chef::Application
option :client_fork,
:short => "-f",
:long => "--[no-]fork",
- :description => "Fork client",
- :boolean => true
+ :description => "Fork client"
option :recipe_url,
:long => "--recipe-url=RECIPE_URL",
@@ -362,6 +361,11 @@ class Chef::Application::Client < Chef::Application
Chef::Config[:splay] = nil
end
+ # supervisor processes are enabled by default for interval-running processes but not for one-shot runs
+ if Chef::Config[:client_fork].nil?
+ Chef::Config[:client_fork] = !!Chef::Config[:interval]
+ end
+
if !Chef::Config[:client_fork] && Chef::Config[:interval] && !Chef::Platform.windows?
Chef::Application.fatal!(unforked_interval_error_message)
end
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 6b4aef42b4..f8502edc38 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2018, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -175,8 +175,7 @@ class Chef::Application::Solo < Chef::Application
option :client_fork,
:short => "-f",
:long => "--[no-]fork",
- :description => "Fork client",
- :boolean => true
+ :description => "Fork client"
option :why_run,
:short => "-W",
@@ -261,6 +260,11 @@ class Chef::Application::Solo < Chef::Application
Chef::Config[:interval] ||= 1800
end
+ # supervisor processes are enabled by default for interval-running processes but not for one-shot runs
+ if Chef::Config[:client_fork].nil?
+ Chef::Config[:client_fork] = !!Chef::Config[:interval]
+ end
+
Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
if Chef::Config[:recipe_url]
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 549872bfd7..f5466ae145 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -55,8 +55,7 @@ class Chef
default :event_loggers do
evt_loggers = []
- if ChefConfig.windows? && !(Chef::Platform.windows_server_2003? ||
- Chef::Platform.windows_nano_server?)
+ if ChefConfig.windows? && !Chef::Platform.windows_nano_server?
evt_loggers << :win_evt
end
evt_loggers
diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb
index fdd0f5a62b..2ebad7e039 100644
--- a/lib/chef/dsl/reboot_pending.rb
+++ b/lib/chef/dsl/reboot_pending.rb
@@ -44,14 +44,7 @@ class Chef
registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') ||
# Vista + Server 2008 and newer may have reboots pending from CBS
- registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') ||
-
- # The mere existence of the UpdateExeVolatile key should indicate a pending restart for certain updates
- # http://support.microsoft.com/kb/832475
- Chef::Platform.windows_server_2003? &&
- (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
- !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? &&
- [1, 2, 3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data]))
+ registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending')
elsif platform?("ubuntu")
# This should work for Debian as well if update-notifier-common happens to be installed. We need an API for that.
File.exists?("/var/run/reboot-required")
diff --git a/lib/chef/mixin/from_file.rb b/lib/chef/mixin/from_file.rb
index 4afea5d9f4..e19597dde8 100644
--- a/lib/chef/mixin/from_file.rb
+++ b/lib/chef/mixin/from_file.rb
@@ -21,11 +21,15 @@ class Chef
module Mixin
module FromFile
+ # Source path from which the object was loaded
+ attr_accessor :source_file
+
# Loads a given ruby file, and runs instance_eval against it in the context of the current
# object.
#
# Raises an IOError if the file cannot be found, or is not readable.
def from_file(filename)
+ self.source_file = filename
if File.exists?(filename) && File.readable?(filename)
instance_eval(IO.read(filename), filename, 1)
else
@@ -38,6 +42,7 @@ class Chef
#
# Raises an IOError if the file cannot be found, or is not readable.
def class_from_file(filename)
+ self.source_file = filename
if File.exists?(filename) && File.readable?(filename)
class_eval(IO.read(filename), filename, 1)
else
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb
index 624dc05e9c..b49010efc0 100644
--- a/lib/chef/platform/query_helpers.rb
+++ b/lib/chef/platform/query_helpers.rb
@@ -24,18 +24,6 @@ class Chef
ChefConfig.windows?
end
- def windows_server_2003?
- # WMI startup shouldn't be performed unless we're on Windows.
- return false unless windows?
- require "wmi-lite/wmi"
-
- wmi = WmiLite::Wmi.new
- host = wmi.first_of("Win32_OperatingSystem")
- is_server_2003 = (host["version"] && host["version"].start_with?("5.2"))
-
- is_server_2003
- end
-
def windows_nano_server?
return false unless windows?
require "win32/registry"
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index 545d36cb0e..e1293190f8 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -263,6 +263,16 @@ class Chef
def apply_policyfile_attributes
node.attributes.role_default = policy["default_attributes"]
node.attributes.role_override = policy["override_attributes"]
+ hoist_policyfile_attributes(node.policy_group) if node.policy_group
+ end
+
+ # @api private
+ #
+ # Hoists attributes from role_X[policy_group] up to the equivalent role_X level
+ def hoist_policyfile_attributes(policy_group)
+ Chef::Log.debug("Running attribute Hoist for group #{policy_group}")
+ Chef::Mixin::DeepMerge.hash_only_merge!(node.role_default, node.role_default[policy_group]) if node.role_default.include?(policy_group)
+ Chef::Mixin::DeepMerge.hash_only_merge!(node.role_override, node.role_override[policy_group]) if node.role_override.include?(policy_group)
end
# @api private
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 7cb2301772..6971465b0a 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -342,45 +342,16 @@ class Chef
extend Forwardable
define_singleton_method(:to_s) { "forwarder module for #{provider_class}" }
define_singleton_method(:inspect) { to_s }
- # Add a delegator for each explicit property that will get the *current* value
- # of the property by default instead of the *actual* value.
- resource.class.properties.each_key do |name|
- class_eval(<<-EOM, __FILE__, __LINE__)
- def #{name}(*args, &block)
- # If no arguments were passed, we process "get" by defaulting
- # the value to current_resource, not new_resource. This helps
- # avoid issues where resources accidentally overwrite perfectly
- # valid stuff with default values.
- #
- # This magic is to make this kind of thing easy:
- #
- # FileUtils.chown new_resource.mode.nil? ? current_resource.mode : new_resource.mode, new_resource.path
- #
- # We do this in the file provider where we need to construct a new filesystem object and
- # when the new_resource is nil/default that means "preserve the current stuff" and does not
- # mean to ignore it which will wind up defaulting to changing the file to have a "root"
- # ownership if anything else changes. Its kind of overly clever and magical, and most likely
- # gets the use case wrong where someone has a property that they really mean to default to
- # some value which /should/ get set if its left as the default and where the default is
- # meant to be declarative. Instead of property_is_set? we should most likely be using
- # nil? but we're going to deprecate all of it anyway. Just type out what you really mean longhand.
- #
- if args.empty? && !block
- if !new_resource.property_is_set?(__method__) && current_resource
- Chef.deprecated(:namespace_collisions, "rename #{name} to current_resource.#{name}")
- return current_resource.public_send(__method__)
- end
- end
- Chef.deprecated(:namespace_collisions, "rename #{name} to new_resource.#{name}")
- new_resource.public_send(__method__, *args, &block)
- end
- EOM
- end
+ # this magic, stated simply, is that any instance method declared directly on
+ # the resource we are building, will be accessible from the action_class(provider)
+ # instance. methods declared on Chef::Resource and properties are not inherited.
dsl_methods =
resource.class.public_instance_methods +
resource.class.protected_instance_methods -
provider_class.instance_methods -
- resource.class.properties.keys
+ resource.class.properties.keys -
+ resource.class.properties.keys.map { |k| "#{k}=".to_sym } -
+ Chef::Resource.instance_methods
def_delegators(:new_resource, *dsl_methods)
end
include @included_resource_dsl_module
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index 1909ed8034..6bbb052792 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -119,15 +119,6 @@ class Chef
end.compact
end
- # see if the keyfile is invalid such as a text file that is not actually a gpg key
- # @param [String] keyfile the path to the keyfile
- #
- # @return [Boolean] is the key file invalid
- def keyfile_is_invalid?(keyfile)
- so = shell_out("gpg #{keyfile}")
- so.error?
- end
-
# validate the key against the apt keystore to see if that version is expired
# @param [String] key
#
@@ -210,10 +201,9 @@ class Chef
mode "0644"
sensitive new_resource.sensitive
action :create
+ verify "gpg %{path}"
end
- raise "The key #{cached_keyfile} is invalid and cannot be used to verify an apt repository." if keyfile_is_invalid?(cached_keyfile)
-
declare_resource(:execute, "apt-key add #{cached_keyfile}") do
sensitive new_resource.sensitive
action :run
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 05a5df370e..e43e71f210 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -17,7 +17,7 @@
#
require "chef/provider/package"
-require "chef/resource/package"
+require "chef/resource/portage_package"
require "chef/util/path_helper"
class Chef
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 9783b3b3a5..2ff7de1138 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -34,6 +34,7 @@ class Chef
UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/
+ # Returns true if the configs for the service name has upstart variable
def self.supports?(resource, action)
Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:upstart)
end
diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb
index 881f932b30..8977444692 100644
--- a/lib/chef/resource/build_essential.rb
+++ b/lib/chef/resource/build_essential.rb
@@ -22,7 +22,12 @@ class Chef
resource_name :build_essential
provides :build_essential
- property :compile_time, [true, false], default: false
+ description "Use the build_essential resource to install packages required for compiling C software from source"
+ introduced "14.0"
+
+ property :compile_time, [TrueClass, FalseClass],
+ description: "Install build essential packages at compile time.",
+ default: false
action :install do
case node["platform_family"]
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index b6bbd0e209..3304690901 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -40,7 +40,7 @@ class Chef
callbacks: {
"The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" },
}
- property :compile_time, [ true, false ], default: false, desired_state: false
+ property :compile_time, [TrueClass, FalseClass], default: false, desired_state: false
# force the resource to compile time if the compile time property has been set
def after_created
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index 98341ff940..341b106720 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -52,13 +52,13 @@ class Chef
allowed_actions :create, :delete, :touch, :create_if_missing
property :path, String, name_property: true, identity: true
- property :atomic_update, [ true, false ], desired_state: false, default: lazy { |r| r.docker? && r.special_docker_files?(r.path) ? false : Chef::Config[:file_atomic_update] }
+ property :atomic_update, [ TrueClass, FalseClass ], desired_state: false, default: lazy { |r| r.docker? && r.special_docker_files?(r.path) ? false : Chef::Config[:file_atomic_update] }
property :backup, [ Integer, false ], desired_state: false, default: 5
property :checksum, [ /^[a-zA-Z0-9]{64}$/, nil ]
property :content, [ String, nil ], desired_state: false
property :diff, [ String, nil ], desired_state: false
- property :force_unlink, [ true, false ], desired_state: false, default: false
- property :manage_symlink_source, [ true, false ], desired_state: false
+ property :force_unlink, [ TrueClass, FalseClass ], desired_state: false, default: false
+ property :manage_symlink_source, [ TrueClass, FalseClass ], desired_state: false
property :verifications, Array, default: lazy { [] }
def verify(command = nil, opts = {}, &block)
diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb
index 1f9bae614d..ee1262cb47 100644
--- a/lib/chef/resource/gem_package.rb
+++ b/lib/chef/resource/gem_package.rb
@@ -40,7 +40,7 @@ class Chef
# FIXME? the array form of installing paths most likely does not work?
#
property :source, [ String, Array ]
- property :clear_sources, [ true, false ], default: false, desired_state: false
+ property :clear_sources, [ TrueClass, FalseClass ], default: false, desired_state: false
# Sets a custom gem_binary to run for gem commands.
property :gem_binary, String, desired_state: false
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb
index 16986c09a3..dfc7ee2ff0 100644
--- a/lib/chef/resource/hostname.rb
+++ b/lib/chef/resource/hostname.rb
@@ -9,28 +9,23 @@ class Chef
description "Sets the systems hostname, ensures that reboot will preserve the hostname, and re-runs the ohai plugin so the hostname will be available in subsequent cookbooks."
introduced "14.0"
- property :hostname,
- String,
+ property :hostname, String,
description: "The hostname if different than the resource's name",
name_property: true
- property :compile_time,
- [ TrueClass, FalseClass ],
+ property :compile_time, [ TrueClass, FalseClass ],
description: "Should the resource run at compile time or not.",
default: true
- property :ipaddress,
- String,
+ property :ipaddress, String,
description: "The ip address to use when configuring the hosts file",
default: lazy { node["ipaddress"] }
- property :aliases,
- [ Array, nil ],
+ property :aliases, [ Array, nil ],
description: "An array of hostname aliases to use when configuring the hosts file",
default: nil
- property :windows_reboot,
- [ TrueClass, FalseClass ],
+ property :windows_reboot, [ TrueClass, FalseClass ],
description: "Should Windows nodes be rebooted upon changing the name so it can take effect",
default: true
diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb
index 88a9f182d4..079cc27231 100644
--- a/lib/chef/resource/ips_package.rb
+++ b/lib/chef/resource/ips_package.rb
@@ -30,7 +30,7 @@ class Chef
allowed_actions :install, :remove, :upgrade
- property :accept_license, [ true, false ], default: false, desired_state: false
+ property :accept_license, [TrueClass, FalseClass], default: false, desired_state: false
end
end
end
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index c0066c84b5..45be356d1b 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -25,50 +25,41 @@ class Chef
provides :mac_os_x_userdefaults
provides :macos_userdefaults
- introduced "14.0"
-
description "Use the macos_userdefaults resource to manage the macOS user defaults"\
" system. The properties to the resource are passed to the defaults command"\
" and the parameters follow convention of the macOS command. See the defaults(1)"\
" man page for details on how the tool works."
+ introduced "14.0"
- property :domain,
- String,
+ property :domain, String,
description: "The domain the defaults belong to.",
required: true
- property :global,
- [true, false],
+ property :global, [TrueClass, FalseClass],
description: "Whether the domain is global.",
default: false
- property :key,
- String,
+ property :key, String,
description: "The preference key."
- property :value,
- [Integer, Float, String, true, false, Hash, Array],
+ property :value, [Integer, Float, String, TrueClass, FalseClass, Hash, Array],
description: "The value of the key.",
coerce: proc { |v| coerce_booleans(v) },
required: true
- property :type,
- String,
+ property :type, String,
description: "Value type of the preference key.",
default: ""
- property :user,
- String,
+ property :user, String,
description: "User for which to set the default."
- property :sudo,
- [true, false],
+ property :sudo, [TrueClass, FalseClass],
description: "Set to true if the setting requires privileged access to modify.",
default: false,
desired_state: false
- property :is_set,
- [true, false],
+ property :is_set, [TrueClass, FalseClass],
description: "",
default: false,
desired_state: false
diff --git a/lib/chef/resource/macosx_service.rb b/lib/chef/resource/macosx_service.rb
index a12add2109..9a88e3bbfc 100644
--- a/lib/chef/resource/macosx_service.rb
+++ b/lib/chef/resource/macosx_service.rb
@@ -25,6 +25,8 @@ class Chef
provides :macosx_service, os: "darwin"
provides :service, os: "darwin"
+ description "Use the macosx_service resource to manage services on the macOS platform."
+
identity_attr :service_name
state_attrs :enabled, :running
diff --git a/lib/chef/resource/macports_package.rb b/lib/chef/resource/macports_package.rb
index e787529f48..254d7e7c5f 100644
--- a/lib/chef/resource/macports_package.rb
+++ b/lib/chef/resource/macports_package.rb
@@ -20,9 +20,10 @@ require "chef/resource/package"
class Chef
class Resource
- # Use the macports_package resource to manage packages for the macOS platform.
class MacportsPackage < Chef::Resource::Package
resource_name :macports_package
+
+ description "Use the macports_package resource to manage packages for the macOS platform."
end
end
end
diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb
index 6d4014b110..c8752ba038 100644
--- a/lib/chef/resource/mdadm.rb
+++ b/lib/chef/resource/mdadm.rb
@@ -21,13 +21,14 @@ require "chef/resource"
class Chef
class Resource
- # Use the mdadm resource to manage RAID devices in a Linux environment using the mdadm utility. The mdadm resource
- # will create and assemble an array, but it will not create the config file that is used to persist the array upon
- # reboot. If the config file is required, it must be done by specifying a template with the correct array layout,
- # and then by using the mount provider to create a file systems table (fstab) entry.
class Mdadm < Chef::Resource
resource_name :mdadm
+ description "Use the mdadm resource to manage RAID devices in a Linux environment using the mdadm utility. The mdadm resource"\
+ " will create and assemble an array, but it will not create the config file that is used to persist the array upon"\
+ " reboot. If the config file is required, it must be done by specifying a template with the correct array layout,"\
+ " and then by using the mount provider to create a file systems table (fstab) entry."
+
default_action :create
allowed_actions :create, :assemble, :stop
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb
index f2534413ea..b506d511ba 100644
--- a/lib/chef/resource/ohai.rb
+++ b/lib/chef/resource/ohai.rb
@@ -19,12 +19,14 @@
class Chef
class Resource
- # Use the ohai resource to reload the Ohai configuration on a node. This allows recipes that change system attributes
- # (like a recipe that adds a user) to refer to those attributes later on during the chef-client run.
class Ohai < Chef::Resource
resource_name :ohai
provides :ohai
+ description "Use the ohai resource to reload the Ohai configuration on a node."\
+ " This allows recipes that change system attributes (like a recipe"\
+ " that adds a user) to refer to those attributes later on during the chef-client run."
+
property :ohai_name, name_property: true
property :plugin, [String]
diff --git a/lib/chef/resource/ohai_hint.rb b/lib/chef/resource/ohai_hint.rb
index 26b76806d7..90755300ca 100644
--- a/lib/chef/resource/ohai_hint.rb
+++ b/lib/chef/resource/ohai_hint.rb
@@ -21,17 +21,15 @@ class Chef
resource_name :ohai_hint
provides :ohai_hint
- description "A resource to pass hint data to Ohai to aid in configuration detection."
+ description "Use the ohai_hint resource to pass hint data to Ohai to aid in configuration detection."
introduced "14.0"
- property :hint_name,
- String,
- description: "The name of hints file if different from the resource name",
+ property :hint_name, String,
+ description: "The name of hints file if different from the resource name.",
name_property: true
- property :content,
- Hash,
- description: "Values to include in the hint file"
+ property :content, Hash,
+ description: "Values to include in the hint file."
property :compile_time,
[TrueClass, FalseClass],
diff --git a/lib/chef/resource/openssl_rsa_private_key.rb b/lib/chef/resource/openssl_rsa_private_key.rb
index 729d5a585a..352d802175 100644
--- a/lib/chef/resource/openssl_rsa_private_key.rb
+++ b/lib/chef/resource/openssl_rsa_private_key.rb
@@ -27,12 +27,12 @@ class Chef
provides :openssl_rsa_private_key
provides :openssl_rsa_key # legacy cookbook resource name
- introduced "14.0"
description "Use the openssl_rsa_private_key resource to generate RSA private key files."\
" If a valid RSA key file can be opened at the specified location, no new file"\
" will be created. If the RSA key file cannot be opened, either because it does"\
" not exist or because the password to the RSA key file does not match the"\
" password in the recipe, it will be overwritten."
+ introduced "14.0"
property :path, String,
description: "The path to write the file to it's different than the resource name.",
@@ -63,7 +63,7 @@ class Chef
description: "The permission mode of all files created by the resource.",
default: "0600"
- property :force, [true, false],
+ property :force, [TrueClass, FalseClass],
description: "Force creating the key even if the existing key exists.",
default: false
diff --git a/lib/chef/resource/osx_profile.rb b/lib/chef/resource/osx_profile.rb
index 56eca90a7e..cf857cec6f 100644
--- a/lib/chef/resource/osx_profile.rb
+++ b/lib/chef/resource/osx_profile.rb
@@ -20,23 +20,20 @@ require "chef/resource"
class Chef
class Resource
- # Use the osx_profile resource to manage configuration profiles (.mobileconfig files)
- # on the macOS platform. The osx_profile resource installs profiles by using
- # the uuidgen library to generate a unique ProfileUUID, and then using the
- # profiles command to install the profile on the system.
class OsxProfile < Chef::Resource
provides :osx_profile, os: "darwin"
provides :osx_config_profile, os: "darwin"
- identity_attr :profile_name
-
- description "12.7"
+ description "Use the osx_profile resource to manage configuration profiles (.mobileconfig files)"\
+ " on the macOS platform. The osx_profile resource installs profiles by using"\
+ " the uuidgen library to generate a unique ProfileUUID, and then using the"\
+ " profiles command to install the profile on the system."
+ introduced "12.7"
default_action :install
-
allowed_actions :install, :remove
- property :profile_name, String, name_property: true
+ property :profile_name, String, name_property: true, identity: true
property :profile, [ String, Hash ]
property :identifier, String
property :path, String
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
index a12039b555..6936f5129f 100644
--- a/lib/chef/resource/portage_package.rb
+++ b/lib/chef/resource/portage_package.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,13 +22,9 @@ class Chef
class Resource
class PortagePackage < Chef::Resource::Package
resource_name :portage_package
- description "Use the portage_package resource to manage packages for the Gentoo platform."
-
- def initialize(name, run_context = nil)
- super
- @provider = Chef::Provider::Package::Portage
- end
+ provides :portage_package
+ description "Use the portage_package resource to manage packages for the Gentoo platform."
end
end
end
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index 565ff278ea..8ca111bf33 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -15,14 +15,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require "chef/provider/registry_key"
+
require "chef/resource"
require "chef/digester"
class Chef
class Resource
- # Use the registry_key resource to create and delete registry keys in Microsoft Windows.
class RegistryKey < Chef::Resource
+ resource_name :registry_key
+ provides :registry_key
+
+ description "Use the registry_key resource to create and delete registry keys in Microsoft Windows."
+ introduced "11.0"
+
identity_attr :key
state_attrs :values
@@ -62,8 +67,6 @@ class Chef
def initialize(name, run_context = nil)
super
- @architecture = :machine
- @recursive = false
@key = name
@values, @unscrubbed_values = [], []
end
@@ -102,21 +105,8 @@ class Chef
end
end
- def recursive(arg = nil)
- set_or_return(
- :recursive,
- arg,
- :kind_of => [TrueClass, FalseClass]
- )
- end
-
- def architecture(arg = nil)
- set_or_return(
- :architecture,
- arg,
- :kind_of => Symbol
- )
- end
+ property :recursive, [TrueClass, FalseClass], default: false
+ property :architecture, Symbol, default: :machine, equal_to: [:machine, :x86_64, :i386]
private
diff --git a/lib/chef/resource/rhsm_errata.rb b/lib/chef/resource/rhsm_errata.rb
index 56779909f5..ca3e71648f 100644
--- a/lib/chef/resource/rhsm_errata.rb
+++ b/lib/chef/resource/rhsm_errata.rb
@@ -27,8 +27,7 @@ class Chef
" to mitigate a single vulnerability must be installed on your hosts."
introduced "14.0"
- property :errata_id,
- String,
+ property :errata_id, String,
description: "An optional property for specifying the errata ID if not using the resource's name.",
name_property: true
diff --git a/lib/chef/resource/rhsm_errata_level.rb b/lib/chef/resource/rhsm_errata_level.rb
index 3aa289ac2e..bab4d6ef26 100644
--- a/lib/chef/resource/rhsm_errata_level.rb
+++ b/lib/chef/resource/rhsm_errata_level.rb
@@ -28,8 +28,7 @@ class Chef
" security level are installed."
introduced "14.0"
- property :errata_level,
- String,
+ property :errata_level, String,
coerce: proc { |x| x.downcase },
equal_to: %w{critical moderate important low},
description: "The errata level of packages to install.",
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index 47fe67d1cf..fe2c6a2391 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -27,29 +27,23 @@ class Chef
" or a local Red Hat Satellite server."
introduced "14.0"
- property :activation_key,
- [String, Array],
+ property :activation_key, [String, Array],
coerce: proc { |x| Array(x) },
description: "A String or array of the activation keys to use when registering. You must also specify the organization property if using activation_key."
- property :satellite_host,
- String,
+ property :satellite_host, String,
description: "The FQDN of the Satellite host to register with. If not specified, the host will be registered with Red Hat's public RHSM service."
- property :organization,
- String,
+ property :organization, String,
description: "The organization to use when registering, required when using an activation key"
- property :environment,
- String,
+ property :environment, String,
description: "The environment to use when registering, required when using username and password"
- property :username,
- String,
+ property :username, String,
description: "The username to use when registering. Not applicable if using an activation key. If specified, password and environment are also required."
- property :password,
- String,
+ property :password, String,
description: "The password to use when registering. Not applicable if using an activation key. If specified, username and environment are also required."
property :auto_attach,
@@ -57,13 +51,11 @@ class Chef
description: "If true, RHSM will attempt to automatically attach the host to applicable subscriptions. It is generally better to use an activation key with the subscriptions pre-defined.",
default: false
- property :install_katello_agent,
- [TrueClass, FalseClass],
+ property :install_katello_agent, [TrueClass, FalseClass],
description: "If true, the 'katello-agent' RPM will be installed.",
default: true
- property :force,
- [TrueClass, FalseClass],
+ property :force, [TrueClass, FalseClass],
description: "If true, the system will be registered even if it is already registered. Normally, any register operations will fail if the machine is has already registered.",
default: false
diff --git a/lib/chef/resource/rhsm_repo.rb b/lib/chef/resource/rhsm_repo.rb
index aef4dd43d6..689874a774 100644
--- a/lib/chef/resource/rhsm_repo.rb
+++ b/lib/chef/resource/rhsm_repo.rb
@@ -26,8 +26,7 @@ class Chef
" repositories that are made available via attached subscriptions."
introduced "14.0"
- property :repo_name,
- String,
+ property :repo_name, String,
description: "An optional property for specifying the repository name if not using the resource's name.",
name_property: true
diff --git a/lib/chef/resource/rhsm_subscription.rb b/lib/chef/resource/rhsm_subscription.rb
index 41dd398cd5..21ee539dda 100644
--- a/lib/chef/resource/rhsm_subscription.rb
+++ b/lib/chef/resource/rhsm_subscription.rb
@@ -27,8 +27,7 @@ class Chef
" does not attach all necessary subscriptions to your host."
introduced "14.0"
- property :pool_id,
- String,
+ property :pool_id, String,
description: "An optional property for specifying the Pool ID if not using the resource's name.",
name_property: true
diff --git a/lib/chef/resource/windows_env.rb b/lib/chef/resource/windows_env.rb
index f5f0bd126d..b970a397aa 100644
--- a/lib/chef/resource/windows_env.rb
+++ b/lib/chef/resource/windows_env.rb
@@ -17,6 +17,8 @@
# limitations under the License.
#
+require "chef/resource"
+
class Chef
class Resource
class WindowsEnv < Chef::Resource
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index 42f5524cc1..84778e2bcb 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -15,6 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+require "chef/resource"
+
class Chef
class Resource
class WindowsFeature < Chef::Resource
@@ -33,11 +36,11 @@ class Chef
property :source, String,
description: "Use a local repository for the feature install."
- property :all, [true, false],
+ property :all, [TrueClass, FalseClass],
description: "Install all sub features.",
default: false
- property :management_tools, [true, false],
+ property :management_tools, [TrueClass, FalseClass],
description: "Install all applicable management tools of the roles, role services, or features (PowerShell only).",
default: false
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb
index 6ffaf318d5..00fc7f71ca 100644
--- a/lib/chef/resource/windows_feature_dism.rb
+++ b/lib/chef/resource/windows_feature_dism.rb
@@ -16,6 +16,8 @@
# limitations under the License.
#
+require "chef/resource"
+
class Chef
class Resource
class WindowsFeatureDism < Chef::Resource
@@ -34,7 +36,7 @@ class Chef
property :source, String,
description: "Use a local repository for the feature install."
- property :all, [true, false],
+ property :all, [TrueClass, FalseClass],
description: "Install all sub features. This is the equivalent of specifying the /All switch to dism.exe",
default: false
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index 30f8f6da83..7e7fb6c160 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -16,6 +16,8 @@
# limitations under the License.
#
+require "chef/resource"
+
class Chef
class Resource
class WindowsFeaturePowershell < Chef::Resource
@@ -37,7 +39,7 @@ class Chef
property :source, String,
description: "Use a local repository for the feature install."
- property :all, [true, false],
+ property :all, [TrueClass, FalseClass],
description: "Install all sub features. This is equivalent to using the"\
" -InstallAllSubFeatures switch with Add-WindowsFeature.",
default: false
@@ -46,7 +48,7 @@ class Chef
description: "Specifies a timeout (in seconds) for feature install.",
default: 600
- property :management_tools, [true, false],
+ property :management_tools, [TrueClass, FalseClass],
description: "",
default: false
diff --git a/lib/chef/resource/windows_pagefile.rb b/lib/chef/resource/windows_pagefile.rb
index 069e76107c..b87134171b 100644
--- a/lib/chef/resource/windows_pagefile.rb
+++ b/lib/chef/resource/windows_pagefile.rb
@@ -15,6 +15,8 @@
# limitations under the License.
#
+require "chef/resource"
+
class Chef
class Resource
class WindowsPagefile < Chef::Resource
@@ -29,10 +31,10 @@ class Chef
description: "The path to the pagefile if different from the resource name.",
name_property: true
- property :system_managed, [true, false],
+ property :system_managed, [TrueClass, FalseClass],
description: "Configures whether the system manages the pagefile size."
- property :automatic_managed, [true, false],
+ property :automatic_managed, [TrueClass, FalseClass],
description: "Enable automatic management of pagefile initial and maximum size. Setting this to true ignores 'initial_size' and 'maximum_size' properties.",
default: false
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb
index c134e27bf7..3ad12e35c7 100644
--- a/lib/chef/resource/windows_printer.rb
+++ b/lib/chef/resource/windows_printer.rb
@@ -39,7 +39,7 @@ class Chef
property :comment, String,
description: "Optional descriptor for the printer queue."
- property :default, [true, false],
+ property :default, [TrueClass, FalseClass],
description: "Should this be the system's default printer.",
default: false
@@ -50,7 +50,7 @@ class Chef
property :location, String,
description: "Printer location, e.g. 'Fifth floor copy room'."
- property :shared, [true, false],
+ property :shared, [TrueClass, FalseClass],
description: "Should the printer be shared.",
default: false
@@ -62,7 +62,8 @@ class Chef
validation_message: "The ipv4_address property must be in the IPv4 format of WWW.XXX.YYY.ZZZ",
regex: Resolv::IPv4::Regex
- property :exists, [true, false], desired_state: true
+ property :exists, [TrueClass, FalseClass],
+ desired_state: true
PRINTERS_REG_KEY = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\\'.freeze unless defined?(PRINTERS_REG_KEY)
diff --git a/lib/chef/resource/windows_printer_port.rb b/lib/chef/resource/windows_printer_port.rb
index 9da43948f6..6d2b293e9f 100644
--- a/lib/chef/resource/windows_printer_port.rb
+++ b/lib/chef/resource/windows_printer_port.rb
@@ -46,7 +46,7 @@ class Chef
property :port_description, String,
description: "The description of the port."
- property :snmp_enabled, [true, false],
+ property :snmp_enabled, [TrueClass, FalseClass],
description: "Should SNMP be enabled on the port.",
default: false
@@ -55,7 +55,7 @@ class Chef
validation_message: "port_protocol must be either 1 for RAW or 2 for LPR!",
default: 1, equal_to: [1, 2]
- property :exists, [true, false],
+ property :exists, [TrueClass, FalseClass],
desired_state: true
PORTS_REG_KEY = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\\'.freeze unless defined?(PORTS_REG_KEY)
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 8a76a716aa..aaa21aa6a7 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -41,11 +41,9 @@ class Chef
allowed_actions :configure_startup, :create, :delete, :configure
- identity_attr :service_name
-
state_attrs :enabled, :running
- property :service_name, name_property: true
+ property :service_name, name_property: true, identity: true
# The display name to be used by user interface programs to identify the
# service. This string has a maximum length of 256 characters.
diff --git a/lib/chef/resource/zypper_package.rb b/lib/chef/resource/zypper_package.rb
index 2e48caef55..23b8779f25 100644
--- a/lib/chef/resource/zypper_package.rb
+++ b/lib/chef/resource/zypper_package.rb
@@ -29,7 +29,7 @@ class Chef
" packages with Zypper for the SUSE Enterprise and OpenSUSE platforms."
property :gpg_check, [ TrueClass, FalseClass ], default: lazy { Chef::Config[:zypper_check_gpg] }
- property :allow_downgrade, [ true, false ], default: false
+ property :allow_downgrade, [ TrueClass, FalseClass ], default: false
end
end
end
diff --git a/lib/chef/resource/zypper_repository.rb b/lib/chef/resource/zypper_repository.rb
index 298373b87d..776c7a407f 100644
--- a/lib/chef/resource/zypper_repository.rb
+++ b/lib/chef/resource/zypper_repository.rb
@@ -33,20 +33,20 @@ class Chef
property :repo_name, String, name_property: true
property :description, String
property :type, String, default: "NONE"
- property :enabled, [true, false], default: true
- property :autorefresh, [true, false], default: true
- property :gpgcheck, [true, false], default: true
+ property :enabled, [TrueClass, FalseClass], default: true
+ property :autorefresh, [TrueClass, FalseClass], default: true
+ property :gpgcheck, [TrueClass, FalseClass], default: true
property :gpgkey, String
property :baseurl, String
property :mirrorlist, String
property :path, String
property :priority, Integer, default: 99
- property :keeppackages, [true, false], default: false
+ property :keeppackages, [TrueClass, FalseClass], default: false
property :mode, default: "0644"
- property :refresh_cache, [true, false], default: true
+ property :refresh_cache, [TrueClass, FalseClass], default: true
property :source, String
property :cookbook, String
- property :gpgautoimportkeys, [true, false], default: true
+ property :gpgautoimportkeys, [TrueClass, FalseClass], default: true
default_action :create
allowed_actions :create, :remove, :add, :refresh
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb
new file mode 100644
index 0000000000..0f4f718c72
--- /dev/null
+++ b/lib/chef/resource_inspector.rb
@@ -0,0 +1,89 @@
+# Copyright:: Copyright 2018, Chef Software, Inc
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "chef/cookbook_loader"
+require "chef/cookbook/file_vendor"
+require "chef/cookbook/file_system_file_vendor"
+require "chef/resource/lwrp_base"
+require "chef/run_context"
+require "chef/node"
+require "chef/resources"
+require "chef/json_compat"
+
+module ResourceInspector
+ def self.extract_resource(resource, complete = false)
+ data = {}
+ data[:description] = resource.description
+ # data[:deprecated] = resource.deprecated || false
+ data[:actions] = resource.allowed_actions
+ data[:examples] = resource.examples
+ data[:introduced] = resource.introduced
+
+ properties = unless complete
+ resource.properties.reject { |_, k| k.options[:declared_in] == Chef::Resource }
+ else
+ resource.properties
+ end
+
+ data[:properties] = properties.each_with_object([]) do |(n, k), acc|
+ opts = k.options
+ acc << { name: n, description: opts[:description], introduced: opts[:introduced], is: opts[:is], deprecated: opts[:deprecated] || false }
+ end
+ data
+ end
+
+ def self.extract_cookbook(path, complete)
+ path = File.expand_path(path)
+ dir, name = File.split(path)
+ Chef::Cookbook::FileVendor.fetch_from_disk(path)
+ loader = Chef::CookbookLoader.new(dir)
+ cookbooks = loader.load_cookbooks
+ resources = cookbooks[name].files_for(:resources)
+
+ resources.each_with_object({}) do |r, res|
+ pth = r["full_path"]
+ cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
+ res[cur.resource_name] = extract_resource(cur, complete)
+ end
+ end
+
+ # If we're given no resources, dump all of Chef's built ins
+ # otherwise, if we have a path then extract all the resources from the cookbook
+ # or else do a list of built in resources
+ #
+ # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
+ def self.inspect(arguments = [], complete: false)
+ output = if arguments.empty?
+ ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
+ else
+ arguments.each_with_object({}) do |arg, acc|
+ if File.directory?(arg)
+ extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
+ else
+ r = Chef::ResourceResolver.resolve(arg.to_sym, canonical: nil)
+ acc[r.resource_name] = extract_resource(r, complete)
+ end
+ end
+ end
+
+ puts Chef::JSONCompat.to_json_pretty(output)
+ end
+
+ def self.start
+ inspect(ARGV, complete: true)
+ end
+
+end
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 66d4b0e3e3..f382f0637a 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require "chef/version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("14.0.108")
+ VERSION = Chef::VersionString.new("14.0.118")
end
#
diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb
index eae0ae4abf..418d72e65e 100644
--- a/lib/chef/win32/eventlog.rb
+++ b/lib/chef/win32/eventlog.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-if Chef::Platform.windows? && (not Chef::Platform.windows_server_2003?)
+if Chef::Platform.windows?
if !defined? Chef::Win32EventLogLoaded
if defined? Windows::Constants
[:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index 63b626b1d7..821d81ef81 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -643,32 +643,26 @@ class Chef
# Checks if the caller has the admin privileges in their
# security token
def self.has_admin_privileges?
- if Chef::Platform.windows_server_2003?
- # Admin privileges do not exist on Windows Server 2003
-
- true
- else
- # a regular user doesn't have privileges to call Chef::ReservedNames::Win32::Security.OpenProcessToken
- # hence we return false if the open_current_process_token fails with `Access is denied.` error message.
- begin
- process_token = open_current_process_token(TOKEN_READ)
- rescue Exception => run_error
- return false if run_error.message =~ /Access is denied/
- Chef::ReservedNames::Win32::Error.raise!
- end
+ # a regular user doesn't have privileges to call Chef::ReservedNames::Win32::Security.OpenProcessToken
+ # hence we return false if the open_current_process_token fails with `Access is denied.` error message.
+ begin
+ process_token = open_current_process_token(TOKEN_READ)
+ rescue Exception => run_error
+ return false if run_error.message =~ /Access is denied/
+ Chef::ReservedNames::Win32::Error.raise!
+ end
- # display token elevation details
- token_elevation_type = get_token_information_elevation_type(process_token)
- Chef::Log.debug("Token Elevation Type: #{token_elevation_type}")
+ # display token elevation details
+ token_elevation_type = get_token_information_elevation_type(process_token)
+ Chef::Log.debug("Token Elevation Type: #{token_elevation_type}")
- elevation_result = FFI::Buffer.new(:ulong)
- elevation_result_size = FFI::MemoryPointer.new(:uint32)
- success = GetTokenInformation(process_token.handle.handle, :TokenElevation, elevation_result, 4, elevation_result_size)
+ elevation_result = FFI::Buffer.new(:ulong)
+ elevation_result_size = FFI::MemoryPointer.new(:uint32)
+ success = GetTokenInformation(process_token.handle.handle, :TokenElevation, elevation_result, 4, elevation_result_size)
- # Assume process is not elevated if the call fails.
- # Process is elevated if the result is different than 0.
- success && (elevation_result.read_ulong != 0)
- end
+ # Assume process is not elevated if the call fails.
+ # Process is elevated if the result is different than 0.
+ success && (elevation_result.read_ulong != 0)
end
def self.logon_user(username, domain, password, logon_type, logon_provider)
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index c77616853c..b551cbd2e3 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -248,8 +248,7 @@ class Chef
# See https://technet.microsoft.com/en-us/library/cc961992.aspx
# In practice, this is SID.Administrators if the current_user is an admin (even if not
- # running elevated), and is current_user otherwise. On win2k3, it technically can be
- # current_user in all cases if a certain group policy is set.
+ # running elevated), and is current_user otherwise.
def self.default_security_object_owner
token = Chef::ReservedNames::Win32::Security.open_current_process_token
Chef::ReservedNames::Win32::Security.get_token_information_owner(token)
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index f8228d40b3..944cb207f5 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -76,15 +76,8 @@ class Chef
@sp_minor_version = ver_info[:w_service_pack_minor]
# Obtain sku information for the purpose of identifying
- # datacenter, cluster, and core skus, the latter 2 only
- # exist in releases after Windows Server 2003
- if ! Chef::Platform.windows_server_2003?
- @sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version)
- else
- # The get_product_info API is not supported on Win2k3,
- # use an alternative to identify datacenter skus
- @sku = get_datacenter_product_info_windows_server_2003(ver_info)
- end
+ # datacenter, cluster, and core skus
+ @sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version)
end
marketing_names = Array.new
@@ -153,12 +146,6 @@ class Chef
out.get_uint(0)
end
- def get_datacenter_product_info_windows_server_2003(ver_info)
- # The intent is not to get the actual sku, just identify
- # Windows Server 2003 datacenter
- sku = (ver_info[:w_suite_mask] & VER_SUITE_DATACENTER) ? PRODUCT_DATACENTER_SERVER : 0
- end
-
end
end
end
diff --git a/spec/data/mixin/invalid_data.rb b/spec/data/mixin/invalid_data.rb
new file mode 100644
index 0000000000..e6f6c3a783
--- /dev/null
+++ b/spec/data/mixin/invalid_data.rb
@@ -0,0 +1,3 @@
+# For spec/functional/mixin/from_file_spec.rb
+a :foo
+c :bar
diff --git a/spec/data/mixin/real_data.rb b/spec/data/mixin/real_data.rb
new file mode 100644
index 0000000000..e15b86fc68
--- /dev/null
+++ b/spec/data/mixin/real_data.rb
@@ -0,0 +1,2 @@
+# For spec/functional/mixin/from_file_spec.rb
+a :foo
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 019595ea8d..8a9475680d 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -19,12 +19,12 @@
require "spec_helper"
require "securerandom"
require "chef/event_loggers/windows_eventlog"
-if Chef::Platform.windows? && (not Chef::Platform.windows_server_2003?)
+if Chef::Platform.windows?
require "win32/eventlog"
include Win32
end
-describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_on_win2k3 do
+describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
def rand
random.rand(1 << 32).to_s
end
diff --git a/spec/functional/mixin/from_file_spec.rb b/spec/functional/mixin/from_file_spec.rb
new file mode 100644
index 0000000000..a279f48790
--- /dev/null
+++ b/spec/functional/mixin/from_file_spec.rb
@@ -0,0 +1,82 @@
+#
+# Copyright:: Copyright 2014-2018, Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+
+describe Chef::Mixin::FromFile do
+ REAL_DATA = File.join(CHEF_SPEC_DATA, "mixin", "real_data.rb")
+ INVALID_DATA = File.join(CHEF_SPEC_DATA, "mixin", "invalid_data.rb")
+ NO_DATA = File.join(CHEF_SPEC_DATA, "mixin", "non_existant_data.rb")
+
+ class TestData
+ include Chef::Mixin::FromFile
+
+ def a(a = nil)
+ @a = a if a
+ @a
+ end
+ end
+
+ class ClassTestData
+ class <<self
+ include Chef::Mixin::FromFile
+
+ def a(a = nil)
+ @a = a if a
+ @a
+ end
+ end
+ end
+
+ describe "from_file" do
+ it "should load data" do
+ datum = TestData.new
+ datum.from_file(REAL_DATA)
+ expect(datum.a).to eq(:foo)
+ end
+
+ it "should load class data" do
+ datum = ClassTestData
+ datum.class_from_file(REAL_DATA)
+ expect(datum.a).to eq(:foo)
+ end
+
+ it "should set source_file" do
+ datum = TestData.new
+ datum.from_file(REAL_DATA)
+ expect(datum.source_file).to eq(REAL_DATA)
+ end
+
+ it "should set class source_file" do
+ datum = ClassTestData
+ datum.class_from_file(REAL_DATA)
+ expect(datum.source_file).to eq(REAL_DATA)
+ end
+
+ it "should fail on invalid data" do
+ datum = TestData.new
+ expect do
+ datum.from_file(INVALID_DATA)
+ end.to raise_error(NoMethodError)
+ end
+
+ it "should fail on nonexistant data" do
+ datum = TestData.new
+ expect { datum.from_file(NO_DATA) }.to raise_error(IOError)
+ end
+ end
+end
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index e8a95436f7..8073bbc92e 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -172,7 +172,7 @@ describe Chef::Resource::Link do
create_resource
end
- describe "when supported on platform", :not_supported_on_win2k3 do
+ describe "when supported on platform" do
shared_examples_for "delete errors out" do
it "delete errors out" do
expect { resource.run_action(:delete) }.to raise_error(Chef::Exceptions::Link)
@@ -694,10 +694,4 @@ describe Chef::Resource::Link do
end
end
end
-
- describe "when not supported on platform", :win2k3_only do
- it "raises error" do
- expect { resource }.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
- end
- end
end
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index af345b0ea4..bbd304fd06 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -36,8 +36,6 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
let(:cmdlet_exit_code_success_content) { "get-item ." }
let(:windows_process_exit_code_success_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe $env:systemroot" }
let(:windows_process_exit_code_not_found_content) { "findstr /notavalidswitch" }
- # Note that process exit codes on 32-bit Win2k3 cannot
- # exceed maximum value of signed integer
let(:arbitrary_nonzero_process_exit_code) { 4193 }
let(:arbitrary_nonzero_process_exit_code_content) { "exit #{arbitrary_nonzero_process_exit_code}" }
let(:invalid_powershell_interpreter_flag) { "/thisflagisinvalid" }
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index 6c24cbec08..22c749b609 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -42,7 +42,6 @@ describe "Chef::Win32::Security", :windows_only do
before do
allow_any_instance_of(Chef::Mixin::UserContext).to receive(:node).and_return({ "platform_family" => "windows" })
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
add_user = Mixlib::ShellOut.new("net user #{user} #{password} /ADD")
add_user.run_command
add_user.error!
diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb
index d6e840ed7f..19bd0e3875 100644
--- a/spec/functional/win32/versions_spec.rb
+++ b/spec/functional/win32/versions_spec.rb
@@ -21,7 +21,7 @@ if Chef::Platform.windows?
require "chef/win32/version"
end
-describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on_win2k3 do
+describe "Chef::ReservedNames::Win32::Version", :windows_only do
before do
wmi = WmiLite::Wmi.new
@@ -31,14 +31,12 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
# On Win2k8R2 and later, we can dynamically obtain marketing
# names for comparison from WMI so the test should not
# need to be modified when new Windows releases arise.
- # For Win2k3 and Win2k8, we use static names in this test
- # based on the version number information from WMI. The names
- # from WMI contain extended characters such as registered
- # trademark on Win2k8 and Win2k3 that we're not using in our
- # library, so we have to set the expectation statically.
- if Chef::Platform.windows_server_2003?
- @current_os_version = "Windows Server 2003 R2"
- elsif is_windows_server_2008?(host)
+ # For Win2k8 we use static names in this test based on the
+ # version number information from WMI. The names from WMI
+ # contain extended characters such as registered trademark
+ # on Win2k8 that we're not using in our library, so we have
+ # to set the expectation statically.
+ if is_windows_server_2008?(host)
@current_os_version = "Windows Server 2008"
else
# The name from WMI is actually what we want in Win2k8R2+.
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index de12b8ba8e..77008524c8 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -46,7 +46,7 @@ describe "chef-client" do
# we're running `chef-client` from the source tree and not the external one.
# cf. CHEF-4914
let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
- let(:chef_solo) { "ruby '#{chef_dir}/chef-solo' --minimal-ohai" }
+ let(:chef_solo) { "ruby '#{chef_dir}/chef-solo' --legacy-mode --minimal-ohai" }
let(:critical_env_vars) { %w{_ORIGINAL_GEM_PATH GEM_PATH GEM_HOME GEM_ROOT BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYLIB RUBYOPT RUBY_ENGINE RUBY_ROOT RUBY_VERSION PATH}.map { |o| "#{o}=#{ENV[o]}" } .join(" ") }
@@ -624,4 +624,102 @@ EOM
expect(command.stdout).not_to include("INFO")
end
end
+
+ when_the_repository "has a cookbook that knows if we're running forked" do
+ before do
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
+EOM
+ file "config/client.rb", <<EOM
+local_mode true
+cookbook_path "#{path_to('cookbooks')}"
+EOM
+ end
+
+ it "chef-client runs by default with no supervisor" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+
+ it "chef-solo runs by default with no supervisor" do
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+
+ it "chef-client --no-fork does not fork" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+
+ it "chef-solo --no-fork does not fork" do
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+
+ it "chef-client with --fork uses a supervisor" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("WITHFORK")
+ end
+
+ it "chef-solo with --fork uses a supervisor" do
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("WITHFORK")
+ end
+ end
+
+ when_the_repository "has a cookbook that knows if we're running forked, and configures forking in config.rb" do
+ before do
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
+EOM
+ file "config/client.rb", <<EOM
+local_mode true
+cookbook_path "#{path_to('cookbooks')}"
+client_fork true
+EOM
+ end
+
+ it "chef-client uses a supervisor" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("WITHFORK")
+ end
+
+ it "chef-solo uses a supervisor" do
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("WITHFORK")
+ end
+ end
+
+ when_the_repository "has a cookbook that knows if we're running forked, and configures no-forking in config.rb" do
+ before do
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
+EOM
+ file "config/client.rb", <<EOM
+local_mode true
+cookbook_path "#{path_to('cookbooks')}"
+client_fork false
+EOM
+ end
+
+ it "chef-client uses a supervisor" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+
+ it "chef-solo uses a supervisor" do
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command.error!
+ expect(command.stdout).to include("NOFORK")
+ end
+ end
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index d6ea4347c4..149b17fcad 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -378,94 +378,6 @@ module ResourceActionSpec
end
end
- context "With a resource with property x" do
- class ResourceActionSpecWithX < Chef::Resource
- resource_name :resource_action_spec_with_x
- property :x, default: 20
- action :set do
- # Access x during converge to ensure that we emit no warnings there
- x
- end
- end
-
- context "And another resource with a property x and an action that sets property x to its value" do
- class ResourceActionSpecAlsoWithX < Chef::Resource
- resource_name :resource_action_spec_also_with_x
- property :x
- action :set_x_to_x do
- resource_action_spec_with_x "hi" do
- x x
- end
- end
- def self.x_warning_line
- __LINE__ - 4
- end
- action :set_x_to_x_in_non_initializer do
- r = resource_action_spec_with_x "hi" do
- x 10
- end
- x_times_2 = r.x * 2
- end
- action :set_x_to_10 do
- resource_action_spec_with_x "hi" do
- x 10
- end
- end
- end
-
- attr_reader :x_warning_line
-
- it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe = converge do
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_x
- end
- end
- warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 2
- expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/)
- end
-
- it "Using the enclosing resource to set x to x outside the initializer emits no warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe = converge do
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_x_in_non_initializer
- end
- end
- warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
- end
-
- it "Using the enclosing resource to set x to 10 emits no warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe = converge do
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_10
- end
- end
- warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
- end
-
- it "Using the enclosing resource to set x to 10 emits no warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe = converge do
- r = resource_action_spec_also_with_x "hi"
- r.x 1
- r.action :set_x_to_10
- end
- warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 1 # the deprecation warning, not the property masking one
- end
- end
-
- end
-
context "With a resource with a set_or_return property named group (same name as a resource)" do
class ResourceActionSpecWithGroupAction < Chef::Resource
resource_name :resource_action_spec_set_group_to_nil
@@ -504,13 +416,6 @@ module ResourceActionSpec
end
end
end
-
- it "Raises an error when attempting to use a template in the action" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect_converge do
- has_property_named_template "hi"
- end.to raise_error(/Property `template` of `has_property_named_template\[hi\]` was incorrectly passed a block. Possible property-resource collision. To call a resource named `template` either rename the property or else use `declare_resource\(:template, ...\)`/)
- end
end
context "When a resource declares methods in action_class" do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index dbefbf29e4..78f8da7b51 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -146,11 +146,9 @@ RSpec.configure do |config|
config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106?
config.filter_run_excluding :not_supported_on_mac_osx => true if mac_osx?
config.filter_run_excluding :mac_osx_only => true if !mac_osx?
- config.filter_run_excluding :not_supported_on_win2k3 => true if windows_win2k3?
config.filter_run_excluding :not_supported_on_solaris => true if solaris?
config.filter_run_excluding :not_supported_on_gce => true if gce?
config.filter_run_excluding :not_supported_on_nano => true if windows_nano_server?
- config.filter_run_excluding :win2k3_only => true unless windows_win2k3?
config.filter_run_excluding :win2012r2_only => true unless windows_2012r2?
config.filter_run_excluding :windows_2008r2_or_later => true unless windows_2008r2_or_later?
config.filter_run_excluding :windows64_only => true unless windows64?
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 3cc8778f7a..f015a6cd50 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -51,11 +51,6 @@ def windows_domain_joined?
computer_system["partofdomain"]
end
-def windows_win2k3?
- return false unless windows?
- (host_version && host_version.start_with?("5.2"))
-end
-
def windows_2008r2_or_later?
return false unless windows?
return false unless host_version
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index eb7a378db9..d025a0806d 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -399,7 +399,7 @@ shared_examples_for "a configured file resource" do
content
end
- context "when the target file is a symlink", :not_supported_on_win2k3 do
+ context "when the target file is a symlink" do
let(:symlink_target) do
File.join(CHEF_SPEC_DATA, "file-test-target")
end
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 3f803f2033..0cd3cb3995 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -107,6 +107,7 @@ describe Chef::Application::Client, "reconfigure" do
shared_examples "sets the configuration" do |cli_arguments, expected_config|
describe cli_arguments do
before do
+ cli_arguments ||= ""
ARGV.replace(cli_arguments.split)
app.reconfigure
end
@@ -144,6 +145,36 @@ describe Chef::Application::Client, "reconfigure" do
end
end
+ describe "--[no]-fork" do
+ before do
+ Chef::Config[:interval] = nil # FIXME: we're overriding the before block setting this
+ end
+
+ context "by default" do
+ it_behaves_like "sets the configuration", "", client_fork: false
+ end
+
+ context "with --fork" do
+ it_behaves_like "sets the configuration", "--fork", client_fork: true
+ end
+
+ context "with --no-fork" do
+ it_behaves_like "sets the configuration", "--no-fork", client_fork: false
+ end
+
+ context "with an interval" do
+ it_behaves_like "sets the configuration", "--interval 1800", client_fork: true
+ end
+
+ context "with once" do
+ it_behaves_like "sets the configuration", "--once", client_fork: false
+ end
+
+ context "with daemonize", :unix_only do
+ it_behaves_like "sets the configuration", "--daemonize", client_fork: true
+ end
+ end
+
describe "--config-option" do
context "with a single value" do
it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example",
@@ -186,21 +217,16 @@ describe Chef::Application::Client, "reconfigure" do
Chef::Config[:splay] = nil
end
- context "when interval is given" do
- before do
- Chef::Config[:interval] = 600
- allow(ChefConfig).to receive(:windows?).and_return(false)
- end
-
- it "should terminate with message" do
- expect(Chef::Application).to receive(:fatal!).with(
-"Unforked chef-client interval runs are disabled in Chef 12.
+ it "should terminal with message when interval is given" do
+ Chef::Config[:interval] = 600
+ allow(ChefConfig).to receive(:windows?).and_return(false)
+ expect(Chef::Application).to receive(:fatal!).with(
+ "Unforked chef-client interval runs are disabled in Chef 12.
Configuration settings:
interval = 600 seconds
Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
- )
- app.reconfigure
- end
+ )
+ app.reconfigure
end
context "when interval is given on windows" do
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 5cd7c7794f..2a12e27610 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -49,19 +49,6 @@ describe Chef::DSL::RebootPending do
allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending').and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
- context "version is server 2003" do
- before do
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(true)
- end
-
- it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data on 2k3' do
- allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
- allow(recipe).to receive(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
- [{ :name => "Flags", :type => :dword, :data => 3 }])
- expect(recipe.reboot_pending?).to be_truthy
- end
- end
end
context "platform is ubuntu" do
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index aa2b3c1f11..ac5158e913 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -18,19 +18,6 @@
require "spec_helper"
-describe "Chef::Platform#windows_server_2003?" do
- it "returns false early when not on windows" do
- allow(ChefConfig).to receive(:windows?).and_return(false)
- expect(Chef::Platform).not_to receive(:require)
- expect(Chef::Platform.windows_server_2003?).to be_falsey
- end
-
- # CHEF-4888: Need to call WIN32OLE.ole_initialize in new threads
- it "does not raise an exception" do
- expect { Thread.fork { Chef::Platform.windows_server_2003? }.join }.not_to raise_error
- end
-end
-
describe "Chef::Platform#windows_nano_server?" do
include_context "Win32"
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 466d0f970b..b8cf56750d 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -70,8 +70,44 @@ describe Chef::PolicyBuilder::Policyfile do
}
end
- let(:policyfile_default_attributes) { { "policyfile_default_attr" => "policyfile_default_value" } }
- let(:policyfile_override_attributes) { { "policyfile_override_attr" => "policyfile_override_value" } }
+ let(:policyfile_default_attributes) do
+ {
+ "policyfile_default_attr" => "policyfile_default_value",
+ "top_level_attr" => "hat",
+ "baseline_attr" => {
+ "one" => 1,
+ "two" => 2,
+ "deep" => {
+ "three" => 3,
+ "four" => [4],
+ "five" => [5],
+ },
+ },
+ "policy_group_value" => {
+ "baseline_attr" => {
+ "one" => 111,
+ },
+ },
+ }
+ end
+
+ let(:policyfile_override_attributes) do
+ {
+ "policyfile_override_attr" => "policyfile_override_value",
+ "baseline_attr" => {
+ "deep" => {
+ "three" => 333 },
+ },
+ "policy_group_value" => {
+ "top_level_attr" => "cat",
+ "baseline_attr" => {
+ "deep" => {
+ "four" => [444],
+ },
+ },
+ },
+ }
+ end
let(:policyfile_run_list) { ["recipe[example1::default]", "recipe[example2::server]"] }
@@ -636,6 +672,42 @@ describe Chef::PolicyBuilder::Policyfile do
end
end
+
+ describe "hoisting attribute values" do
+ context "with no policy group set" do
+ it "does not hoist policy_group specific attributes" do
+ expect( node["top_level_attr"] ).to eql("hat")
+ expect( node["baseline_attr"]["one"] ).to eql(1)
+ expect( node["baseline_attr"]["two"] ).to eql(2)
+ expect( node["baseline_attr"]["deep"]["three"] ).to eql(333)
+ expect( node["baseline_attr"]["deep"]["four"] ).to eql([4])
+ expect( node["baseline_attr"]["deep"]["five"] ).to eql([5])
+ end
+ end
+
+ context "with a policy group set" do
+ before do
+ Chef::Config[:policy_group] = "policy_group_value"
+ policy_builder.finish_load_node(node)
+ policy_builder.build_node
+ end
+
+ it "hoists default attributes" do
+ expect( node["top_level_attr"] ).to eql("cat")
+ expect( node["baseline_attr"]["one"]).to eql(111)
+ expect( node["baseline_attr"]["two"] ).to eql(2)
+ expect( node["baseline_attr"]["deep"]["five"] ).to eql([5])
+ end
+
+ it "hoists override attributes" do
+ expect( node["top_level_attr"] ).to eql("cat")
+ expect( node["baseline_attr"]["two"] ).to eql(2)
+ expect( node["baseline_attr"]["deep"]["three"] ).to eql(333)
+ expect( node["baseline_attr"]["deep"]["four"] ).to eql([444])
+ expect( node["baseline_attr"]["deep"]["five"] ).to eql([5])
+ end
+ end
+ end
end
describe "fetching the desired cookbook set" do
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index ca85831a06..d881d01124 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -251,16 +251,4 @@ C5986B4F1257FFA86632CBA746181433FBB75451
expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil)).to eql(target)
end
end
-
- describe "#keyfile_is_invalid?" do
- it "returns true if the file is invalid" do
- expect(provider).to receive(:shell_out).and_return(gpg_shell_out_failure)
- expect(provider.keyfile_is_invalid?("/foo/bar.key")).to be_truthy
- end
-
- it "returns false if the file is valid" do
- expect(provider).to receive(:shell_out).and_return(gpg_shell_out_success)
- expect(provider.keyfile_is_invalid?("/foo/bar.key")).to be_falsey
- end
- end
end
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 9426cf41dc..b233fac72b 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -25,7 +25,7 @@ if Chef::Platform.windows?
require "chef/win32/file" #probably need this in spec_helper
end
-describe Chef::Resource::Link, :not_supported_on_win2k3 do
+describe Chef::Resource::Link do
let(:provider) do
node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb
index cb1b6e3cd8..d391da3010 100644
--- a/spec/unit/provider/remote_directory_spec.rb
+++ b/spec/unit/provider/remote_directory_spec.rb
@@ -193,7 +193,7 @@ describe Chef::Provider::RemoteDirectory do
expect(::File.exist?(@destination_dir + "/a/multiply/nested/directory/qux.txt")).to be_falsey
end
- it "removes directory symlinks properly", :not_supported_on_win2k3 do
+ it "removes directory symlinks properly" do
symlinked_dir_path = @destination_dir + "/symlinked_dir"
@provider.action = :create
@provider.run_action
diff --git a/spec/unit/resource/portage_package_spec.rb b/spec/unit/resource/portage_package_spec.rb
index 02a7aef39a..a37cfd6e41 100644
--- a/spec/unit/resource/portage_package_spec.rb
+++ b/spec/unit/resource/portage_package_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,8 +29,4 @@ describe Chef::Resource::PortagePackage, "initialize" do
it "sets the resource_name to :portage_package" do
expect(resource.resource_name).to eql(:portage_package)
end
-
- it "sets the provider to Chef::Provider::Package::Portage" do
- expect(resource.provider).to eql(Chef::Provider::Package::Portage)
- end
end
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index 07ad4f820b..d8eea74ed4 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Resource::RegistryKey, "initialize" do
expect(resource.resource_name).to eql(:registry_key)
end
- it "sets the key equal to the argument to initialize" do
+ it "sets the key property to the resource name" do
expect(resource.key).to eql('HKCU\Software\Raxicoricofallapatorius')
end
@@ -159,6 +159,10 @@ describe Chef::Resource::RegistryKey, "architecture" do
end
end
+ it "does not allow other symbols" do
+ expect { resource.architecture(:nope) }.to raise_error(ArgumentError)
+ end
+
it "does not allow a hash" do
expect { resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/resource_inspector_spec.rb b/spec/unit/resource_inspector_spec.rb
new file mode 100644
index 0000000000..2cb9c0bb65
--- /dev/null
+++ b/spec/unit/resource_inspector_spec.rb
@@ -0,0 +1,60 @@
+# Copyright:: Copyright 2018, Chef Software, Inc
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+require "chef/resource_inspector"
+
+class DummyResource < Chef::Resource
+ resource_name :dummy
+ description "A dummy resource"
+ examples <<~EOH
+ dummy "foo" do
+ first "yes"
+ end
+ EOH
+ introduced "14.0"
+ property :first, String, description: "My First Property", introduced: "14.0"
+
+ action :dummy do
+ return true
+ end
+end
+
+describe ResourceInspector do
+ describe "inspecting a resource" do
+ subject { ResourceInspector.extract_resource(DummyResource, false) }
+
+ it "returns a hash with required data" do
+ expect(subject[:description]).to eq "A dummy resource"
+ expect(subject[:actions]).to match_array [:nothing, :dummy]
+ end
+
+ context "excluding built in properties" do
+ it "returns a single property" do
+ expect(subject[:properties].count).to eq 1
+ expect(subject[:properties].first[:name]).to eq :first
+ end
+ end
+
+ context "including built in properties" do
+ subject { ResourceInspector.extract_resource(DummyResource, true) }
+ it "returns many properties" do
+ expect(subject[:properties].count).to be > 1
+ expect(subject[:properties].map { |n| n[:name] }).to include(:name, :first, :sensitive)
+ end
+ end
+ end
+end
diff --git a/spec/unit/win32/security_spec.rb b/spec/unit/win32/security_spec.rb
index 6e4441a482..9d98ccdf49 100644
--- a/spec/unit/win32/security_spec.rb
+++ b/spec/unit/win32/security_spec.rb
@@ -65,14 +65,8 @@ describe "Chef::Win32::Security", :windows_only do
end
describe "self.has_admin_privileges?" do
- it "returns true for windows server 2003" do
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(true)
- expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to be true
- end
-
context "when the user doesn't have admin privileges" do
it "returns false" do
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
allow(Chef::ReservedNames::Win32::Security).to receive(:open_current_process_token).and_raise("Access is denied.")
expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to be false
end
@@ -80,7 +74,6 @@ describe "Chef::Win32::Security", :windows_only do
context "when open_current_process_token fails with some other error than `Access is Denied`" do
it "raises error" do
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
allow(Chef::ReservedNames::Win32::Security).to receive(:open_current_process_token).and_raise("boom")
expect { Chef::ReservedNames::Win32::Security.has_admin_privileges? }.to raise_error(Chef::Exceptions::Win32APIError)
end
@@ -88,7 +81,6 @@ describe "Chef::Win32::Security", :windows_only do
context "when the user has admin privileges" do
it "returns true" do
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
allow(Chef::ReservedNames::Win32::Security).to receive(:open_current_process_token)
token = Chef::ReservedNames::Win32::Security.open_current_process_token
allow(token).to receive_message_chain(:handle, :handle)