chef 15.12.22-universal-mingw32 → 15.16.4-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/Rakefile +11 -17
  4. data/chef-universal-mingw32.gemspec +4 -4
  5. data/chef.gemspec +22 -4
  6. data/lib/chef/api_client/registration.rb +2 -2
  7. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  8. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  9. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  10. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  11. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  13. data/lib/chef/deprecated.rb +4 -0
  14. data/lib/chef/environment.rb +2 -2
  15. data/lib/chef/exceptions.rb +3 -0
  16. data/lib/chef/http.rb +2 -1
  17. data/lib/chef/knife/bootstrap.rb +3 -3
  18. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  19. data/lib/chef/knife/cookbook_download.rb +1 -1
  20. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  21. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  22. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  23. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  24. data/lib/chef/knife/exec.rb +2 -2
  25. data/lib/chef/knife/ssh.rb +20 -1
  26. data/lib/chef/log.rb +1 -1
  27. data/lib/chef/mixin/openssl_helper.rb +26 -3
  28. data/lib/chef/mixin/template.rb +1 -0
  29. data/lib/chef/node_map.rb +5 -2
  30. data/lib/chef/provider/mount/solaris.rb +0 -1
  31. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
  32. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  33. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  34. data/lib/chef/provider/package/zypper.rb +0 -1
  35. data/lib/chef/provider/service/arch.rb +2 -2
  36. data/lib/chef/provider/service/debian.rb +1 -1
  37. data/lib/chef/provider/service/gentoo.rb +2 -2
  38. data/lib/chef/provider/service/macosx.rb +2 -2
  39. data/lib/chef/provider/service/openbsd.rb +1 -1
  40. data/lib/chef/provider/service/redhat.rb +2 -2
  41. data/lib/chef/provider/service/upstart.rb +1 -1
  42. data/lib/chef/provider/yum_repository.rb +1 -1
  43. data/lib/chef/provider/zypper_repository.rb +1 -1
  44. data/lib/chef/resource.rb +2 -0
  45. data/lib/chef/resource/cron_access.rb +2 -2
  46. data/lib/chef/resource/cron_d.rb +2 -1
  47. data/lib/chef/resource/homebrew_cask.rb +3 -3
  48. data/lib/chef/resource/hostname.rb +18 -18
  49. data/lib/chef/resource/locale.rb +1 -1
  50. data/lib/chef/resource/lwrp_base.rb +7 -0
  51. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  52. data/lib/chef/resource/sudo.rb +2 -2
  53. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  54. data/lib/chef/resource/windows_font.rb +2 -1
  55. data/lib/chef/role.rb +2 -2
  56. data/lib/chef/shell.rb +32 -1
  57. data/lib/chef/shell/shell_session.rb +2 -0
  58. data/lib/chef/util/diff.rb +1 -1
  59. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  60. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  61. data/lib/chef/version.rb +2 -2
  62. data/lib/chef/version_string.rb +1 -1
  63. data/lib/chef/win32/file.rb +2 -2
  64. data/spec/functional/knife/ssh_spec.rb +4 -4
  65. data/spec/functional/resource/aix_service_spec.rb +0 -1
  66. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  67. data/spec/functional/resource/apt_package_spec.rb +0 -1
  68. data/spec/functional/resource/bff_spec.rb +2 -2
  69. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  70. data/spec/functional/resource/cron_spec.rb +0 -1
  71. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  72. data/spec/functional/resource/insserv_spec.rb +4 -5
  73. data/spec/functional/resource/link_spec.rb +17 -17
  74. data/spec/functional/resource/rpm_spec.rb +2 -2
  75. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  76. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  77. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  78. data/spec/functional/resource/windows_font_spec.rb +49 -0
  79. data/spec/functional/run_lock_spec.rb +2 -1
  80. data/spec/functional/shell_spec.rb +5 -5
  81. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  82. data/spec/functional/version_spec.rb +1 -1
  83. data/spec/functional/win32/service_manager_spec.rb +1 -1
  84. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  85. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  86. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  87. data/spec/integration/recipes/notifies_spec.rb +1 -1
  88. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  89. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  90. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  91. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  92. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  93. data/spec/scripts/ssl-serve.rb +1 -1
  94. data/spec/spec_helper.rb +10 -8
  95. data/spec/support/platform_helpers.rb +12 -42
  96. data/spec/support/platforms/win32/spec_service.rb +1 -1
  97. data/spec/support/shared/functional/directory_resource.rb +1 -1
  98. data/spec/support/shared/functional/execute_resource.rb +1 -1
  99. data/spec/support/shared/functional/file_resource.rb +2 -2
  100. data/spec/support/shared/functional/win32_service.rb +1 -1
  101. data/spec/support/shared/functional/windows_script.rb +3 -3
  102. data/spec/support/shared/integration/knife_support.rb +2 -5
  103. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  104. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  105. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  106. data/spec/unit/environment_spec.rb +7 -7
  107. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  108. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  109. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  110. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  111. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  112. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  113. data/spec/unit/knife/ssh_spec.rb +2 -2
  114. data/spec/unit/knife/supermarket_share_spec.rb +5 -3
  115. data/spec/unit/lwrp_spec.rb +4 -4
  116. data/spec/unit/mixin/securable_spec.rb +0 -1
  117. data/spec/unit/property_spec.rb +5 -5
  118. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  119. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  120. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  121. data/spec/unit/provider/package/windows_spec.rb +30 -53
  122. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  123. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  124. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  125. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  126. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  127. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  128. data/spec/unit/provider/service/windows_spec.rb +2 -6
  129. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  130. data/spec/unit/provider_spec.rb +1 -0
  131. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  132. data/spec/unit/resource/windows_package_spec.rb +1 -0
  133. data/spec/unit/role_spec.rb +11 -11
  134. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  135. data/spec/unit/win32/security_spec.rb +4 -3
  136. metadata +48 -29
@@ -97,7 +97,7 @@ class Chef
97
97
  # @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
98
98
  #
99
99
  def generate_locales
100
- shell_out!("locale-gen #{unavailable_locales.join(" ")}")
100
+ shell_out!("locale-gen #{unavailable_locales.join(" ")}", timeout: 1800)
101
101
  end
102
102
 
103
103
  # Updates system locale by appropriately writing them in /etc/locale.conf
@@ -65,6 +65,12 @@ class Chef
65
65
 
66
66
  LWRPBase.loaded_lwrps[filename] = true
67
67
 
68
+ unless resource_class.resource_name.nil?
69
+ if Chef.resource_handler_map.get(node, resource_class.resource_name, canonical: true) == resource_class
70
+ Chef.deprecated(:resource_name_without_provides, "Resource #{resource_class.resource_name} needs `provides :#{resource_class.resource_name}` in addition to `resource_name :#{resource_class.resource_name}` declaration")
71
+ end
72
+ end
73
+
68
74
  # wire up the default resource name after the class is parsed only if we haven't declared one.
69
75
  # (this ordering is important for MapCollision deprecation warnings)
70
76
  resource_class.resource_name resource_name.to_sym if resource_class.resource_name.nil?
@@ -103,6 +109,7 @@ class Chef
103
109
  protected
104
110
 
105
111
  attr_writer :loaded_lwrps
112
+
106
113
  def loaded_lwrps
107
114
  @loaded_lwrps ||= {}
108
115
  end
@@ -88,7 +88,7 @@ class Chef
88
88
 
89
89
  r = with_run_context :root do
90
90
  find_resource(:template, "update ssh known hosts file #{new_resource.file_location}") do
91
- source ::File.expand_path("../support/ssh_known_hosts.erb", __FILE__)
91
+ source ::File.expand_path("support/ssh_known_hosts.erb", __dir__)
92
92
  local true
93
93
  path new_resource.file_location
94
94
  owner new_resource.owner
@@ -172,7 +172,7 @@ class Chef
172
172
  end
173
173
  else
174
174
  declare_resource(:template, file_path) do
175
- source ::File.expand_path("../support/sudoer.erb", __FILE__)
175
+ source ::File.expand_path("support/sudoer.erb", __dir__)
176
176
  local true
177
177
  mode "0440"
178
178
  variables sudoer: (new_resource.groups + new_resource.users).join(","),
@@ -228,7 +228,7 @@ class Chef
228
228
  end
229
229
 
230
230
  def visudo_content(path)
231
- if ::File.exists?(path)
231
+ if ::File.exist?(path)
232
232
  "cat #{new_resource.config_prefix}/sudoers | #{new_resource.visudo_binary} -cf - && #{new_resource.visudo_binary} -cf %{path}"
233
233
  else
234
234
  "cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -"
@@ -163,8 +163,12 @@ class Chef
163
163
 
164
164
  # @return [Array] features the user has requested to install which need installation
165
165
  def features_to_install
166
- # the intersection of the features to install & disabled features are what needs installing
167
- @install ||= new_resource.feature_name & node["powershell_features_cache"]["disabled"]
166
+ # the intersection of the features to install & disabled/removed features are what needs installing
167
+ @features_to_install ||= begin
168
+ features = node["powershell_features_cache"]["disabled"]
169
+ features |= node["powershell_features_cache"]["removed"] if new_resource.source
170
+ new_resource.feature_name & features
171
+ end
168
172
  end
169
173
 
170
174
  # @return [Array] features the user has requested to remove which need removing
@@ -90,8 +90,9 @@ class Chef
90
90
  def font_exists?
91
91
  require "win32ole" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
92
92
  fonts_dir = WIN32OLE.new("WScript.Shell").SpecialFolders("Fonts")
93
+ fonts_dir_local = Chef::Util::PathHelper.join(ENV["home"], "AppData/Local/Microsoft/Windows/fonts")
93
94
  logger.trace("Seeing if the font at #{Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)} exists")
94
- ::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name))
95
+ ::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)) || ::File.exist?(Chef::Util::PathHelper.join(fonts_dir_local, new_resource.font_name))
95
96
  end
96
97
 
97
98
  # Parse out the schema provided to us to see if it's one we support via remote_file.
data/lib/chef/role.rb CHANGED
@@ -257,11 +257,11 @@ class Chef
257
257
 
258
258
  js_path, rb_path = js_files.first, rb_files.first
259
259
 
260
- if js_path && File.exists?(js_path)
260
+ if js_path && File.exist?(js_path)
261
261
  # from_json returns object.class => json_class in the JSON.
262
262
  hsh = Chef::JSONCompat.parse(IO.read(js_path))
263
263
  return from_hash(hsh)
264
- elsif rb_path && File.exists?(rb_path)
264
+ elsif rb_path && File.exist?(rb_path)
265
265
  role = Chef::Role.new
266
266
  role.name(name)
267
267
  role.from_file(rb_path)
data/lib/chef/shell.rb CHANGED
@@ -19,6 +19,7 @@ require "singleton" unless defined?(Singleton)
19
19
  require "pp" unless defined?(PP)
20
20
  require "etc" unless defined?(Etc)
21
21
  require "mixlib/cli" unless defined?(Mixlib::CLI)
22
+ require "chef-config/mixin/dot_d"
22
23
 
23
24
  require_relative "../chef"
24
25
  require_relative "version"
@@ -199,6 +200,7 @@ module Shell
199
200
 
200
201
  class Options
201
202
  include Mixlib::CLI
203
+ include ChefConfig::Mixin::DotD
202
204
 
203
205
  def self.footer(text = nil)
204
206
  @footer = text if text
@@ -314,15 +316,44 @@ module Shell
314
316
  # We have to nuke ARGV to make sure irb's option parser never sees it.
315
317
  # otherwise, IRB complains about command line switches it doesn't recognize.
316
318
  ARGV.clear
319
+
320
+ # This code should not exist.
321
+ # We should be using Application::Client and then calling load_config_file
322
+ # which does all this properly. However this will do for now.
317
323
  config[:config_file] = config_file_for_shell_mode(environment)
318
324
  config_msg = config[:config_file] || "none (standalone session)"
319
325
  puts "loading configuration: #{config_msg}"
320
- Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
326
+
327
+ # load the config (if we have one)
328
+ unless config[:config_file].nil?
329
+ if File.exist?(config[:config_file]) && File.readable?(config[:config_file])
330
+ Chef::Config.from_file(config[:config_file])
331
+ end
332
+
333
+ # even if we couldn't load that, we need to tell Chef::Config what
334
+ # the file was so it sets confdir and d_dir and such properly
335
+ Chef::Config[:config_file] = config[:config_file]
336
+
337
+ # now attempt to load any relevant dot-dirs
338
+ load_dot_d(Chef::Config[:client_d_dir]) if Chef::Config[:client_d_dir]
339
+ end
340
+
341
+ # finally merge command-line options in
321
342
  Chef::Config.merge!(config)
322
343
  end
323
344
 
324
345
  private
325
346
 
347
+ # shamelessly lifted from application.rb
348
+ def apply_config(config_content, config_file_path)
349
+ Chef::Config.from_string(config_content, config_file_path)
350
+ rescue Exception => error
351
+ logger.fatal("Configuration error #{error.class}: #{error.message}")
352
+ filtered_trace = error.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
353
+ filtered_trace.each { |line| logger.fatal(" " + line ) }
354
+ raise Chef::Exceptions::ConfigurationError.new("Aborting due to error in '#{config_file_path}': #{error}")
355
+ end
356
+
326
357
  def config_file_for_shell_mode(environment)
327
358
  dot_chef_dir = Chef::Util::PathHelper.home(".chef")
328
359
  if config[:config_file]
@@ -41,6 +41,7 @@ module Shell
41
41
 
42
42
  attr_accessor :node, :compile, :recipe, :json_configuration
43
43
  attr_reader :node_attributes, :client
44
+
44
45
  def initialize
45
46
  @node_built = false
46
47
  formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR)
@@ -75,6 +76,7 @@ module Shell
75
76
  end
76
77
 
77
78
  attr_writer :run_context
79
+
78
80
  def run_context
79
81
  @run_context ||= rebuild_context
80
82
  end
@@ -64,7 +64,7 @@ class Chef
64
64
 
65
65
  def use_tempfile_if_missing(file)
66
66
  tempfile = nil
67
- unless File.exists?(file)
67
+ unless File.exist?(file)
68
68
  Chef::Log.trace("File #{file} does not exist to diff against, using empty tempfile")
69
69
  tempfile = Tempfile.new("chef-diff")
70
70
  file = tempfile.path
@@ -64,7 +64,7 @@ class Chef::Util::DSC
64
64
  # The name may not be null or empty, and should start with a letter.
65
65
  def validate_configuration_name!(configuration_name)
66
66
  if !!(configuration_name =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false
67
- raise ArgumentError, 'Configuration `#{configuration_name}` is not a valid PowerShell cmdlet name'
67
+ raise ArgumentError, "Configuration `#{configuration_name}` is not a valid PowerShell cmdlet name"
68
68
  end
69
69
  end
70
70
 
@@ -164,7 +164,7 @@ class Chef
164
164
  end
165
165
 
166
166
  def self.destroy(name)
167
- proc { File.delete(name) if File.exists? name }
167
+ proc { File.delete(name) if File.exist? name }
168
168
  end
169
169
  end
170
170
  end
data/lib/chef/version.rb CHANGED
@@ -22,8 +22,8 @@
22
22
  require_relative "version_string"
23
23
 
24
24
  class Chef
25
- CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("15.12.22")
25
+ CHEF_ROOT = File.expand_path("..", __dir__)
26
+ VERSION = Chef::VersionString.new("15.16.4")
27
27
  end
28
28
 
29
29
  #
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "chef-utils/version_string"
16
+ require "chef-utils/version_string" unless defined?(ChefUtils::VersionString)
17
17
 
18
18
  class Chef
19
19
  VersionString = ChefUtils::VersionString
@@ -78,7 +78,7 @@ class Chef
78
78
  def self.symlink?(file_name)
79
79
  is_symlink = false
80
80
  path = encode_path(file_name)
81
- if ::File.exists?(file_name) || ::File.symlink?(file_name)
81
+ if ::File.exist?(file_name) || ::File.symlink?(file_name)
82
82
  if (GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0
83
83
  file_search_handle(file_name) do |handle, find_data|
84
84
  if find_data[:dw_reserved_0] == IO_REPARSE_TAG_SYMLINK
@@ -104,7 +104,7 @@ class Chef
104
104
  # will raise a NotImplementedError, as per MRI.
105
105
  #
106
106
  def self.readlink(link_name)
107
- raise Errno::ENOENT, link_name unless ::File.exists?(link_name) || ::File.symlink?(link_name)
107
+ raise Errno::ENOENT, link_name unless ::File.exist?(link_name) || ::File.symlink?(link_name)
108
108
 
109
109
  symlink_file_handle(link_name) do |handle|
110
110
  # Go to DeviceIoControl to get the symlink information
@@ -274,7 +274,7 @@ describe Chef::Knife::Ssh do
274
274
  end
275
275
 
276
276
  it "uses the ssh_gateway" do
277
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
277
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true })
278
278
  @knife.run
279
279
  expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
280
280
  end
@@ -287,7 +287,7 @@ describe Chef::Knife::Ssh do
287
287
  end
288
288
 
289
289
  it "uses the ssh_gateway" do
290
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
290
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true })
291
291
  @knife.run
292
292
  expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
293
293
  end
@@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do
301
301
  end
302
302
 
303
303
  it "uses the ssh_gateway_identity file" do
304
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
304
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true, keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
305
305
  @knife.run
306
306
  expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
307
307
  end
@@ -315,7 +315,7 @@ describe Chef::Knife::Ssh do
315
315
  end
316
316
 
317
317
  it "uses the ssh_gateway_identity file" do
318
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
318
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true, keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
319
319
  @knife.run
320
320
  expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
321
321
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -29,11 +28,11 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
29
28
  # Platform specific validation routines.
30
29
  def service_should_be_started(file_name)
31
30
  # The existence of this file indicates that the service was started.
32
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
31
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
33
32
  end
34
33
 
35
34
  def service_should_be_stopped(file_name)
36
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
35
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
37
36
  end
38
37
 
39
38
  def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
@@ -69,12 +68,12 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
69
68
  end
70
69
 
71
70
  before(:all) do
72
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
71
+ File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
73
72
  FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/chefinittest")).to_s, "/etc/rc.d/init.d/chefinittest")
74
73
  end
75
74
 
76
75
  after(:all) do
77
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
76
+ File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
78
77
  end
79
78
 
80
79
  before(:each) do
@@ -166,7 +165,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
166
165
  end
167
166
 
168
167
  after do
169
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
168
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
170
169
  end
171
170
 
172
171
  it "creates symlink with status K" do
@@ -182,7 +181,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
182
181
  end
183
182
 
184
183
  after do
185
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
184
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
186
185
  end
187
186
 
188
187
  it "creates a symlink with status K and a priority" do
@@ -199,7 +198,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
199
198
  end
200
199
 
201
200
  after do
202
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
201
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
203
202
  end
204
203
 
205
204
  it "create symlink with status stop (K) and a priority " do
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Daniel DeLeo (<dan@chef.io>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -31,12 +31,12 @@ describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] !
31
31
 
32
32
  def bff_pkg_should_be_installed(resource)
33
33
  expect(shell_out("lslpp -L #{resource.name}").exitstatus).to eq(0)
34
- ::File.exists?("/usr/PkgA/bin/acommand")
34
+ ::File.exist?("/usr/PkgA/bin/acommand")
35
35
  end
36
36
 
37
37
  def bff_pkg_should_be_removed(resource)
38
38
  expect(shell_out("lslpp -L #{resource.name}").exitstatus).to eq(1)
39
- !::File.exists?("/usr/PkgA/bin/acommand")
39
+ !::File.exist?("/usr/PkgA/bin/acommand")
40
40
  end
41
41
 
42
42
  before(:all) do
@@ -72,7 +72,7 @@ describe Chef::Resource::CookbookFile do
72
72
  end
73
73
 
74
74
  after do
75
- FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exists?(windows_non_temp_dir)
75
+ FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exist?(windows_non_temp_dir)
76
76
  end
77
77
 
78
78
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -62,7 +62,7 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
62
62
  end
63
63
 
64
64
  after do
65
- File.delete(tmp_file_name) if File.exists? tmp_file_name
65
+ File.delete(tmp_file_name) if File.exist? tmp_file_name
66
66
  end
67
67
 
68
68
  it "converges the resource if it is not converged" do
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Dheeraj Dubey (<dheeraj.dubey@msystechnologies.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -40,11 +39,11 @@ describe Chef::Resource::Service, :requires_root, :sles11 do
40
39
  # Platform specific validation routines.
41
40
  def service_should_be_started(file_name)
42
41
  # The existence of this file indicates that the service was started.
43
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
42
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
44
43
  end
45
44
 
46
45
  def service_should_be_stopped(file_name)
47
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
46
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
48
47
  end
49
48
 
50
49
  def delete_test_files
@@ -73,13 +72,13 @@ describe Chef::Resource::Service, :requires_root, :sles11 do
73
72
  end
74
73
 
75
74
  before(:all) do
76
- File.delete("/etc/init.d/inittest") if File.exists?("/etc/init.d/inittest")
75
+ File.delete("/etc/init.d/inittest") if File.exist?("/etc/init.d/inittest")
77
76
  FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/inittest")).to_s, "/etc/init.d/inittest")
78
77
  FileUtils.chmod(0755, "/etc/init.d/inittest")
79
78
  end
80
79
 
81
80
  after(:all) do
82
- File.delete("/etc/init.d/inittest") if File.exists?("/etc/init.d/inittest")
81
+ File.delete("/etc/init.d/inittest") if File.exist?("/etc/init.d/inittest")
83
82
  end
84
83
 
85
84
  before(:each) do
@@ -56,9 +56,9 @@ describe Chef::Resource::Link do
56
56
 
57
57
  after(:each) do
58
58
  begin
59
- cleanup_link(to) if File.exists?(to)
60
- cleanup_link(target_file) if File.exists?(target_file)
61
- cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
59
+ cleanup_link(to) if File.exist?(to)
60
+ cleanup_link(target_file) if File.exist?(target_file)
61
+ cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
62
62
  rescue
63
63
  puts "Could not remove a file: #{$!}"
64
64
  end
@@ -276,7 +276,7 @@ describe Chef::Resource::Link do
276
276
  resource.run_action(:create)
277
277
  end
278
278
  it "preserves the hard link" do
279
- expect(File.exists?(target_file)).to be_truthy
279
+ expect(File.exist?(target_file)).to be_truthy
280
280
  expect(symlink?(target_file)).to be_falsey
281
281
  # Writing to one hardlinked file should cause both
282
282
  # to have the new value.
@@ -301,7 +301,7 @@ describe Chef::Resource::Link do
301
301
  resource.run_action(:create)
302
302
  end
303
303
  it "links to the target file" do
304
- expect(File.exists?(target_file)).to be_truthy
304
+ expect(File.exist?(target_file)).to be_truthy
305
305
  expect(symlink?(target_file)).to be_falsey
306
306
  # Writing to one hardlinked file should cause both
307
307
  # to have the new value.
@@ -341,7 +341,7 @@ describe Chef::Resource::Link do
341
341
  include_context "delete succeeds"
342
342
  it "the :delete action does not delete the target file" do
343
343
  resource.run_action(:delete)
344
- expect(File.exists?(to)).to be_truthy
344
+ expect(File.exist?(to)).to be_truthy
345
345
  end
346
346
  end
347
347
  context "pointing somewhere else", :requires_root_or_running_windows do
@@ -369,7 +369,7 @@ describe Chef::Resource::Link do
369
369
  include_context "delete succeeds"
370
370
  it "the :delete action does not delete the target file" do
371
371
  resource.run_action(:delete)
372
- expect(File.exists?(to)).to be_truthy
372
+ expect(File.exist?(to)).to be_truthy
373
373
  end
374
374
  end
375
375
  context "pointing nowhere" do
@@ -386,7 +386,7 @@ describe Chef::Resource::Link do
386
386
  context "and the link already exists and is a hard link to the file" do
387
387
  before(:each) do
388
388
  link(to, target_file)
389
- expect(File.exists?(target_file)).to be_truthy
389
+ expect(File.exist?(target_file)).to be_truthy
390
390
  expect(symlink?(target_file)).to be_falsey
391
391
  end
392
392
  include_context "create symbolic link succeeds"
@@ -406,7 +406,7 @@ describe Chef::Resource::Link do
406
406
  it "create errors out" do
407
407
  if windows?
408
408
  expect { resource.run_action(:create) }.to raise_error(Errno::EACCES)
409
- elsif os_x? || solaris? || freebsd? || aix?
409
+ elsif macos? || solaris? || freebsd? || aix?
410
410
  expect { resource.run_action(:create) }.to raise_error(Errno::EPERM)
411
411
  else
412
412
  expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR)
@@ -585,14 +585,14 @@ describe Chef::Resource::Link do
585
585
  context "and the link already exists and is a hard link to the file" do
586
586
  before(:each) do
587
587
  link(to, target_file)
588
- expect(File.exists?(target_file)).to be_truthy
588
+ expect(File.exist?(target_file)).to be_truthy
589
589
  expect(symlink?(target_file)).to be_falsey
590
590
  end
591
591
  include_context "create hard link is noop"
592
592
  include_context "delete succeeds"
593
593
  it "the :delete action does not delete the target file" do
594
594
  resource.run_action(:delete)
595
- expect(File.exists?(to)).to be_truthy
595
+ expect(File.exist?(to)).to be_truthy
596
596
  end
597
597
  end
598
598
  context "and the link already exists and is a file" do
@@ -609,7 +609,7 @@ describe Chef::Resource::Link do
609
609
  it "errors out" do
610
610
  if windows?
611
611
  expect { resource.run_action(:create) }.to raise_error(Errno::EACCES)
612
- elsif os_x? || solaris? || freebsd? || aix?
612
+ elsif macos? || solaris? || freebsd? || aix?
613
613
  expect { resource.run_action(:create) }.to raise_error(Errno::EPERM)
614
614
  else
615
615
  expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR)
@@ -656,10 +656,10 @@ describe Chef::Resource::Link do
656
656
  end
657
657
  context "and the link does not yet exist" do
658
658
  it "links to the target file" do
659
- skip("OS X/FreeBSD/AIX/Solaris symlink? and readlink working on hard links to symlinks") if os_x? || freebsd? || aix? || solaris?
659
+ skip("macOS/FreeBSD/AIX/Solaris symlink? and readlink working on hard links to symlinks") if macos? || freebsd? || aix? || solaris?
660
660
  resource.run_action(:create)
661
- expect(File.exists?(target_file)).to be_truthy
662
- # OS X gets angry about this sort of link. Bug in OS X, IMO.
661
+ expect(File.exist?(target_file)).to be_truthy
662
+ # macOS gets angry about this sort of link. Bug in macOS, IMO.
663
663
  expect(symlink?(target_file)).to be_truthy
664
664
  expect(readlink(target_file)).to eq(canonicalize(@other_target))
665
665
  end
@@ -675,9 +675,9 @@ describe Chef::Resource::Link do
675
675
  end
676
676
  context "and the link does not yet exist" do
677
677
  it "links to the target file" do
678
- skip("OS X/FreeBSD/AIX/Solaris fails to create hardlinks to broken symlinks") if os_x? || freebsd? || aix? || solaris?
678
+ skip("macOS/FreeBSD/AIX/Solaris fails to create hardlinks to broken symlinks") if macos? || freebsd? || aix? || solaris?
679
679
  resource.run_action(:create)
680
- expect(File.exists?(target_file) || File.symlink?(target_file)).to be_truthy
680
+ expect(File.exist?(target_file) || File.symlink?(target_file)).to be_truthy
681
681
  expect(symlink?(target_file)).to be_truthy
682
682
  expect(readlink(target_file)).to eq(canonicalize(@other_target))
683
683
  end