chef 17.10.0 → 18.0.185

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -8
  3. data/README.md +7 -7
  4. data/Rakefile +5 -24
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
  6. data/chef.gemspec +14 -7
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/exit_code.rb +3 -3
  9. data/lib/chef/client.rb +167 -0
  10. data/lib/chef/compliance/input.rb +1 -1
  11. data/lib/chef/compliance/input_collection.rb +1 -1
  12. data/lib/chef/compliance/profile.rb +1 -1
  13. data/lib/chef/compliance/profile_collection.rb +1 -2
  14. data/lib/chef/compliance/waiver.rb +1 -1
  15. data/lib/chef/compliance/waiver_collection.rb +1 -1
  16. data/lib/chef/cookbook/syntax_check.rb +2 -2
  17. data/lib/chef/dsl/reader_helpers.rb +1 -1
  18. data/lib/chef/dsl/rest_resource.rb +77 -0
  19. data/lib/chef/dsl/secret.rb +113 -5
  20. data/lib/chef/event_dispatch/base.rb +3 -0
  21. data/lib/chef/exceptions.rb +8 -0
  22. data/lib/chef/http/authenticator.rb +170 -3
  23. data/lib/chef/http/ssl_policies.rb +3 -3
  24. data/lib/chef/mixin/checksum.rb +6 -0
  25. data/lib/chef/mixin/powershell_exec.rb +5 -28
  26. data/lib/chef/mixin/properties.rb +6 -0
  27. data/lib/chef/node/attribute.rb +20 -3
  28. data/lib/chef/node/mixin/deep_merge_cache.rb +4 -4
  29. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  30. data/lib/chef/property.rb +5 -3
  31. data/lib/chef/provider/cron.rb +5 -1
  32. data/lib/chef/provider/file.rb +2 -2
  33. data/lib/chef/provider/group/windows.rb +1 -1
  34. data/lib/chef/provider/http_request.rb +11 -9
  35. data/lib/chef/provider/mount/linux.rb +5 -0
  36. data/lib/chef/provider/mount/mount.rb +8 -0
  37. data/lib/chef/provider/mount/windows.rb +1 -1
  38. data/lib/chef/provider/package/powershell.rb +1 -1
  39. data/lib/chef/provider/package/rubygems.rb +1 -1
  40. data/lib/chef/provider/package/snap.rb +1 -1
  41. data/lib/chef/provider/package/windows/msi.rb +2 -2
  42. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  43. data/lib/chef/provider/package/windows.rb +1 -1
  44. data/lib/chef/provider/package/zypper/version.rb +60 -0
  45. data/lib/chef/provider/package/zypper.rb +47 -3
  46. data/lib/chef/provider/service/windows.rb +1 -1
  47. data/lib/chef/provider/user/aix.rb +5 -0
  48. data/lib/chef/provider/user/linux.rb +29 -0
  49. data/lib/chef/provider/user/mac.rb +1 -1
  50. data/lib/chef/provider/user.rb +45 -9
  51. data/lib/chef/provider.rb +1 -1
  52. data/lib/chef/recipe.rb +1 -1
  53. data/lib/chef/resource/_rest_resource.rb +389 -0
  54. data/lib/chef/resource/alternatives.rb +0 -1
  55. data/lib/chef/resource/apt_package.rb +2 -1
  56. data/lib/chef/resource/apt_preference.rb +0 -1
  57. data/lib/chef/resource/apt_repository.rb +0 -1
  58. data/lib/chef/resource/apt_update.rb +0 -1
  59. data/lib/chef/resource/archive_file.rb +0 -1
  60. data/lib/chef/resource/bash.rb +0 -1
  61. data/lib/chef/resource/batch.rb +0 -1
  62. data/lib/chef/resource/bff_package.rb +0 -1
  63. data/lib/chef/resource/breakpoint.rb +0 -1
  64. data/lib/chef/resource/build_essential.rb +0 -1
  65. data/lib/chef/resource/cab_package.rb +0 -1
  66. data/lib/chef/resource/chef_client_config.rb +17 -14
  67. data/lib/chef/resource/chef_client_cron.rb +1 -2
  68. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  69. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  70. data/lib/chef/resource/chef_client_systemd_timer.rb +0 -1
  71. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  72. data/lib/chef/resource/chef_gem.rb +0 -1
  73. data/lib/chef/resource/chef_handler.rb +0 -1
  74. data/lib/chef/resource/chef_sleep.rb +1 -3
  75. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  76. data/lib/chef/resource/chocolatey_config.rb +0 -1
  77. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  78. data/lib/chef/resource/chocolatey_package.rb +0 -1
  79. data/lib/chef/resource/chocolatey_source.rb +0 -1
  80. data/lib/chef/resource/cookbook_file.rb +0 -1
  81. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  82. data/lib/chef/resource/cron/cron.rb +0 -1
  83. data/lib/chef/resource/cron/cron_d.rb +15 -1
  84. data/lib/chef/resource/cron_access.rb +0 -1
  85. data/lib/chef/resource/csh.rb +0 -1
  86. data/lib/chef/resource/directory.rb +0 -1
  87. data/lib/chef/resource/dmg_package.rb +2 -1
  88. data/lib/chef/resource/dnf_package.rb +0 -1
  89. data/lib/chef/resource/dpkg_package.rb +0 -1
  90. data/lib/chef/resource/dsc_resource.rb +0 -1
  91. data/lib/chef/resource/dsc_script.rb +0 -1
  92. data/lib/chef/resource/execute.rb +0 -1
  93. data/lib/chef/resource/file.rb +0 -1
  94. data/lib/chef/resource/freebsd_package.rb +2 -1
  95. data/lib/chef/resource/gem_package.rb +2 -1
  96. data/lib/chef/resource/group.rb +25 -2
  97. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  98. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  99. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  100. data/lib/chef/resource/habitat_config.rb +0 -1
  101. data/lib/chef/resource/habitat_install.rb +0 -1
  102. data/lib/chef/resource/habitat_service.rb +0 -1
  103. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  104. data/lib/chef/resource/homebrew_cask.rb +0 -1
  105. data/lib/chef/resource/homebrew_package.rb +2 -1
  106. data/lib/chef/resource/homebrew_tap.rb +0 -1
  107. data/lib/chef/resource/homebrew_update.rb +0 -2
  108. data/lib/chef/resource/hostname.rb +0 -1
  109. data/lib/chef/resource/http_request.rb +0 -1
  110. data/lib/chef/resource/ifconfig.rb +0 -1
  111. data/lib/chef/resource/inspec_input.rb +0 -1
  112. data/lib/chef/resource/inspec_waiver.rb +0 -1
  113. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  114. data/lib/chef/resource/ips_package.rb +0 -1
  115. data/lib/chef/resource/kernel_module.rb +0 -1
  116. data/lib/chef/resource/ksh.rb +0 -1
  117. data/lib/chef/resource/launchd.rb +0 -1
  118. data/lib/chef/resource/link.rb +0 -1
  119. data/lib/chef/resource/locale.rb +1 -2
  120. data/lib/chef/resource/log.rb +0 -1
  121. data/lib/chef/resource/lwrp_base.rb +0 -4
  122. data/lib/chef/resource/macos_userdefaults.rb +0 -1
  123. data/lib/chef/resource/macosx_service.rb +0 -1
  124. data/lib/chef/resource/macports_package.rb +2 -1
  125. data/lib/chef/resource/mdadm.rb +0 -1
  126. data/lib/chef/resource/mount.rb +0 -1
  127. data/lib/chef/resource/msu_package.rb +0 -1
  128. data/lib/chef/resource/notify_group.rb +0 -2
  129. data/lib/chef/resource/ohai.rb +0 -1
  130. data/lib/chef/resource/ohai_hint.rb +0 -1
  131. data/lib/chef/resource/openbsd_package.rb +2 -1
  132. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  133. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  134. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  135. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  136. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  137. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  138. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  139. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  140. data/lib/chef/resource/osx_profile.rb +0 -1
  141. data/lib/chef/resource/package.rb +0 -1
  142. data/lib/chef/resource/pacman_package.rb +2 -1
  143. data/lib/chef/resource/paludis_package.rb +0 -1
  144. data/lib/chef/resource/perl.rb +0 -1
  145. data/lib/chef/resource/plist.rb +7 -3
  146. data/lib/chef/resource/portage_package.rb +2 -1
  147. data/lib/chef/resource/powershell_package.rb +0 -1
  148. data/lib/chef/resource/powershell_package_source.rb +0 -1
  149. data/lib/chef/resource/powershell_script.rb +0 -1
  150. data/lib/chef/resource/python.rb +0 -1
  151. data/lib/chef/resource/reboot.rb +0 -1
  152. data/lib/chef/resource/registry_key.rb +0 -1
  153. data/lib/chef/resource/remote_directory.rb +0 -1
  154. data/lib/chef/resource/remote_file.rb +0 -1
  155. data/lib/chef/resource/rhsm_errata.rb +0 -1
  156. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  157. data/lib/chef/resource/rhsm_register.rb +17 -1
  158. data/lib/chef/resource/rhsm_repo.rb +0 -1
  159. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  160. data/lib/chef/resource/route.rb +0 -1
  161. data/lib/chef/resource/rpm_package.rb +2 -1
  162. data/lib/chef/resource/ruby.rb +0 -1
  163. data/lib/chef/resource/ruby_block.rb +0 -1
  164. data/lib/chef/resource/scm/_scm.rb +0 -2
  165. data/lib/chef/resource/scm/git.rb +0 -2
  166. data/lib/chef/resource/scm/subversion.rb +0 -2
  167. data/lib/chef/resource/script.rb +0 -1
  168. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  169. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  170. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  171. data/lib/chef/resource/selinux_boolean.rb +101 -0
  172. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  173. data/lib/chef/resource/selinux_install.rb +107 -0
  174. data/lib/chef/resource/selinux_module.rb +143 -0
  175. data/lib/chef/resource/selinux_permissive.rb +64 -0
  176. data/lib/chef/resource/selinux_port.rb +118 -0
  177. data/lib/chef/resource/selinux_state.rb +166 -0
  178. data/lib/chef/resource/service.rb +0 -1
  179. data/lib/chef/resource/smartos_package.rb +2 -1
  180. data/lib/chef/resource/snap_package.rb +2 -1
  181. data/lib/chef/resource/solaris_package.rb +2 -1
  182. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  183. data/lib/chef/resource/sudo.rb +0 -1
  184. data/lib/chef/resource/support/client.erb +3 -4
  185. data/lib/chef/resource/swap_file.rb +0 -1
  186. data/lib/chef/resource/sysctl.rb +1 -2
  187. data/lib/chef/resource/systemd_unit.rb +0 -1
  188. data/lib/chef/resource/template.rb +0 -1
  189. data/lib/chef/resource/timezone.rb +0 -1
  190. data/lib/chef/resource/user/aix_user.rb +0 -1
  191. data/lib/chef/resource/user/linux_user.rb +0 -1
  192. data/lib/chef/resource/user/mac_user.rb +0 -1
  193. data/lib/chef/resource/user/pw_user.rb +0 -1
  194. data/lib/chef/resource/user/solaris_user.rb +0 -1
  195. data/lib/chef/resource/user/windows_user.rb +0 -1
  196. data/lib/chef/resource/user.rb +10 -1
  197. data/lib/chef/resource/user_ulimit.rb +0 -1
  198. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  199. data/lib/chef/resource/windows_ad_join.rb +0 -2
  200. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  201. data/lib/chef/resource/windows_auto_run.rb +0 -1
  202. data/lib/chef/resource/windows_certificate.rb +54 -43
  203. data/lib/chef/resource/windows_defender.rb +0 -1
  204. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  205. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  206. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  207. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  208. data/lib/chef/resource/windows_dns_record.rb +0 -1
  209. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  210. data/lib/chef/resource/windows_env.rb +0 -1
  211. data/lib/chef/resource/windows_feature.rb +0 -1
  212. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  213. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  214. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  215. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  216. data/lib/chef/resource/windows_font.rb +2 -3
  217. data/lib/chef/resource/windows_package.rb +3 -4
  218. data/lib/chef/resource/windows_pagefile.rb +27 -22
  219. data/lib/chef/resource/windows_path.rb +0 -1
  220. data/lib/chef/resource/windows_printer.rb +0 -1
  221. data/lib/chef/resource/windows_printer_port.rb +0 -1
  222. data/lib/chef/resource/windows_script.rb +0 -2
  223. data/lib/chef/resource/windows_security_policy.rb +0 -1
  224. data/lib/chef/resource/windows_service.rb +0 -1
  225. data/lib/chef/resource/windows_share.rb +0 -1
  226. data/lib/chef/resource/windows_shortcut.rb +1 -2
  227. data/lib/chef/resource/windows_task.rb +0 -1
  228. data/lib/chef/resource/windows_uac.rb +0 -1
  229. data/lib/chef/resource/windows_update_settings.rb +0 -1
  230. data/lib/chef/resource/windows_user_privilege.rb +36 -27
  231. data/lib/chef/resource/windows_workgroup.rb +0 -1
  232. data/lib/chef/resource/yum_package.rb +2 -1
  233. data/lib/chef/resource/yum_repository.rb +0 -1
  234. data/lib/chef/resource/zypper_package.rb +2 -1
  235. data/lib/chef/resource/zypper_repository.rb +0 -1
  236. data/lib/chef/resource.rb +13 -5
  237. data/lib/chef/resources.rb +7 -0
  238. data/lib/chef/run_context.rb +19 -3
  239. data/lib/chef/secret_fetcher/azure_key_vault.rb +3 -3
  240. data/lib/chef/secret_fetcher/hashi_vault.rb +1 -1
  241. data/lib/chef/version.rb +1 -1
  242. data/lib/chef/win32/handle.rb +6 -7
  243. data/lib/chef/win32/registry.rb +7 -3
  244. data/lib/chef/win32/version.rb +2 -1
  245. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  246. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  247. data/spec/functional/resource/group_spec.rb +10 -6
  248. data/spec/functional/resource/link_spec.rb +8 -8
  249. data/spec/functional/resource/plist_spec.rb +25 -0
  250. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  251. data/spec/functional/resource/windows_certificate_spec.rb +15 -12
  252. data/spec/functional/resource/windows_font_spec.rb +11 -8
  253. data/spec/functional/resource/windows_pagefile_spec.rb +31 -4
  254. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  255. data/spec/functional/shell_spec.rb +7 -2
  256. data/spec/functional/version_spec.rb +1 -1
  257. data/spec/integration/client/client_spec.rb +82 -3
  258. data/spec/integration/client/exit_code_spec.rb +1 -1
  259. data/spec/integration/client/ipv6_spec.rb +1 -1
  260. data/spec/integration/compliance/compliance_spec.rb +1 -1
  261. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  262. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  263. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  264. data/spec/integration/recipes/notifies_spec.rb +1 -1
  265. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  266. data/spec/integration/recipes/remote_directory.rb +1 -1
  267. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  268. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  269. data/spec/integration/solo/solo_spec.rb +2 -2
  270. data/spec/spec_helper.rb +1 -0
  271. data/spec/support/platform_helpers.rb +4 -0
  272. data/spec/support/ruby_installer.rb +1 -1
  273. data/spec/support/shared/functional/windows_script.rb +2 -2
  274. data/spec/unit/application/client_spec.rb +0 -10
  275. data/spec/unit/client_spec.rb +54 -2
  276. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  277. data/spec/unit/daemon_spec.rb +1 -5
  278. data/spec/unit/dsl/secret_spec.rb +127 -23
  279. data/spec/unit/http/authenticator_spec.rb +68 -0
  280. data/spec/unit/mixin/checksum_spec.rb +28 -0
  281. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  282. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  283. data/spec/unit/provider/cron_spec.rb +36 -0
  284. data/spec/unit/provider/http_request_spec.rb +60 -72
  285. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  286. data/spec/unit/provider/package/rubygems_spec.rb +2 -2
  287. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  288. data/spec/unit/provider/user/linux_spec.rb +96 -1
  289. data/spec/unit/provider/user_spec.rb +24 -6
  290. data/spec/unit/resource/archive_file_spec.rb +1 -1
  291. data/spec/unit/resource/chef_client_config_spec.rb +8 -0
  292. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  293. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  294. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  295. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  296. data/spec/unit/resource/cron_d_spec.rb +37 -1
  297. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  298. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  299. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  300. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  301. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  302. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  303. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  304. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  305. data/spec/unit/resource/sysctl_spec.rb +2 -2
  306. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  307. data/spec/unit/resource_spec.rb +21 -1
  308. data/spec/unit/run_context_spec.rb +16 -0
  309. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  310. data/tasks/rspec.rb +1 -1
  311. metadata +87 -27
@@ -145,6 +145,16 @@ class Chef
145
145
  #
146
146
  attr_accessor :input_collection
147
147
 
148
+ #
149
+ # @return [Symbol, nil]
150
+ #
151
+ attr_accessor :default_secret_service
152
+
153
+ #
154
+ # @return [Hash<Symbol,Object>]
155
+ #
156
+ attr_accessor :default_secret_config
157
+
148
158
  # Pointer back to the Chef::Runner that created this
149
159
  #
150
160
  attr_accessor :runner
@@ -222,6 +232,8 @@ class Chef
222
232
  @input_collection = Chef::Compliance::InputCollection.new(events)
223
233
  @waiver_collection = Chef::Compliance::WaiverCollection.new(events)
224
234
  @profile_collection = Chef::Compliance::ProfileCollection.new(events)
235
+ @default_secret_service = nil
236
+ @default_secret_config = {}
225
237
 
226
238
  initialize_child_state
227
239
  end
@@ -401,9 +413,9 @@ class Chef
401
413
  logger.warn(<<~ERROR_MESSAGE)
402
414
  MissingCookbookDependency:
403
415
  Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
404
- is not a dependency of any cookbook in the run_list. To load this recipe,
405
- first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
406
- including it from in that cookbook's metadata.
416
+ is not a dependency of any cookbook in the run_list. To load this recipe,
417
+ first add a dependency of the cookbook '#{cookbook_name}' into the metadata
418
+ of the cookbook which depends on '#{cookbook_name}'.
407
419
  ERROR_MESSAGE
408
420
  end
409
421
 
@@ -693,6 +705,10 @@ class Chef
693
705
  cookbook_collection
694
706
  cookbook_collection=
695
707
  cookbook_compiler
708
+ default_secret_config
709
+ default_secret_config=
710
+ default_secret_service
711
+ default_secret_service=
696
712
  definitions
697
713
  events
698
714
  events=
@@ -59,7 +59,7 @@ class Chef
59
59
  end
60
60
 
61
61
  def validate!
62
- raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :object_id, :client_id, or :mi_res_id" if [object_id, client_id, mi_res_id].count { |x| !x.nil? } > 1
62
+ raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :object_id, :client_id, or :mi_res_id" if [config_object_id, client_id, mi_res_id].count { |x| !x.nil? } > 1
63
63
  end
64
64
 
65
65
  private
@@ -87,7 +87,7 @@ class Chef
87
87
  "https://vault.azure.net"
88
88
  end
89
89
 
90
- def object_id
90
+ def config_object_id
91
91
  config[:object_id]
92
92
  end
93
93
 
@@ -104,7 +104,7 @@ class Chef
104
104
  p = {}
105
105
  p["api-version"] = api_version
106
106
  p["resource"] = resource
107
- p["object_id"] = object_id if object_id
107
+ p["object_id"] = config_object_id if config_object_id
108
108
  p["client_id"] = client_id if client_id
109
109
  p["mi_res_id"] = mi_res_id if mi_res_id
110
110
  URI.encode_www_form(p)
@@ -112,7 +112,7 @@ class Chef
112
112
  raise Chef::Exceptions::Secret::ConfigurationInvalid.new("You must provide the authenticating Vault role name in the configuration as :role_name")
113
113
  end
114
114
 
115
- Vault.auth.aws_iam(config[:role_name], Aws::InstanceProfileCredentials.new)
115
+ Vault.auth.aws_iam(config[:role_name], Aws::InstanceProfileCredentials.new, Vault.address)
116
116
  else
117
117
  raise Chef::Exceptions::Secret::ConfigurationInvalid.new("Invalid :auth_method provided. You gave #{config[:auth_method]}, expected one of :#{SUPPORTED_AUTH_TYPES.join(", :")} ")
118
118
  end
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("17.10.0")
26
+ VERSION = Chef::VersionString.new("18.0.185")
27
27
  end
28
28
 
29
29
  #
@@ -26,10 +26,6 @@ class Chef
26
26
  class Handle
27
27
  extend Chef::ReservedNames::Win32::API::Process
28
28
 
29
- # See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
30
- # The handle value returned by the GetCurrentProcess function is the pseudo handle (HANDLE)-1 (which is 0xFFFFFFFF)
31
- CURRENT_PROCESS_HANDLE = 4294967295
32
-
33
29
  def initialize(handle)
34
30
  @handle = handle
35
31
  ObjectSpace.define_finalizer(self, Handle.close_handle_finalizer(handle))
@@ -38,13 +34,16 @@ class Chef
38
34
  attr_reader :handle
39
35
 
40
36
  def self.close_handle_finalizer(handle)
37
+ proc { close_handle(handle) }
38
+ end
39
+
40
+ def self.close_handle(handle)
41
41
  # According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx, it is not necessary
42
42
  # to close the pseudo handle returned by the GetCurrentProcess function. The docs also say that it doesn't hurt to call
43
43
  # CloseHandle on it. However, doing so from inside of Ruby always seems to produce an invalid handle error.
44
- proc { close_handle(handle) unless handle == CURRENT_PROCESS_HANDLE }
45
- end
44
+ # The recommendation is to use GetCurrentProcess instead of the const (HANDLE)-1, to ensure we're making the correct comparison.
45
+ return if handle == GetCurrentProcess()
46
46
 
47
- def self.close_handle(handle)
48
47
  unless CloseHandle(handle)
49
48
  Chef::ReservedNames::Win32::Error.raise!
50
49
  end
@@ -20,7 +20,7 @@ require_relative "../reserved_names"
20
20
  require_relative "api"
21
21
  require_relative "../mixin/wide_string"
22
22
 
23
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
23
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
24
24
  require "win32/api"
25
25
  module Win32
26
26
  autoload :Registry, File.expand_path("../monkey_patches/win32/registry", __dir__)
@@ -32,7 +32,7 @@ class Chef
32
32
  class Win32
33
33
  class Registry
34
34
 
35
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
35
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
36
36
  include Chef::ReservedNames::Win32::API::Registry
37
37
  extend Chef::ReservedNames::Win32::API::Registry
38
38
  end
@@ -293,7 +293,11 @@ class Chef
293
293
  end
294
294
 
295
295
  def machine_architecture
296
- node[:kernel][:machine].to_sym
296
+ if node.nil?
297
+ ::RbConfig::CONFIG["target_cpu"] == "x64" ? :x86_64 : :i386
298
+ else
299
+ node[:kernel][:machine].to_sym
300
+ end
297
301
  end
298
302
 
299
303
  def assert_architecture!
@@ -51,7 +51,8 @@ class Chef
51
51
  WIN_VERSIONS = {
52
52
  "Windows Server 2022" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 20348 } },
53
53
  "Windows Server 2019" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number >= 17763 && build_number < 20348 } },
54
- "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
54
+ "Windows 11" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION && build_number >= 22000 } },
55
+ "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION && build_number >= 19044 && build_number < 22000 } },
55
56
  "Windows Server 2016" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION && build_number <= 14393 } },
56
57
  "Windows 8.1" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask, build_number| product_type == VER_NT_WORKSTATION } },
57
58
  "Windows Server 2012 R2" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask, build_number| product_type != VER_NT_WORKSTATION } },
@@ -46,4 +46,5 @@
46
46
  4.14.0 |checksum:99a20cc5e7b901f6b493a8ca5e13439b73b19671eaaca68a00216c4f66765edc
47
47
  4.14.1 |checksum:0fa8731445cf4a0c01570ec29aac4b50a0451ce66b1b31ad768f5035e3af7b90,ruby:~> 2.2
48
48
  4.15.0 |checksum:a5ec27d8055ad47444cfb7ce860bad8af2365772a82892f4a8a0d97e8e9e3b34,ruby:~> 2.2
49
- 4.15.1 |checksum:9291a0f2247f50d15068ee6965b67cd7b678b0d273e18adf3c0b2ea4a890125c,ruby:< 3.1&>= 2.1
49
+ 4.15.1 |checksum:9291a0f2247f50d15068ee6965b67cd7b678b0d273e18adf3c0b2ea4a890125c,ruby:>= 2.1
50
+ 4.16.1 |checksum:5caadbf4bbe5ab539cb892a5bcf74ca33a2f2a897cecafdee4a63be79b4819dc,ruby:>= 2.1
@@ -263,7 +263,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :ruby64_only d
263
263
  dsc_test_resource.cwd(dsc_environment_fail_etc_directory)
264
264
  expect {
265
265
  dsc_test_resource.run_action(:run)
266
- }.to raise_error(Chef::PowerShell::CommandFailed, /#{exception_message_signature}/)
266
+ }.to raise_error(ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed, /#{exception_message_signature}/)
267
267
  end
268
268
  end
269
269
  end
@@ -44,10 +44,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
44
44
  members.shift # Get rid of GroupMembership: string
45
45
  members.include?(user)
46
46
  else
47
- # TODO For some reason our temporary AIX 7.2 system does not correctly report group membership immediately after changes have been made.
48
- # Adding a 2 second delay for this platform is enough to get correct results.
49
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
50
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
47
+ # NOTE: For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
48
+ # Adding a delay for this platform is enough to get correct results.
49
+ # reference: https://github.com/chef/release-engineering/issues/1617
50
+ sleep 3 if aix?
51
51
  Etc.getgrnam(group_name).mem.include?(user)
52
52
  end
53
53
  end
@@ -133,6 +133,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
133
133
  temp_resource.append(true)
134
134
  temp_resource.run_action(:modify)
135
135
  members.each do |member|
136
+ # NOTE For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
137
+ # Adding a delay for this platform is enough to get correct results.
138
+ # reference: https://github.com/chef/release-engineering/issues/1617
139
+ sleep 3 if aix?
136
140
  expect(user_exist_in_group?(member)).to eq(true)
137
141
  end
138
142
  end
@@ -425,7 +429,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
425
429
  end
426
430
  end
427
431
 
428
- describe "when there is a group" do
432
+ describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
429
433
  it_behaves_like "correct group management"
430
434
  end
431
435
 
@@ -463,7 +467,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
463
467
  end
464
468
  end
465
469
 
466
- describe "when there is a group" do
470
+ describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
467
471
  it_behaves_like "correct group management"
468
472
  end
469
473
 
@@ -345,17 +345,17 @@ describe Chef::Resource::Link do
345
345
  let(:test_user) { "test-link-user" }
346
346
  before do
347
347
  user(test_user).run_action(:create)
348
- # TODO For some reason our temporary AIX 7.2 system does not correctly report user existence immediately after changes have been made.
349
- # Adding a 2 second delay for this platform is enough to get correct results.
350
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
351
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
348
+ # NOTE: For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
349
+ # Adding a delay for this platform is enough to get correct results.
350
+ # reference: https://github.com/chef/release-engineering/issues/1617
351
+ sleep 3 if aix?
352
352
  end
353
353
  after do
354
354
  user(test_user).run_action(:remove)
355
- # TODO For some reason our temporary AIX 7.2 system does not correctly report user existence immediately after changes have been made.
356
- # Adding a 2 second delay for this platform is enough to get correct results.
357
- # We hope to remove this delay after we get more permanent AIX 7.2 systems in our CI pipeline. reference: https://github.com/chef/release-engineering/issues/1617
358
- sleep 2 if aix? && (ohai[:platform_version] == "7.2")
355
+ # TODO For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
356
+ # Adding a delay for this platform is enough to get correct results.
357
+ # reference: https://github.com/chef/release-engineering/issues/1617
358
+ sleep 3 if aix?
359
359
  end
360
360
  before(:each) do
361
361
  resource.owner(test_user)
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+ require "plist"
3
+
4
+ describe Chef::Resource::PlistResource, :macos_only, requires_root: true do
5
+ include RecipeDSLHelper
6
+
7
+ let(:global_prefs) do
8
+ File.join(Dir.mktmpdir, ".GlobalPreferences.plist")
9
+ end
10
+
11
+ before(:each) do
12
+ FileUtils.rm_f global_prefs
13
+ end
14
+
15
+ context "make Monday the first DOW" do
16
+ it "creates a new plist with a hash value" do
17
+ plist global_prefs do
18
+ entry "AppleFirstWeekday"
19
+ value(gregorian: 4)
20
+ end
21
+ expect(File.exist?(global_prefs))
22
+ expect(shell_out!("/usr/libexec/PlistBuddy -c 'Print :\"AppleFirstWeekday\":gregorian' \"#{global_prefs}\"").stdout.to_i).to eq(4)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,127 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/mixin/shell_out"
20
+
21
+ metadata = {
22
+ requires_root: true,
23
+ linux_only: true,
24
+ }
25
+
26
+ describe "Chef::Resource::User with Chef::Provider::User::LinuxUser provider", metadata do
27
+ include Chef::Mixin::ShellOut
28
+
29
+ def clean_user
30
+ shell_out!("/usr/sbin/userdel #{username}")
31
+ rescue Mixlib::ShellOut::ShellCommandFailed
32
+ # Raised when the user is already cleaned
33
+ end
34
+
35
+ def ensure_file_cache_path_exists
36
+ path = Chef::Config["file_cache_path"]
37
+ FileUtils.mkdir_p(path) unless File.directory?(path)
38
+ end
39
+
40
+ def user_should_exist
41
+ expect(shell_out("grep -q #{username} /etc/passwd").error?).to be(false)
42
+ end
43
+
44
+ def check_password(pass, user)
45
+ expect(shell_out("grep ^#{user}: /etc/shadow | cut -d: -f2 | grep ^#{pass}$").exitstatus).to eq(0)
46
+ end
47
+
48
+ let(:node) do
49
+ n = Chef::Node.new
50
+ n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
51
+ n
52
+ end
53
+
54
+ let(:events) do
55
+ Chef::EventDispatch::Dispatcher.new
56
+ end
57
+
58
+ let(:run_context) do
59
+ Chef::RunContext.new(node, {}, events)
60
+ end
61
+
62
+ let(:username) do
63
+ "greatchef"
64
+ end
65
+
66
+ let(:uid) { nil }
67
+ let(:gid) do
68
+ # SLES 15 doesn't have the "20" group and
69
+ # so lets just pick the last group... no,
70
+ # Etc.group.map(&:gid).last does not work
71
+ Etc.enum_for(:group).map(&:gid).last
72
+ end
73
+ let(:home) { nil }
74
+ let(:manage_home) { false }
75
+ let(:password) { "XXXYYYZZZ" }
76
+ let(:comment) { "Great Chef" }
77
+ let(:shell) { "/bin/bash" }
78
+ let(:salt) { nil }
79
+
80
+ let(:user_resource) do
81
+ r = Chef::Resource::User::LinuxUser.new("TEST USER RESOURCE", run_context)
82
+ r.username(username)
83
+ r.uid(uid)
84
+ r.gid(gid)
85
+
86
+ r.home(home)
87
+ r.shell(shell)
88
+ r.comment(comment)
89
+ r.manage_home(manage_home)
90
+ r.password(password)
91
+ r.salt(salt)
92
+ r
93
+ end
94
+
95
+ before do
96
+ clean_user
97
+ ensure_file_cache_path_exists
98
+ end
99
+
100
+ after(:each) do
101
+ clean_user
102
+ end
103
+
104
+ describe "action :create" do
105
+ it "should create the user" do
106
+ user_resource.run_action(:create)
107
+ user_should_exist
108
+ check_password(password, username)
109
+ end
110
+ end
111
+
112
+ describe "when user exists" do
113
+ before do
114
+ existing_resource = user_resource.dup
115
+ existing_resource.run_action(:create)
116
+ user_should_exist
117
+ end
118
+
119
+ describe "when password is updated" do
120
+ it "should update the password of the user" do
121
+ user_resource.password("mykitchen")
122
+ user_resource.run_action(:create)
123
+ check_password("mykitchen", username)
124
+ end
125
+ end
126
+ end
127
+ end
@@ -89,7 +89,9 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
89
89
 
90
90
  end
91
91
 
92
- after { delete_store }
92
+ after do
93
+ delete_store
94
+ end
93
95
 
94
96
  describe "action: create" do
95
97
  it "starts with no certificates" do
@@ -195,7 +197,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
195
197
  create_store
196
198
  end
197
199
  it "fails with no certificates in the store" do
198
- expect(Chef::Log).to receive(:info).with("Certificate not found")
200
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
199
201
 
200
202
  resource.source = tests_thumbprint
201
203
  resource.run_action(:verify)
@@ -219,7 +221,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
219
221
  end
220
222
 
221
223
  it "fails with an invalid thumbprint" do
222
- expect(Chef::Log).to receive(:info).with("Certificate not found")
224
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
223
225
 
224
226
  resource.source = others_thumbprint
225
227
  resource.run_action(:verify)
@@ -253,7 +255,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
253
255
  end
254
256
 
255
257
  it "fails with an invalid thumbprint" do
256
- expect(Chef::Log).to receive(:info).with("Certificate not found")
258
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
257
259
 
258
260
  resource.source = others_thumbprint
259
261
  resource.run_action(:verify)
@@ -265,11 +267,11 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
265
267
 
266
268
  describe "action: fetch" do
267
269
  context "with no certificate in the store" do
268
- it "throws an error with no certificates in the store" do
269
- expect(Chef::Log).not_to receive(:info)
270
+ it "logs a debug error with no certificates in the store" do
271
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
270
272
  resource.source = others_thumbprint
271
273
  resource.output_path = cert_output_path
272
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
274
+ resource.run_action(:fetch)
273
275
  end
274
276
  end
275
277
 
@@ -288,7 +290,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
288
290
  end
289
291
 
290
292
  it "fails with an invalid thumbprint" do
291
- expect(Chef::Log).not_to receive(:info)
293
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
292
294
 
293
295
  resource.source = others_thumbprint
294
296
 
@@ -296,7 +298,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
296
298
  path = File.join(dir, "test.pem")
297
299
 
298
300
  resource.output_path = path
299
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
301
+ resource.run_action(:fetch)
300
302
  end
301
303
 
302
304
  end
@@ -340,9 +342,10 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
340
342
  end
341
343
 
342
344
  describe "action: delete" do
343
- it "throws an argument error when attempting to delete a certificate that doesn't exist" do
345
+ it "logs an error when attempting to delete a certificate that doesn't exist" do
346
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
344
347
  resource.source = tests_thumbprint
345
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
348
+ resource.run_action(:delete)
346
349
  end
347
350
 
348
351
  it "deletes an existing certificate while leaving other certificates alone" do
@@ -360,7 +363,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
360
363
  expect(certificate_count).to eq(1)
361
364
  expect(resource).to be_updated_by_last_action
362
365
 
363
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
366
+ expect { resource.run_action :delete }.not_to raise_error
364
367
  expect(certificate_count).to eq(1)
365
368
  expect(resource).not_to be_updated_by_last_action
366
369
 
@@ -37,13 +37,16 @@ describe Chef::Resource::WindowsFont, :windows_only do
37
37
  resource
38
38
  end
39
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
40
+ ## these were commented out because testing hangs in the verify pipeline with them enabled. WEIRD
41
+ ## that needs to be addressed
44
42
 
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
43
+ # it "installs font on first install" do
44
+ # subject.run_action(:install)
45
+ # expect(subject).to be_updated_by_last_action
46
+ # end
47
+
48
+ # it "does not install font when already installed" do
49
+ # subject.run_action(:install)
50
+ # expect(subject).not_to be_updated_by_last_action
51
+ # end
49
52
  end
@@ -40,13 +40,32 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
40
40
  new_resource
41
41
  end
42
42
 
43
+ def set_automatic_managed_to_false
44
+ powershell_code = <<~EOH
45
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
46
+ $computersys.AutomaticManagedPagefile = $False;
47
+ $computersys.Put();
48
+ EOH
49
+ powershell_exec!(powershell_code)
50
+ end
51
+
52
+ def set_automatic_managed_to_true
53
+ powershell_code = <<~EOH
54
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
55
+ $computersys.AutomaticManagedPagefile = $True;
56
+ $computersys.Put();
57
+ EOH
58
+ powershell_exec!(powershell_code)
59
+ end
60
+
43
61
  describe "Setting Up Pagefile Management" do
44
62
  context "Disable Automatic Management" do
45
- it "Disables Automatic Management" do
63
+ it "Verifies Automatic Management is Disabled" do
64
+ set_automatic_managed_to_false
46
65
  subject.path c_path
47
66
  subject.automatic_managed false
48
67
  subject.run_action(:set)
49
- expect(subject).to be_updated_by_last_action
68
+ expect(subject).not_to be_updated_by_last_action
50
69
  end
51
70
 
52
71
  it "Enable Automatic Management " do
@@ -55,6 +74,14 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
55
74
  subject.run_action(:set)
56
75
  expect(subject).to be_updated_by_last_action
57
76
  end
77
+
78
+ it "Disables Automatic Management" do
79
+ set_automatic_managed_to_true
80
+ subject.path c_path
81
+ subject.automatic_managed false
82
+ subject.run_action(:set)
83
+ expect(subject).to be_updated_by_last_action
84
+ end
58
85
  end
59
86
  end
60
87
 
@@ -69,8 +96,8 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
69
96
  context "Update a pagefile" do
70
97
  it "Changes a pagefile to use custom sizes" do
71
98
  subject.path c_path
72
- subject.initial_size 20000
73
- subject.maximum_size 80000
99
+ subject.initial_size 128
100
+ subject.maximum_size 512
74
101
  subject.run_action(:set)
75
102
  expect(subject).to be_updated_by_last_action
76
103
  end
@@ -74,6 +74,18 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
74
74
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
75
75
  end
76
76
 
77
+ it "install package with source argument" do
78
+ zypper_package.source = "#{CHEF_SPEC_ASSETS}/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
79
+ zypper_package.run_action(:install)
80
+ expect(zypper_package.updated_by_last_action?).to be true
81
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
82
+ end
83
+
84
+ it "raises an error when passed a source that does not exist" do
85
+ zypper_package.source = "#{CHEF_SPEC_ASSETS}/false/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
86
+ expect { zypper_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
87
+ end
88
+
77
89
  it "does not install if the package is installed" do
78
90
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
79
91
  zypper_package.run_action(:install)
@@ -78,10 +78,15 @@ describe Shell do
78
78
  def run_chef_shell_with(options)
79
79
  # Windows ruby installs don't (always?) have PTY,
80
80
  # so hide the require here
81
-
82
81
  require "pty"
82
+
83
+ # FIXME this is temporary... Solaris envs have TERM set to unknown
84
+ # and the value isn't propagating from the build environment TERM
85
+ # variable
86
+ ENV["TERM"] = "vt100" if ["", "unknown"].include?(ENV["TERM"].to_s)
87
+
83
88
  config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA)
84
- reader, writer, pid = PTY.spawn("bundle exec chef-shell --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
89
+ reader, writer, pid = PTY.spawn("bundle exec #{ChefUtils::Dist::Infra::SHELL} --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
85
90
  read_until(reader, "chef (#{Chef::VERSION})>")
86
91
  yield reader, writer if block_given?
87
92
  writer.puts('"done"')
@@ -25,7 +25,7 @@ describe "Chef Versions", :executables do
25
25
  include Chef::Mixin::ShellOut
26
26
  let(:chef_dir) { File.join(__dir__, "..", "..") }
27
27
 
28
- binaries = [ ChefUtils::Dist::Infra::CLIENT, "chef-shell", "chef-apply", ChefUtils::Dist::Solo::EXEC ]
28
+ binaries = [ ChefUtils::Dist::Infra::CLIENT, ChefUtils::Dist::Infra::SHELL, "chef-apply", ChefUtils::Dist::Solo::EXEC ]
29
29
 
30
30
  binaries.each do |binary|
31
31
  it "#{binary} version should be sane" do