chef 15.10.12-universal-mingw32 → 15.14.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/README.md +3 -3
  4. data/Rakefile +1 -1
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +3 -3
  7. data/distro/powershell/chef/chef.psm1 +3 -3
  8. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  9. data/lib/chef/api_client/registration.rb +2 -2
  10. data/lib/chef/application/apply.rb +2 -2
  11. data/lib/chef/application/exit_code.rb +2 -2
  12. data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
  13. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  20. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  21. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  22. data/lib/chef/chef_fs/path_utils.rb +3 -3
  23. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +4 -4
  25. data/lib/chef/data_bag.rb +2 -2
  26. data/lib/chef/data_collector/error_handlers.rb +1 -1
  27. data/lib/chef/deprecated.rb +13 -1
  28. data/lib/chef/dsl/declare_resource.rb +1 -1
  29. data/lib/chef/dsl/platform_introspection.rb +3 -1
  30. data/lib/chef/environment.rb +2 -2
  31. data/lib/chef/exceptions.rb +3 -0
  32. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
  33. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
  34. data/lib/chef/http.rb +2 -1
  35. data/lib/chef/knife.rb +26 -20
  36. data/lib/chef/knife/bootstrap.rb +30 -31
  37. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
  38. data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
  39. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  40. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
  41. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  42. data/lib/chef/knife/cookbook_download.rb +1 -1
  43. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  44. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  45. data/lib/chef/knife/cookbook_site_show.rb +1 -1
  46. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  47. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  48. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  49. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  50. data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
  51. data/lib/chef/knife/exec.rb +2 -2
  52. data/lib/chef/knife/ssh.rb +21 -2
  53. data/lib/chef/log.rb +1 -1
  54. data/lib/chef/mixin/create_path.rb +8 -8
  55. data/lib/chef/mixin/openssl_helper.rb +26 -3
  56. data/lib/chef/mixin/template.rb +1 -0
  57. data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
  58. data/lib/chef/node_map.rb +5 -2
  59. data/lib/chef/provider/mount/solaris.rb +0 -1
  60. data/lib/chef/provider/package/cab.rb +1 -1
  61. data/lib/chef/provider/package/chocolatey.rb +4 -3
  62. data/lib/chef/provider/package/msu.rb +1 -0
  63. data/lib/chef/provider/package/powershell.rb +5 -1
  64. data/lib/chef/provider/package/snap.rb +96 -27
  65. data/lib/chef/provider/package/zypper.rb +0 -1
  66. data/lib/chef/provider/service/arch.rb +2 -2
  67. data/lib/chef/provider/service/debian.rb +1 -1
  68. data/lib/chef/provider/service/gentoo.rb +2 -2
  69. data/lib/chef/provider/service/macosx.rb +2 -2
  70. data/lib/chef/provider/service/openbsd.rb +1 -1
  71. data/lib/chef/provider/service/redhat.rb +2 -2
  72. data/lib/chef/provider/service/simple.rb +3 -3
  73. data/lib/chef/provider/service/upstart.rb +1 -1
  74. data/lib/chef/provider/windows_task.rb +1 -1
  75. data/lib/chef/provider/yum_repository.rb +1 -1
  76. data/lib/chef/provider/zypper_repository.rb +31 -11
  77. data/lib/chef/resource.rb +2 -0
  78. data/lib/chef/resource/archive_file.rb +28 -8
  79. data/lib/chef/resource/build_essential.rb +1 -1
  80. data/lib/chef/resource/cron_access.rb +13 -5
  81. data/lib/chef/resource/cron_d.rb +1 -1
  82. data/lib/chef/resource/hostname.rb +19 -18
  83. data/lib/chef/resource/launchd.rb +4 -4
  84. data/lib/chef/resource/lwrp_base.rb +7 -0
  85. data/lib/chef/resource/macos_userdefaults.rb +3 -3
  86. data/lib/chef/resource/msu_package.rb +5 -0
  87. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  88. data/lib/chef/resource/sudo.rb +2 -2
  89. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  90. data/lib/chef/resource/windows_firewall_rule.rb +8 -4
  91. data/lib/chef/resource/windows_font.rb +2 -1
  92. data/lib/chef/resource/windows_share.rb +4 -4
  93. data/lib/chef/resource/windows_task.rb +13 -13
  94. data/lib/chef/resource_inspector.rb +4 -3
  95. data/lib/chef/role.rb +2 -2
  96. data/lib/chef/shell.rb +1 -1
  97. data/lib/chef/shell/shell_session.rb +2 -0
  98. data/lib/chef/util/diff.rb +1 -1
  99. data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
  100. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  101. data/lib/chef/version.rb +2 -2
  102. data/lib/chef/win32/api/command_line_helper.rb +89 -0
  103. data/lib/chef/win32/api/file.rb +18 -18
  104. data/lib/chef/win32/file.rb +3 -3
  105. data/lib/chef/win32/process.rb +2 -2
  106. data/spec/functional/knife/ssh_spec.rb +4 -4
  107. data/spec/functional/resource/aix_service_spec.rb +0 -1
  108. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  109. data/spec/functional/resource/apt_package_spec.rb +0 -1
  110. data/spec/functional/resource/bff_spec.rb +2 -2
  111. data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
  112. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  113. data/spec/functional/resource/cron_spec.rb +0 -1
  114. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  115. data/spec/functional/resource/insserv_spec.rb +4 -5
  116. data/spec/functional/resource/link_spec.rb +17 -17
  117. data/spec/functional/resource/msu_package_spec.rb +5 -2
  118. data/spec/functional/resource/rpm_spec.rb +2 -2
  119. data/spec/functional/resource/user/dscl_spec.rb +2 -2
  120. data/spec/functional/resource/user/mac_user_spec.rb +2 -2
  121. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  122. data/spec/functional/resource/windows_font_spec.rb +49 -0
  123. data/spec/functional/resource/windows_task_spec.rb +8 -8
  124. data/spec/functional/run_lock_spec.rb +2 -1
  125. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  126. data/spec/functional/version_spec.rb +1 -1
  127. data/spec/functional/win32/service_manager_spec.rb +1 -1
  128. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  129. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  130. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  131. data/spec/integration/recipes/notifies_spec.rb +1 -1
  132. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  133. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  134. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  135. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  136. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  137. data/spec/scripts/ssl-serve.rb +1 -1
  138. data/spec/spec_helper.rb +26 -19
  139. data/spec/support/chef_helpers.rb +1 -1
  140. data/spec/support/platform_helpers.rb +12 -42
  141. data/spec/support/platforms/win32/spec_service.rb +1 -1
  142. data/spec/support/shared/functional/directory_resource.rb +1 -1
  143. data/spec/support/shared/functional/execute_resource.rb +1 -1
  144. data/spec/support/shared/functional/file_resource.rb +3 -3
  145. data/spec/support/shared/functional/win32_service.rb +1 -1
  146. data/spec/support/shared/functional/windows_script.rb +3 -3
  147. data/spec/support/shared/integration/knife_support.rb +2 -5
  148. data/spec/unit/application_spec.rb +7 -0
  149. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  150. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  151. data/spec/unit/data_bag_spec.rb +1 -1
  152. data/spec/unit/data_collector_spec.rb +1 -1
  153. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  154. data/spec/unit/environment_spec.rb +7 -7
  155. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  156. data/spec/unit/file_access_control_spec.rb +1 -1
  157. data/spec/unit/json_compat_spec.rb +1 -1
  158. data/spec/unit/knife/bootstrap_spec.rb +26 -29
  159. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  160. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  161. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  162. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  163. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
  164. data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
  165. data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
  166. data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
  167. data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
  168. data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
  169. data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
  170. data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
  171. data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
  172. data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
  173. data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
  174. data/spec/unit/knife/ssh_spec.rb +2 -2
  175. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  176. data/spec/unit/lwrp_spec.rb +4 -4
  177. data/spec/unit/mixin/securable_spec.rb +0 -1
  178. data/spec/unit/mixin/user_context_spec.rb +1 -9
  179. data/spec/unit/property_spec.rb +6 -6
  180. data/spec/unit/provider/apt_repository_spec.rb +2 -2
  181. data/spec/unit/provider/git_spec.rb +3 -3
  182. data/spec/unit/provider/osx_profile_spec.rb +2 -2
  183. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  184. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  185. data/spec/unit/provider/package/msu_spec.rb +3 -3
  186. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  187. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  188. data/spec/unit/provider/package/snap_spec.rb +1 -1
  189. data/spec/unit/provider/package/windows_spec.rb +30 -53
  190. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  191. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  192. data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
  193. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  194. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  195. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  196. data/spec/unit/provider/service/windows_spec.rb +2 -6
  197. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  198. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  199. data/spec/unit/provider_resolver_spec.rb +9 -9
  200. data/spec/unit/provider_spec.rb +1 -0
  201. data/spec/unit/resource/archive_file_spec.rb +11 -2
  202. data/spec/unit/resource/msu_package_spec.rb +4 -0
  203. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  204. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  205. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  206. data/spec/unit/resource/windows_package_spec.rb +1 -0
  207. data/spec/unit/resource/windows_task_spec.rb +1 -1
  208. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  209. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  210. data/spec/unit/resource_reporter_spec.rb +1 -1
  211. data/spec/unit/resource_spec.rb +1 -1
  212. data/spec/unit/role_spec.rb +11 -11
  213. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  214. data/spec/unit/run_context_spec.rb +1 -1
  215. data/spec/unit/run_lock_spec.rb +1 -1
  216. data/spec/unit/scan_access_control_spec.rb +1 -1
  217. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  218. data/spec/unit/win32/security_spec.rb +4 -3
  219. data/tasks/rspec.rb +5 -13
  220. metadata +32 -18
@@ -68,8 +68,8 @@ module ResourceInspector
68
68
  dir, name = File.split(path)
69
69
  Chef::Cookbook::FileVendor.fetch_from_disk(path)
70
70
  loader = Chef::CookbookLoader.new(dir)
71
- cookbooks = loader.load_cookbooks
72
- resources = cookbooks[name].files_for(:resources)
71
+ cookbook = loader.load_cookbook(name)
72
+ resources = cookbook.files_for(:resources)
73
73
 
74
74
  resources.each_with_object({}) do |r, res|
75
75
  pth = r["full_path"]
@@ -82,13 +82,14 @@ module ResourceInspector
82
82
  # otherwise, if we have a path then extract all the resources from the cookbook
83
83
  # or else do a list of built in resources
84
84
  #
85
+ # @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect
85
86
  # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
86
87
  # @return [String] JSON formatting of all resources
87
88
  def self.inspect(arguments = [], complete: false)
88
89
  output = if arguments.empty?
89
90
  ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
90
91
  else
91
- arguments.each_with_object({}) do |arg, acc|
92
+ Array(arguments).each_with_object({}) do |arg, acc|
92
93
  if File.directory?(arg)
93
94
  extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
94
95
  else
@@ -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)
@@ -317,7 +317,7 @@ module Shell
317
317
  config[:config_file] = config_file_for_shell_mode(environment)
318
318
  config_msg = config[:config_file] || "none (standalone session)"
319
319
  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])
320
+ Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exist?(config[:config_file]) && File.readable?(config[:config_file])
321
321
  Chef::Config.merge!(config)
322
322
  end
323
323
 
@@ -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
@@ -160,9 +160,9 @@ class Chef
160
160
 
161
161
  def self.parse_line(line)
162
162
  if match = line.match(/^.*?:.*?:\s*LCM:\s*\[(.*?)\](.*)/)
163
- # If the line looks like
164
- # What If: [machinename]: LCM: [op_action op_type] message
165
- # extract op_action, op_type, and message
163
+ # If the line looks like
164
+ # What If: [machinename]: LCM: [op_action op_type] message
165
+ # extract op_action, op_type, and message
166
166
  operation, info = match.captures
167
167
  op_action, op_type = operation.strip.split(" ").map { |m| m.downcase.to_sym }
168
168
  else
@@ -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
@@ -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.10.12")
25
+ CHEF_ROOT = File.expand_path("..", __dir__)
26
+ VERSION = Chef::VersionString.new("15.14.0")
27
27
  end
28
28
 
29
29
  #
@@ -0,0 +1,89 @@
1
+ #
2
+ # Author:: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
3
+ # Copyright:: Copyright 2013-2020, Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "../api"
20
+
21
+ class Chef
22
+ module ReservedNames::Win32
23
+ module API
24
+ module CommandLineHelper
25
+ # extend Chef::ReservedNames::Win32
26
+ extend Chef::ReservedNames::Win32::API
27
+
28
+ ###############################################
29
+ # Win32 API Bindings
30
+ ###############################################
31
+
32
+ ffi_lib "Shell32"
33
+
34
+ =begin
35
+ LPWSTR * CommandLineToArgvW(
36
+ LPCWSTR lpCmdLine,
37
+ int *pNumArgs
38
+ );
39
+ =end
40
+
41
+ safe_attach_function :command_line_to_argv_w, :CommandLineToArgvW, %i{pointer pointer}, :pointer
42
+
43
+ ffi_lib "Kernel32"
44
+
45
+ =begin
46
+ LPSTR GetCommandLineA();
47
+ =end
48
+
49
+ safe_attach_function :get_command_line, :GetCommandLineA, [], :pointer
50
+
51
+ =begin
52
+ HLOCAL LocalFree(
53
+ _Frees_ptr_opt_ HLOCAL hMem
54
+ );
55
+ =end
56
+
57
+ safe_attach_function :local_free, :LocalFree, [:pointer], :pointer
58
+
59
+ ###############################################
60
+ # Helpers
61
+ ###############################################
62
+
63
+ # It takes the supplied string and splits it into an array.
64
+ def command_line_to_argv_w_helper(args)
65
+ arguments_list = []
66
+ argv = args.to_wstring
67
+ result = get_command_line
68
+ argc = FFI::MemoryPointer.new(:int)
69
+
70
+ # Parses a Unicode command line string
71
+ # It is return an array of pointers to the command line arguments.
72
+ # Along with a count of such arguments
73
+ result = command_line_to_argv_w(argv, argc)
74
+ str_ptr = result.read_pointer
75
+ offset = 0
76
+ number_of_agrs = argc.read_int
77
+ number_of_agrs.times do
78
+ new_str_pointer = str_ptr.+(offset)
79
+ argument = new_str_pointer.read_wstring
80
+ arguments_list << argument
81
+ offset = offset + argument.length * 2 + 2
82
+ end
83
+ local_free(result)
84
+ arguments_list
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -461,22 +461,22 @@ BOOL WINAPI DeviceIoControl(
461
461
  =end
462
462
  safe_attach_function :DeviceIoControl, %i{HANDLE DWORD LPVOID DWORD LPVOID DWORD LPDWORD pointer}, :BOOL
463
463
 
464
- # BOOL WINAPI DeleteVolumeMountPoint(
465
- # _In_ LPCTSTR lpszVolumeMountPoint
466
- # );
464
+ # BOOL WINAPI DeleteVolumeMountPoint(
465
+ # _In_ LPCTSTR lpszVolumeMountPoint
466
+ # );
467
467
  safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL
468
468
 
469
- # BOOL WINAPI SetVolumeMountPoint(
470
- # _In_ LPCTSTR lpszVolumeMountPoint,
471
- # _In_ LPCTSTR lpszVolumeName
472
- # );
469
+ # BOOL WINAPI SetVolumeMountPoint(
470
+ # _In_ LPCTSTR lpszVolumeMountPoint,
471
+ # _In_ LPCTSTR lpszVolumeName
472
+ # );
473
473
  safe_attach_function :SetVolumeMountPointW, %i{LPCTSTR LPCTSTR}, :BOOL
474
474
 
475
- # BOOL WINAPI GetVolumeNameForVolumeMountPoint(
476
- # _In_ LPCTSTR lpszVolumeMountPoint,
477
- # _Out_ LPTSTR lpszVolumeName,
478
- # _In_ DWORD cchBufferLength
479
- # );
475
+ # BOOL WINAPI GetVolumeNameForVolumeMountPoint(
476
+ # _In_ LPCTSTR lpszVolumeMountPoint,
477
+ # _Out_ LPTSTR lpszVolumeName,
478
+ # _In_ DWORD cchBufferLength
479
+ # );
480
480
  safe_attach_function :GetVolumeNameForVolumeMountPointW, %i{LPCTSTR LPTSTR DWORD}, :BOOL
481
481
 
482
482
  =begin
@@ -538,12 +538,12 @@ BOOL WINAPI VerQueryValue(
538
538
  # ensures the handle is closed on exit of the block
539
539
  # FIXME: yard with @yield
540
540
  def file_search_handle(path)
541
- # Workaround for CHEF-4419:
542
- # Make sure paths starting with "/" has a drive letter
543
- # assigned from the current working diretory.
544
- # Note: With CHEF-4427 this issue will be fixed with a
545
- # broader fix to map all the paths starting with "/" to
546
- # SYSTEM_DRIVE on windows.
541
+ # Workaround for CHEF-4419:
542
+ # Make sure paths starting with "/" has a drive letter
543
+ # assigned from the current working diretory.
544
+ # Note: With CHEF-4427 this issue will be fixed with a
545
+ # broader fix to map all the paths starting with "/" to
546
+ # SYSTEM_DRIVE on windows.
547
547
  path = ::File.expand_path(path) if path.start_with? "/"
548
548
  path = canonical_encode_path(path)
549
549
  find_data = WIN32_FIND_DATA.new
@@ -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
@@ -171,7 +171,7 @@ class Chef
171
171
  rescue Chef::Exceptions::Win32APIFunctionNotImplemented => e
172
172
  raise e
173
173
  rescue Exception
174
- # things are ok.
174
+ # things are ok.
175
175
  end
176
176
 
177
177
  def self.file_access_check(path, desired_access)
@@ -82,8 +82,8 @@ class Chef
82
82
  (call_succeeded != 0) && (is_64_bit_process_result.get_int(0) != 0)
83
83
  end
84
84
 
85
- # Must have PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION rights,
86
- # AND the PROCESS_VM_READ right
85
+ # Must have PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION rights,
86
+ # AND the PROCESS_VM_READ right
87
87
  def self.get_process_memory_info(handle)
88
88
  memory_info = PROCESS_MEMORY_COUNTERS.new
89
89
  unless GetProcessMemoryInfo(handle.handle, memory_info, memory_info.size)
@@ -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
@@ -32,6 +32,11 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
32
32
  new_resource
33
33
  end
34
34
 
35
+ let(:provider) do
36
+ provider = subject.provider_for_action(subject.action)
37
+ provider
38
+ end
39
+
35
40
  context "installing a package" do
36
41
  after { remove_package }
37
42
 
@@ -88,6 +93,30 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
88
93
  expect(package_list.call).to eq("#{package_name}|2.0")
89
94
  end
90
95
 
96
+ context "when multiple options passed as string" do
97
+ before do
98
+ subject.options "--force --confirm"
99
+ subject.source nil
100
+ end
101
+
102
+ it "splits a string into an array of options" do
103
+ expect(provider.send(:cmd_args)).to eq(["--force", "--confirm"])
104
+ end
105
+
106
+ it "calls command_line_to_argv_w_helper method" do
107
+ expect(provider).to receive(:command_line_to_argv_w_helper).with(subject.options).and_return(["--force", "--confirm"])
108
+ provider.send(:cmd_args)
109
+ end
110
+ end
111
+
112
+ context "when multiple options passed as array" do
113
+ it "Does not call command_line_to_argv_w_helper method" do
114
+ subject.options [ "--force", "--confirm" ]
115
+ expect(provider).not_to receive(:command_line_to_argv_w_helper)
116
+ provider.send(:cmd_args)
117
+ end
118
+ end
119
+
91
120
  it "installs with multiple options as an array" do
92
121
  subject.options [ "--force", "--confirm" ]
93
122
  subject.run_action(:install)