chef 16.2.50 → 16.2.73

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -15
  3. data/chef.gemspec +2 -2
  4. data/lib/chef/application/apply.rb +1 -0
  5. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +2 -2
  6. data/lib/chef/digester.rb +3 -2
  7. data/lib/chef/file_access_control/windows.rb +2 -2
  8. data/lib/chef/file_content_management/deploy/mv_unix.rb +1 -1
  9. data/lib/chef/http.rb +1 -1
  10. data/lib/chef/knife/bootstrap.rb +12 -3
  11. data/lib/chef/knife/cookbook_upload.rb +1 -4
  12. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  13. data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
  14. data/lib/chef/resource.rb +1 -1
  15. data/lib/chef/resource/dmg_package.rb +1 -1
  16. data/lib/chef/resource/launchd.rb +1 -1
  17. data/lib/chef/resource/windows_user_privilege.rb +25 -2
  18. data/lib/chef/version.rb +1 -1
  19. data/spec/functional/knife/configure_spec.rb +1 -1
  20. data/spec/functional/resource/aix_service_spec.rb +10 -1
  21. data/spec/functional/resource/aixinit_service_spec.rb +1 -1
  22. data/spec/functional/resource/bash_spec.rb +3 -2
  23. data/spec/functional/resource/bff_spec.rb +1 -1
  24. data/spec/functional/resource/chocolatey_package_spec.rb +4 -0
  25. data/spec/functional/resource/cron_spec.rb +10 -1
  26. data/spec/functional/resource/dnf_package_spec.rb +4 -1
  27. data/spec/functional/resource/execute_spec.rb +1 -1
  28. data/spec/functional/resource/group_spec.rb +9 -1
  29. data/spec/functional/resource/ifconfig_spec.rb +9 -1
  30. data/spec/functional/resource/insserv_spec.rb +3 -2
  31. data/spec/functional/resource/link_spec.rb +2 -5
  32. data/spec/functional/resource/mount_spec.rb +9 -1
  33. data/spec/functional/resource/msu_package_spec.rb +9 -3
  34. data/spec/functional/resource/powershell_script_spec.rb +4 -4
  35. data/spec/functional/resource/remote_file_spec.rb +6 -6
  36. data/spec/functional/resource/rpm_spec.rb +1 -1
  37. data/spec/functional/resource/timezone_spec.rb +2 -0
  38. data/spec/functional/resource/windows_package_spec.rb +0 -1
  39. data/spec/functional/resource/windows_path_spec.rb +4 -0
  40. data/spec/functional/resource/windows_security_policy_spec.rb +0 -1
  41. data/spec/functional/resource/windows_service_spec.rb +4 -0
  42. data/spec/functional/resource/windows_task_spec.rb +4 -3
  43. data/spec/functional/resource/windows_user_privilege_spec.rb +0 -1
  44. data/spec/functional/resource/yum_package_spec.rb +4 -1
  45. data/spec/functional/resource/zypper_package_spec.rb +4 -1
  46. data/spec/functional/shell_spec.rb +0 -1
  47. data/spec/functional/win32/crypto_spec.rb +1 -1
  48. data/spec/integration/knife/cookbook_upload_spec.rb +1 -1
  49. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -1
  50. data/spec/integration/knife/environment_from_file_spec.rb +1 -1
  51. data/spec/integration/knife/node_from_file_spec.rb +1 -1
  52. data/spec/integration/knife/role_from_file_spec.rb +1 -1
  53. data/spec/integration/recipes/recipe_dsl_spec.rb +4 -0
  54. data/spec/integration/recipes/resource_load_spec.rb +2 -2
  55. data/spec/support/shared/functional/securable_resource.rb +1 -2
  56. data/spec/support/shared/functional/securable_resource_with_reporting.rb +0 -1
  57. data/spec/support/shared/functional/windows_script.rb +2 -2
  58. data/spec/support/shared/unit/provider/file.rb +12 -8
  59. data/spec/unit/application/solo_spec.rb +4 -2
  60. data/spec/unit/chef_fs/config_spec.rb +2 -2
  61. data/spec/unit/chef_fs/diff_spec.rb +8 -8
  62. data/spec/unit/client_spec.rb +4 -1
  63. data/spec/unit/cookbook/synchronizer_spec.rb +26 -24
  64. data/spec/unit/data_bag_spec.rb +6 -3
  65. data/spec/unit/decorator_spec.rb +23 -23
  66. data/spec/unit/environment_spec.rb +5 -1
  67. data/spec/unit/guard_interpreter_spec.rb +1 -1
  68. data/spec/unit/http/api_versions_spec.rb +1 -1
  69. data/spec/unit/knife/bootstrap_spec.rb +1 -0
  70. data/spec/unit/knife/cookbook_download_spec.rb +2 -2
  71. data/spec/unit/knife/cookbook_show_spec.rb +6 -7
  72. data/spec/unit/knife/data_bag_edit_spec.rb +1 -1
  73. data/spec/unit/lwrp_spec.rb +5 -2
  74. data/spec/unit/mixin/powershell_out_spec.rb +2 -4
  75. data/spec/unit/mixin/powershell_type_coercions_spec.rb +1 -1
  76. data/spec/unit/mixin/subclass_directive_spec.rb +2 -2
  77. data/spec/unit/mixin/unformatter_spec.rb +2 -2
  78. data/spec/unit/mixin/uris_spec.rb +1 -1
  79. data/spec/unit/provider/batch_spec.rb +1 -1
  80. data/spec/unit/provider/cron/unix_spec.rb +1 -1
  81. data/spec/unit/provider/dsc_resource_spec.rb +22 -38
  82. data/spec/unit/provider/dsc_script_spec.rb +10 -10
  83. data/spec/unit/provider/execute_spec.rb +1 -1
  84. data/spec/unit/provider/git_spec.rb +3 -3
  85. data/spec/unit/provider/mdadm_spec.rb +1 -3
  86. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  87. data/spec/unit/provider/package/pacman_spec.rb +17 -20
  88. data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +3 -3
  89. data/spec/unit/provider/user/dscl_spec.rb +2 -2
  90. data/spec/unit/provider/windows_env_spec.rb +5 -4
  91. data/spec/unit/resource/chef_client_cron_spec.rb +23 -7
  92. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +7 -4
  93. data/spec/unit/resource/file/verification_spec.rb +2 -1
  94. data/spec/unit/resource_spec.rb +25 -8
  95. data/spec/unit/role_spec.rb +23 -21
  96. data/spec/unit/util/backup_spec.rb +1 -1
  97. data/spec/unit/util/powershell/ps_credential_spec.rb +2 -2
  98. data/spec/unit/util/selinux_spec.rb +2 -1
  99. metadata +20 -15
  100. data/spec/functional/resource/base.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55bc589eea6fe895e338847f884c9595eafb6029a8ee84dbfbcaee2aafa75ad9
4
- data.tar.gz: ad843219ffacb362cc10c5634208aefa867c32f8643e80c6097d83f0187ea998
3
+ metadata.gz: 23d8bd36461cb7ba6be34881a27fc57842493d28ee7f0cd040873dd958e3697f
4
+ data.tar.gz: e4a001233319d2fb24e8ae2ba3b0c4954d2a8688d16b76e909fba16da24df0c0
5
5
  SHA512:
6
- metadata.gz: aba367537baf2d72aac0fb73cc897e6441935a1a474370328e2045280e4f4ca20bf72a9e55b28eb92aaa37d648430e0c021b4e750080645d7693500d195e37af
7
- data.tar.gz: 7f4a4e6e9747156ff93f8e8f0aa103a36f25d3ade6e71e4813bdd14d0806939f8044dea09199eab31ac7de7808a3392a9d264da425fa62ccd29c76918d94f7cb
6
+ metadata.gz: 9ccda8d3f26e8bb4992b83f4bb3ee08b72cfeafbbd55c6bf13be2713c1e65a5b1599c497390176739c912f20796a6fa5e2af427427bbbb5ff7886bffd7f82ce8
7
+ data.tar.gz: 94e1348340d540b3f172fae9ee9b48e0e1cbc5e1a15806c084ded7c26ec0e62c9108c98c6de24e60583dfed265a0cb163e5a2794f40cbe54d5c2d3f8f2187dd3
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ begin
25
25
  require_relative "tasks/dependencies"
26
26
  require_relative "tasks/announce"
27
27
  require_relative "tasks/docs"
28
+ require_relative "tasks/spellcheck"
28
29
  require_relative "lib/chef/dist"
29
30
  rescue LoadError => e
30
31
  puts "Skipping missing rake dep: #{e}"
@@ -107,18 +108,4 @@ begin
107
108
  end
108
109
  rescue LoadError
109
110
  puts "yard is not available. bundle install first to make sure all dependencies are installed."
110
- end
111
-
112
- namespace :spellcheck do
113
- task :run do
114
- sh 'cspell "**/*"'
115
- end
116
-
117
- desc "List the unique unrecognized words in the project."
118
- task :unknown_words do
119
- sh 'cspell "**/*" --wordsOnly --no-summary | sort | uniq'
120
- end
121
- end
122
-
123
- desc "Run spellcheck on the project."
124
- task spellcheck: "spellcheck:run"
111
+ end
@@ -39,8 +39,8 @@ Gem::Specification.new do |s|
39
39
  s.add_dependency "tty-screen", "~> 0.6" # knife list
40
40
  s.add_dependency "pastel" # knife ui.color
41
41
  s.add_dependency "erubis", "~> 2.7"
42
- s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4"
43
- s.add_dependency "ffi-libarchive"
42
+ s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output
43
+ s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3"
44
44
  s.add_dependency "chef-zero", ">= 14.0.11"
45
45
  s.add_dependency "chef-vault"
46
46
 
@@ -21,6 +21,7 @@ require_relative "../../chef"
21
21
  require_relative "../application"
22
22
  require_relative "../client"
23
23
  require_relative "../config"
24
+ require_relative "../config_fetcher"
24
25
  require_relative "../log"
25
26
  require "fileutils" unless defined?(FileUtils)
26
27
  require "tempfile" unless defined?(Tempfile)
@@ -18,7 +18,7 @@
18
18
 
19
19
  require_relative "../base_fs_object"
20
20
  require_relative "../../../http/simple"
21
- require "openssl" unless defined?(OpenSSL)
21
+ require "digest" unless defined?(Digest)
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -69,7 +69,7 @@ class Chef
69
69
  private
70
70
 
71
71
  def calc_checksum(value)
72
- OpenSSL::Digest.hexdigest("MD5", value)
72
+ ::Digest::MD5.hexdigest(value)
73
73
  end
74
74
  end
75
75
  end
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require "openssl" unless defined?(OpenSSL)
22
+ require "digest" unless defined?(Digest)
22
23
  require "singleton" unless defined?(Singleton)
23
24
 
24
25
  class Chef
@@ -50,11 +51,11 @@ class Chef
50
51
  end
51
52
 
52
53
  def generate_md5_checksum_for_file(file)
53
- checksum_file(file, OpenSSL::Digest.new("MD5"))
54
+ checksum_file(file, ::Digest::MD5.new)
54
55
  end
55
56
 
56
57
  def generate_md5_checksum(io)
57
- checksum_io(io, OpenSSL::Digest.new("MD5"))
58
+ checksum_io(io, ::Digest::MD5.new)
58
59
  end
59
60
 
60
61
  private
@@ -96,7 +96,7 @@ class Chef
96
96
  self_ace.mask = securable_object.predict_rights_mask(target_ace.mask)
97
97
  new_target_acl << self_ace
98
98
  end
99
- # As there is no inheritence needed in case of WRITE permissions.
99
+ # As there is no inheritance needed in case of WRITE permissions.
100
100
  if target_ace.mask != Chef::ReservedNames::Win32::API::Security::WRITE && target_ace.flags & (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE) != 0
101
101
  children_ace = target_ace.dup
102
102
  children_ace.flags |= INHERIT_ONLY_ACE
@@ -242,7 +242,7 @@ class Chef
242
242
  flags = 0
243
243
 
244
244
  #
245
- # Configure child inheritence only if the resource is some
245
+ # Configure child inheritance only if the resource is some
246
246
  # type of a directory.
247
247
  #
248
248
  if resource.is_a? Chef::Resource::Directory
@@ -51,7 +51,7 @@ class Chef
51
51
  # in the case where i'm running chef-solo on my homedir as myself and some root-shell
52
52
  # work has caused dotfiles of mine to change to root-owned, i'm fine with this not being
53
53
  # exceptional, and i think most use cases will consider this to not be exceptional, and
54
- # the right thing is to fix the ownership of the file to the user running the commmand
54
+ # the right thing is to fix the ownership of the file to the user running the command
55
55
  # (which requires write perms to the directory, or mv will throw an exception)
56
56
  begin
57
57
  ::File.chown(uid, nil, src)
@@ -52,7 +52,7 @@ class Chef
52
52
 
53
53
  def handle_chunk(next_chunk)
54
54
  # stream handlers handle responses so must be applied in reverse order
55
- # (same as #apply_stream_complete_middleware or #apply_response_midddleware)
55
+ # (same as #apply_stream_complete_middleware or #apply_response_middleware)
56
56
  @stream_handlers.reverse.inject(next_chunk) do |chunk, handler|
57
57
  Chef::Log.trace("Chef::HTTP::StreamHandler calling #{handler.class}#handle_chunk")
58
58
  handler.handle_chunk(chunk)
@@ -703,8 +703,17 @@ class Chef
703
703
  true
704
704
  end
705
705
 
706
+ # FIXME: someone needs to clean this up properly: https://github.com/chef/chef/issues/9645
707
+ # This code is deliberately left without an abstraction around deprecating the config options to avoid knife plugins from
708
+ # using those methods (which will need to be deprecated and break them) via inheritance (ruby does not have a true `private`
709
+ # so the lack of any inheritable implementation is because of that).
710
+ #
706
711
  def winrm_auth_method
707
- config_value(:winrm_auth_method, :winrm_authentication_protocol, "negotiate")
712
+ config.key?(:winrm_auth_method) ? config[:winrm_auth_method] : config.key?(:winrm_authentications_protocol) ? config[:winrm_authentication_protocol] : "negotiate" # rubocop:disable Style/NestedTernaryOperator
713
+ end
714
+
715
+ def ssh_verify_host_key
716
+ config.key?(:ssh_verify_host_key) ? config[:ssh_verify_host_key] : config.key?(:host_key_verify) ? config[:host_key_verify] : "always" # rubocop:disable Style/NestedTernaryOperator
708
717
  end
709
718
 
710
719
  # Fail if using plaintext auth without ssl because
@@ -905,7 +914,7 @@ class Chef
905
914
  { self_signed: config[:winrm_no_verify_cert] === true }
906
915
  elsif ssh?
907
916
  # Fall back to the old knife config key name for back compat.
908
- { verify_host_key: config_value(:ssh_verify_host_key, :host_key_verify, "always") }
917
+ { verify_host_key: ssh_verify_host_key }
909
918
  else
910
919
  {}
911
920
  end
@@ -1051,7 +1060,7 @@ class Chef
1051
1060
  # @api deprecated
1052
1061
  #
1053
1062
  def config_value(key, fallback_key = nil, default = nil)
1054
- Chef.deprecated(:knife_bootstrap_apis, "Use of config_value without a fallback_key is deprecated. Knife plugin authors should access the config hash directly, which does correct merging of cli and config options.") if fallback_key.nil?
1063
+ Chef.deprecated(:knife_bootstrap_apis, "Use of config_value is deprecated. Knife plugin authors should access the config hash directly, which does correct merging of cli and config options.")
1055
1064
  if config.key?(key)
1056
1065
  # the first key is the primary key so we check the merged hash first
1057
1066
  config[key]
@@ -23,9 +23,6 @@ require_relative "../knife"
23
23
  class Chef
24
24
  class Knife
25
25
  class CookbookUpload < Knife
26
- CHECKSUM = "checksum".freeze
27
- MATCH_CHECKSUM = /[0-9a-f]{32,}/.freeze
28
-
29
26
  deps do
30
27
  require_relative "../mixin/file_class"
31
28
  include Chef::Mixin::FileClass
@@ -245,7 +242,7 @@ class Chef
245
242
  # manifest object, but the manifest becomes invalid when you
246
243
  # regenerate the metadata
247
244
  broken_files = cookbook.dup.manifest_records_by_path.select do |path, info|
248
- info[CHECKSUM].nil? || info[CHECKSUM] !~ MATCH_CHECKSUM
245
+ !/[0-9a-f]{32,}/.match?(info["checksum"])
249
246
  end
250
247
  unless broken_files.empty?
251
248
  broken_filenames = Array(broken_files).map { |path, info| path }
@@ -28,7 +28,7 @@ class Chef
28
28
  # bootstrap templates. For backwards compatibility, they +must+ set the
29
29
  # following instance variables:
30
30
  # * @config - a hash of knife's config values
31
- # * @run_list - the run list for the node to boostrap
31
+ # * @run_list - the run list for the node to bootstrap
32
32
  #
33
33
  class BootstrapContext
34
34
 
@@ -27,7 +27,7 @@ class Chef
27
27
  # bootstrap templates. For backwards compatibility, they +must+ set the
28
28
  # following instance variables:
29
29
  # * @config - a hash of knife's config values
30
- # * @run_list - the run list for the node to boostrap
30
+ # * @run_list - the run list for the node to bootstrap
31
31
  #
32
32
  class WindowsBootstrapContext < BootstrapContext
33
33
  attr_accessor :config
@@ -460,7 +460,7 @@ class Chef
460
460
  property :umask, String,
461
461
  desired_state: false,
462
462
  introduced: "16.2",
463
- description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask."
463
+ description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask. Unsupported on Windows because Windows lacks a direct equivalent to UNIX's umask."
464
464
 
465
465
  # The time it took (in seconds) to run the most recently-run action. Not
466
466
  # cumulative across actions. This is set to 0 as soon as a new action starts
@@ -38,7 +38,7 @@ class Chef
38
38
  end
39
39
  ```
40
40
 
41
- **Install Virtualbox from the .mpkg**:
41
+ **Install VirtualBox from the .mpkg**:
42
42
 
43
43
  ```ruby
44
44
  dmg_package 'Virtualbox' do
@@ -68,7 +68,7 @@ class Chef
68
68
  # check. According to `man 5 launchd.plist`:
69
69
  # StartCalendarInterval <dictionary of integers or array of dictionaries of integers>
70
70
  # ... Missing arguments are considered to be wildcard.
71
- # What the man page doesn't state, but what was observed (OSX 10.11.5, launchctrl v3.4.0)
71
+ # What the man page doesn't state, but what was observed (OSX 10.11.5, launchctl v3.4.0)
72
72
  # Is that keys that are specified, but invalid, will also be treated as a wildcard
73
73
  # this means that an entry like:
74
74
  # { "Hour"=>0, "Weekday"=>"6-7"}
@@ -112,6 +112,15 @@ class Chef
112
112
  action :remove
113
113
  end
114
114
  ```
115
+
116
+ **Clear all users from the SeDenyNetworkLogonRight Privilege**:
117
+
118
+ ```ruby
119
+ windows_user_privilege 'Allow any user the Network Logon right' do
120
+ privilege 'SeDenyNetworkLogonRight'
121
+ action :clear
122
+ end
123
+ ```
115
124
  DOC
116
125
 
117
126
  property :principal, String,
@@ -132,8 +141,8 @@ class Chef
132
141
  }
133
142
 
134
143
  load_current_value do |new_resource|
135
- unless new_resource.principal.nil?
136
- privilege Chef::ReservedNames::Win32::Security.get_account_right(new_resource.principal) unless new_resource.action.include?(:set)
144
+ if new_resource.principal && (new_resource.action.include?(:add) || new_resource.action.include?(:remove))
145
+ privilege Chef::ReservedNames::Win32::Security.get_account_right(new_resource.principal)
137
146
  end
138
147
  end
139
148
 
@@ -180,6 +189,20 @@ class Chef
180
189
  end
181
190
  end
182
191
 
192
+ action :clear do
193
+ new_resource.privilege.each do |privilege|
194
+ accounts = Chef::ReservedNames::Win32::Security.get_account_with_user_rights(privilege)
195
+
196
+ # comparing the existing accounts for privilege with users
197
+ # Removing only accounts which is not matching with users in new_resource
198
+ accounts.each do |account|
199
+ converge_by("removing user '#{account}' from privilege #{privilege}") do
200
+ Chef::ReservedNames::Win32::Security.remove_account_right(account, privilege)
201
+ end
202
+ end
203
+ end
204
+ end
205
+
183
206
  action :remove do
184
207
  curr_res_privilege = current_resource.privilege
185
208
  missing_res_privileges = (new_resource.privilege - curr_res_privilege)
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("16.2.50")
26
+ VERSION = Chef::VersionString.new("16.2.73")
27
27
  end
28
28
 
29
29
  #
@@ -21,7 +21,7 @@ require "spec_helper"
21
21
  require "chef/knife/configure"
22
22
 
23
23
  describe "knife configure" do
24
- let (:ohai) do
24
+ let(:ohai) do
25
25
  OHAI_SYSTEM
26
26
  end
27
27
 
@@ -18,7 +18,6 @@
18
18
  #
19
19
 
20
20
  require "spec_helper"
21
- require "functional/resource/base"
22
21
  require "chef/mixin/shell_out"
23
22
 
24
23
  shared_examples "src service" do
@@ -80,6 +79,16 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
80
79
  shell_out("id -u #{ENV["USER"]}").stdout.chomp
81
80
  end
82
81
 
82
+ let(:run_context) do
83
+ node = Chef::Node.new
84
+ node.default[:platform] = ohai[:platform]
85
+ node.default[:platform_version] = ohai[:platform_version]
86
+ node.default[:os] = ohai[:os]
87
+ events = Chef::EventDispatch::Dispatcher.new
88
+ Chef::RunContext.new(node, {}, events)
89
+ end
90
+
91
+
83
92
  describe "When service is a subsystem" do
84
93
  before(:all) do
85
94
  script_dir = File.join(File.dirname(__FILE__), "/../assets/")
@@ -18,7 +18,6 @@
18
18
  #
19
19
 
20
20
  require "spec_helper"
21
- require "functional/resource/base"
22
21
  require "chef/mixin/shell_out"
23
22
  require "fileutils"
24
23
 
@@ -57,6 +56,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
57
56
 
58
57
  # Actual tests
59
58
  let(:new_resource) do
59
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
60
60
  new_resource = Chef::Resource::Service.new("chefinittest", run_context)
61
61
  new_resource.provider Chef::Provider::Service::AixInit
62
62
  new_resource.supports({ status: true, restart: true, reload: true })
@@ -17,18 +17,19 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- require "functional/resource/base"
21
20
 
22
21
  describe Chef::Resource::Bash, :unix_only do
23
22
  let(:code) { "echo hello" }
24
23
  let(:resource) do
24
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
25
+
25
26
  resource = Chef::Resource::Bash.new("foo_resource", run_context)
26
27
  resource.code(code) unless code.nil?
27
28
  resource
28
29
  end
29
30
 
30
31
  describe "when setting the command property" do
31
- let (:command) { "wizard racket" }
32
+ let(:command) { "wizard racket" }
32
33
 
33
34
  it "should raise an exception when trying to set the command" do
34
35
  expect { resource.command command }.to raise_error(Chef::Exceptions::Script)
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "functional/resource/base"
20
19
  require "chef/mixin/shell_out"
21
20
 
22
21
  # Run the test only for AIX platform.
@@ -24,6 +23,7 @@ describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] !
24
23
  include Chef::Mixin::ShellOut
25
24
 
26
25
  let(:new_resource) do
26
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
27
27
  new_resource = Chef::Resource::BffPackage.new(@pkg_name, run_context)
28
28
  new_resource.source @pkg_path
29
29
  new_resource
@@ -25,6 +25,10 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
25
25
  let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
26
26
  let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
27
27
 
28
+ let(:run_context) do
29
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
30
+ end
31
+
28
32
  subject do
29
33
  new_resource = Chef::Resource::ChocolateyPackage.new("test choco package", run_context)
30
34
  new_resource.package_name package_name
@@ -18,7 +18,6 @@
18
18
  #
19
19
 
20
20
  require "spec_helper"
21
- require "functional/resource/base"
22
21
  require "chef/mixin/shell_out"
23
22
 
24
23
  describe Chef::Resource::Cron, :requires_root, :unix_only do
@@ -53,6 +52,16 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
53
52
  end
54
53
 
55
54
  # Actual tests
55
+
56
+ let(:run_context) do
57
+ node = Chef::Node.new
58
+ node.default[:platform] = ohai[:platform]
59
+ node.default[:platform_version] = ohai[:platform_version]
60
+ node.default[:os] = ohai[:os]
61
+ events = Chef::EventDispatch::Dispatcher.new
62
+ Chef::RunContext.new(node, {}, events)
63
+ end
64
+
56
65
  let(:new_resource) do
57
66
  new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context)
58
67
  new_resource.user "root"
@@ -16,7 +16,6 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
- require "functional/resource/base"
20
19
  require "chef/mixin/shell_out"
21
20
 
22
21
  # run this test only for following platforms.
@@ -66,6 +65,10 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
66
65
  FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
67
66
  end
68
67
 
68
+ let(:run_context) do
69
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
70
+ end
71
+
69
72
  let(:package_name) { "chef_rpm" }
70
73
  let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) }
71
74