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
@@ -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
@@ -23,6 +23,8 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
23
23
 
24
24
  let(:package_name) { "Package_for_KB2959977" }
25
25
  let(:package_source) { "https://download.microsoft.com/download/3/B/3/3B320C07-B7B1-41E5-81F4-79EBC02DF7D3/Windows8.1-KB2959977-x64.msu" }
26
+ let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" }
27
+ let(:timeout) { 3600 }
26
28
 
27
29
  let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") }
28
30
  let(:cab_provider) do
@@ -36,6 +38,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
36
38
  new_resource = Chef::Resource::MsuPackage.new("test msu package", run_context)
37
39
  new_resource.package_name package_name
38
40
  new_resource.source package_source
41
+ new_resource.timeout timeout
39
42
  new_resource
40
43
  end
41
44
 
@@ -44,7 +47,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
44
47
 
45
48
  it "installs the package successfully" do
46
49
  subject.run_action(:install)
47
- found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
50
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity }
48
51
  expect(found_packages.length).to be == 1
49
52
  end
50
53
  end
@@ -53,7 +56,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
53
56
  it "removes an installed package" do
54
57
  subject.run_action(:install)
55
58
  remove_package
56
- found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
59
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity }
57
60
  expect(found_packages.length).to be == 0
58
61
  end
59
62
  end
@@ -39,7 +39,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
39
39
  # mytest rpm package works in centos, redhat and in suse without any dependency issues.
40
40
  else
41
41
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(0)
42
- ::File.exists?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
42
+ ::File.exist?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
43
43
  end
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
48
48
  expect(shell_out("rpm -qa | grep dummy").exitstatus).to eq(1)
49
49
  else
50
50
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(1)
51
- !::File.exists?("/opt/mytest/mytest.sh")
51
+ !::File.exist?("/opt/mytest/mytest.sh")
52
52
  end
53
53
  end
54
54
 
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "chef/mixin/shell_out"
20
20
 
21
21
  metadata = {
22
- macos_only: true,
22
+ macos_1013: true,
23
23
  requires_root: true,
24
24
  }
25
25
 
@@ -29,7 +29,7 @@ describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metada
29
29
  def clean_user
30
30
  shell_out!("/usr/bin/dscl . -delete '/Users/#{username}'")
31
31
  rescue Mixlib::ShellOut::ShellCommandFailed
32
- # Raised when the user is already cleaned
32
+ # Raised when the user is already cleaned
33
33
  end
34
34
 
35
35
  def user_should_exist
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "chef/mixin/shell_out"
20
20
 
21
21
  metadata = {
22
- macos_1014: true,
22
+ macos_gte_1014: true,
23
23
  requires_root: true,
24
24
  }
25
25
 
@@ -29,7 +29,7 @@ describe "Chef::Resource::User with Chef::Provider::User::MacUser provider", met
29
29
  def clean_user
30
30
  shell_out!("/usr/bin/dscl . -delete '/Users/#{username}'")
31
31
  rescue Mixlib::ShellOut::ShellCommandFailed
32
- # Raised when the user is already cleaned
32
+ # Raised when the user is already cleaned
33
33
  end
34
34
 
35
35
  def ensure_file_cache_path_exists
@@ -390,7 +390,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
390
390
  end
391
391
 
392
392
  after do
393
- if File.exists?(out_path)
393
+ if File.exist?(out_path)
394
394
  File.delete(out_path)
395
395
  end
396
396
  end
@@ -405,7 +405,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
405
405
  expect(no_of_certificates).to eq(1)
406
406
  end
407
407
  it "Stores Certificate content at given path" do
408
- expect(File.exists?(out_path)).to be_truthy
408
+ expect(File.exist?(out_path)).to be_truthy
409
409
  end
410
410
  it "Does not converge while fetching" do
411
411
  expect(win_certificate).not_to be_updated_by_last_action
@@ -425,7 +425,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
425
425
  expect(stdout.string.strip).to be_empty
426
426
  end
427
427
  it "Does not store certificate content at given path" do
428
- expect(File.exists?(out_path)).to be_falsy
428
+ expect(File.exist?(out_path)).to be_falsy
429
429
  end
430
430
  it "Does not converge while fetching" do
431
431
  expect(win_certificate).not_to be_updated_by_last_action
@@ -0,0 +1,49 @@
1
+ #
2
+ # Author:: Dheeraj Singh Dubey (<ddubey@chef.io>)
3
+ # Copyright:: Copyright (c) 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 "spec_helper"
20
+
21
+ describe Chef::Resource::WindowsFont, :windows_only do
22
+ let(:resource_name) { "Playmaker.ttf" }
23
+ let(:resource_source) { "https://www.wfonts.com/download/data/2020/05/06/playmaker/Playmaker.ttf" }
24
+
25
+ let(:run_context) do
26
+ node = Chef::Node.new
27
+ node.default[:platform] = ohai[:platform]
28
+ node.default[:platform_version] = ohai[:platform_version]
29
+ node.default[:os] = ohai[:os]
30
+ events = Chef::EventDispatch::Dispatcher.new
31
+ Chef::RunContext.new(node, {}, events)
32
+ end
33
+
34
+ subject do
35
+ resource = Chef::Resource::WindowsFont.new(resource_name, run_context)
36
+ resource.source resource_source
37
+ resource
38
+ end
39
+
40
+ it "installs font on first install" do
41
+ subject.run_action(:install)
42
+ expect(subject).to be_updated_by_last_action
43
+ end
44
+
45
+ it "does not install font when already installed" do
46
+ subject.run_action(:install)
47
+ expect(subject).not_to be_updated_by_last_action
48
+ end
49
+ end
@@ -513,13 +513,13 @@ describe Chef::Resource::WindowsTask, :windows_only do
513
513
  it "not raises any Argument error if frequency_modifier set as 'first, second, third' and day is provided" do
514
514
  subject.frequency_modifier "first, second, third"
515
515
  subject.day "Mon, Fri"
516
- expect { subject.after_created }.not_to raise_error(ArgumentError)
516
+ expect { subject.after_created }.not_to raise_error
517
517
  end
518
518
 
519
519
  it "not raises any Argument error if frequency_modifier 2 " do
520
520
  subject.frequency_modifier 2
521
521
  subject.day "Mon, Sun"
522
- expect { subject.after_created }.not_to raise_error(ArgumentError)
522
+ expect { subject.after_created }.not_to raise_error
523
523
  end
524
524
 
525
525
  it "raises argument error if frequency_modifier > 12" do
@@ -535,7 +535,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
535
535
  it "creates scheduled task to run task monthly on Monday and Friday of first, second and thrid week of month" do
536
536
  subject.frequency_modifier "first, second, third"
537
537
  subject.day "Mon, Fri"
538
- expect { subject.after_created }.not_to raise_error(ArgumentError)
538
+ expect { subject.after_created }.not_to raise_error
539
539
  call_for_create_action
540
540
  current_resource = call_for_load_current_resource
541
541
  expect(current_resource.exists).to eq(true)
@@ -558,7 +558,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
558
558
  it "creates scheduled task to run task monthly on every 6 months when frequency_modifier is 6 and to run on 1st and 2nd day of month" do
559
559
  subject.frequency_modifier 6
560
560
  subject.day "1, 2"
561
- expect { subject.after_created }.not_to raise_error(ArgumentError)
561
+ expect { subject.after_created }.not_to raise_error
562
562
  call_for_create_action
563
563
  current_resource = call_for_load_current_resource
564
564
  expect(current_resource.exists).to eq(true)
@@ -590,7 +590,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
590
590
 
591
591
  it "creates scheduled task to run monthly to run last day of the month" do
592
592
  subject.day "last"
593
- expect { subject.after_created }.not_to raise_error(ArgumentError)
593
+ expect { subject.after_created }.not_to raise_error
594
594
  call_for_create_action
595
595
  current_resource = call_for_load_current_resource
596
596
  expect(current_resource.exists).to eq(true)
@@ -611,7 +611,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
611
611
 
612
612
  it "day property set as 'lastday' creates scheduled task to run monthly to run last day of the month" do
613
613
  subject.day "lastday"
614
- expect { subject.after_created }.not_to raise_error(ArgumentError)
614
+ expect { subject.after_created }.not_to raise_error
615
615
  call_for_create_action
616
616
  current_resource = call_for_load_current_resource
617
617
  expect(current_resource.exists).to eq(true)
@@ -635,7 +635,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
635
635
  it "creates scheduled task to run monthly on last week of the month" do
636
636
  subject.frequency_modifier "last"
637
637
  subject.day "Mon, Fri"
638
- expect { subject.after_created }.not_to raise_error(ArgumentError)
638
+ expect { subject.after_created }.not_to raise_error
639
639
  call_for_create_action
640
640
  current_resource = call_for_load_current_resource
641
641
  expect(current_resource.exists).to eq(true)
@@ -659,7 +659,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
659
659
  context "when wild card (*) set as months" do
660
660
  it "creates the scheduled task to run on 1st day of the all months" do
661
661
  subject.months "*"
662
- expect { subject.after_created }.not_to raise_error(ArgumentError)
662
+ expect { subject.after_created }.not_to raise_error
663
663
  call_for_create_action
664
664
  current_resource = call_for_load_current_resource
665
665
  expect(current_resource.exists).to eq(true)
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/client"
20
20
 
21
21
  describe Chef::RunLock do
@@ -435,6 +435,7 @@ describe Chef::RunLock do
435
435
 
436
436
  class TestRunLock < Chef::RunLock
437
437
  attr_accessor :client_process
438
+
438
439
  def create_lock
439
440
  super
440
441
  client_process.fire_event("created lock")
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/json_compat"
20
- require File.expand_path("../../../../spec_helper", __FILE__)
20
+ require File.expand_path("../../../spec_helper", __dir__)
21
21
 
22
22
  describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
23
23
  before(:all) do
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/mixin/shell_out"
20
20
  require "chef/version"
21
21
  require "ohai/version"
@@ -125,7 +125,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
125
125
  it "start should start the service", :volatile do
126
126
  service_manager.run(["-a", "start"])
127
127
  expect(test_service_state).to eq("running")
128
- expect(File.exists?(test_service_file)).to be_truthy
128
+ expect(File.exist?(test_service_file)).to be_truthy
129
129
  end
130
130
 
131
131
  it "stop should not affect the service" do