chef 12.13.37-universal-mingw32 → 12.14.60-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (338) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +48 -95
  3. data/Gemfile +6 -1
  4. data/README.md +9 -11
  5. data/VERSION +1 -1
  6. data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
  7. data/acceptance/Gemfile +4 -7
  8. data/acceptance/Gemfile.lock +59 -92
  9. data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
  10. data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
  13. data/chef.gemspec +3 -2
  14. data/lib/chef/application/client.rb +4 -4
  15. data/lib/chef/application/solo.rb +2 -2
  16. data/lib/chef/chef_fs/command_line.rb +36 -34
  17. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
  18. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  19. data/lib/chef/chef_fs/file_system.rb +139 -137
  20. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/synchronizer.rb +3 -3
  24. data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
  25. data/lib/chef/cookbook_uploader.rb +1 -1
  26. data/lib/chef/cookbook_version.rb +6 -6
  27. data/lib/chef/dsl/powershell.rb +1 -1
  28. data/lib/chef/event_dispatch/base.rb +2 -2
  29. data/lib/chef/exceptions.rb +1 -1
  30. data/lib/chef/file_cache.rb +1 -1
  31. data/lib/chef/formatters/base.rb +2 -2
  32. data/lib/chef/formatters/doc.rb +2 -2
  33. data/lib/chef/http.rb +48 -18
  34. data/lib/chef/http/auth_credentials.rb +1 -1
  35. data/lib/chef/http/basic_client.rb +11 -2
  36. data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
  37. data/lib/chef/key.rb +55 -56
  38. data/lib/chef/knife.rb +70 -61
  39. data/lib/chef/knife/client_delete.rb +2 -2
  40. data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
  41. data/lib/chef/knife/cookbook_show.rb +1 -1
  42. data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
  43. data/lib/chef/knife/search.rb +2 -2
  44. data/lib/chef/knife/ssh.rb +19 -21
  45. data/lib/chef/knife/status.rb +2 -2
  46. data/lib/chef/mixin/command/unix.rb +2 -2
  47. data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
  48. data/lib/chef/mixin/properties.rb +3 -0
  49. data/lib/chef/mixin/securable.rb +2 -2
  50. data/lib/chef/mixin/shell_out.rb +30 -0
  51. data/lib/chef/mixin/uris.rb +2 -1
  52. data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
  53. data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
  54. data/lib/chef/monologger.rb +1 -1
  55. data/lib/chef/node.rb +2 -2
  56. data/lib/chef/node/attribute.rb +3 -3
  57. data/lib/chef/platform/provider_mapping.rb +5 -2
  58. data/lib/chef/property.rb +14 -3
  59. data/lib/chef/provider/apt_repository.rb +3 -7
  60. data/lib/chef/provider/apt_update.rb +4 -6
  61. data/lib/chef/provider/cron.rb +1 -2
  62. data/lib/chef/provider/dsc_script.rb +4 -4
  63. data/lib/chef/provider/group/usermod.rb +1 -1
  64. data/lib/chef/provider/link.rb +10 -3
  65. data/lib/chef/provider/osx_profile.rb +10 -10
  66. data/lib/chef/provider/package.rb +2 -12
  67. data/lib/chef/provider/package/rubygems.rb +17 -16
  68. data/lib/chef/provider/package/windows.rb +2 -0
  69. data/lib/chef/provider/package/windows/exe.rb +1 -1
  70. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
  71. data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
  72. data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
  73. data/lib/chef/provider/remote_file/ftp.rb +2 -2
  74. data/lib/chef/provider/remote_file/sftp.rb +2 -2
  75. data/lib/chef/provider/service/debian.rb +2 -2
  76. data/lib/chef/provider/service/simple.rb +4 -3
  77. data/lib/chef/provider/service/solaris.rb +1 -1
  78. data/lib/chef/provider/service/systemd.rb +2 -2
  79. data/lib/chef/provider/service/upstart.rb +8 -5
  80. data/lib/chef/provider/support/yum_repo.erb +125 -0
  81. data/lib/chef/provider/systemd_unit.rb +11 -2
  82. data/lib/chef/provider/template_finder.rb +1 -1
  83. data/lib/chef/provider/user.rb +20 -16
  84. data/lib/chef/provider/user/aix.rb +5 -2
  85. data/lib/chef/provider/user/dscl.rb +1 -0
  86. data/lib/chef/provider/user/linux.rb +128 -0
  87. data/lib/chef/provider/user/pw.rb +2 -1
  88. data/lib/chef/provider/user/solaris.rb +3 -2
  89. data/lib/chef/provider/user/useradd.rb +5 -4
  90. data/lib/chef/provider/user/windows.rb +1 -1
  91. data/lib/chef/provider/windows_script.rb +5 -2
  92. data/lib/chef/provider/yum_repository.rb +121 -0
  93. data/lib/chef/providers.rb +4 -2
  94. data/lib/chef/resource.rb +7 -9
  95. data/lib/chef/resource/conditional.rb +9 -1
  96. data/lib/chef/resource/launchd.rb +1 -1
  97. data/lib/chef/resource/user.rb +3 -3
  98. data/lib/chef/resource/user/aix_user.rb +31 -0
  99. data/lib/chef/resource/user/dscl_user.rb +31 -0
  100. data/lib/chef/resource/user/linux_user.rb +51 -0
  101. data/lib/chef/resource/user/pw_user.rb +31 -0
  102. data/lib/chef/resource/user/solaris_user.rb +31 -0
  103. data/lib/chef/resource/user/windows_user.rb +31 -0
  104. data/lib/chef/resource/yum_package.rb +13 -12
  105. data/lib/chef/resource/yum_repository.rb +76 -0
  106. data/lib/chef/resource_builder.rb +1 -1
  107. data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
  108. data/lib/chef/resource_reporter.rb +5 -5
  109. data/lib/chef/resources.rb +7 -0
  110. data/lib/chef/run_context.rb +5 -3
  111. data/lib/chef/run_context/cookbook_compiler.rb +3 -2
  112. data/lib/chef/run_list.rb +2 -2
  113. data/lib/chef/search/query.rb +11 -8
  114. data/lib/chef/shell/ext.rb +2 -2
  115. data/lib/chef/shell/shell_session.rb +1 -1
  116. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  117. data/lib/chef/util/powershell/cmdlet.rb +5 -2
  118. data/lib/chef/util/selinux.rb +1 -1
  119. data/lib/chef/version.rb +1 -1
  120. data/lib/chef/version_class.rb +2 -2
  121. data/lib/chef/version_constraint.rb +2 -2
  122. data/lib/chef/win32/api/error.rb +2 -2
  123. data/lib/chef/win32/api/net.rb +1 -1
  124. data/lib/chef/win32/eventlog.rb +1 -1
  125. data/lib/chef/win32/net.rb +1 -1
  126. data/lib/chef/win32/security/sid.rb +1 -1
  127. data/spec/functional/assets/testchefsubsys +2 -3
  128. data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
  129. data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
  130. data/spec/functional/http/simple_spec.rb +2 -2
  131. data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
  132. data/spec/functional/knife/exec_spec.rb +6 -6
  133. data/spec/functional/knife/ssh_spec.rb +4 -4
  134. data/spec/functional/notifications_spec.rb +2 -2
  135. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  136. data/spec/functional/rebooter_spec.rb +5 -5
  137. data/spec/functional/resource/bash_spec.rb +2 -2
  138. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  139. data/spec/functional/resource/dpkg_package_spec.rb +2 -2
  140. data/spec/functional/resource/dsc_resource_spec.rb +5 -5
  141. data/spec/functional/resource/dsc_script_spec.rb +27 -22
  142. data/spec/functional/resource/env_spec.rb +4 -4
  143. data/spec/functional/resource/execute_spec.rb +4 -4
  144. data/spec/functional/resource/group_spec.rb +20 -8
  145. data/spec/functional/resource/link_spec.rb +34 -0
  146. data/spec/functional/resource/ohai_spec.rb +6 -6
  147. data/spec/functional/resource/reboot_spec.rb +2 -2
  148. data/spec/functional/resource/remote_file_spec.rb +16 -7
  149. data/spec/functional/resource/user/dscl_spec.rb +3 -3
  150. data/spec/functional/resource/user/useradd_spec.rb +32 -26
  151. data/spec/functional/resource/windows_service_spec.rb +15 -15
  152. data/spec/functional/rest_spec.rb +2 -2
  153. data/spec/functional/run_lock_spec.rb +9 -9
  154. data/spec/functional/tiny_server_spec.rb +9 -8
  155. data/spec/functional/win32/crypto_spec.rb +1 -1
  156. data/spec/functional/win32/security_spec.rb +8 -8
  157. data/spec/integration/client/client_spec.rb +6 -4
  158. data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
  159. data/spec/integration/knife/upload_spec.rb +1 -1
  160. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
  161. data/spec/integration/recipes/noop_resource_spec.rb +4 -4
  162. data/spec/integration/recipes/provider_choice.rb +3 -3
  163. data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
  164. data/spec/integration/recipes/resource_action_spec.rb +50 -54
  165. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
  166. data/spec/integration/recipes/resource_load_spec.rb +24 -24
  167. data/spec/integration/solo/solo_spec.rb +21 -30
  168. data/spec/scripts/ssl-serve.rb +1 -1
  169. data/spec/spec_helper.rb +1 -0
  170. data/spec/stress/win32/security_spec.rb +4 -4
  171. data/spec/support/chef_helpers.rb +22 -0
  172. data/spec/support/platform_helpers.rb +5 -1
  173. data/spec/support/shared/context/client.rb +3 -2
  174. data/spec/support/shared/functional/file_resource.rb +5 -4
  175. data/spec/support/shared/functional/http.rb +16 -16
  176. data/spec/support/shared/functional/securable_resource.rb +5 -5
  177. data/spec/support/shared/functional/win32_service.rb +5 -7
  178. data/spec/support/shared/integration/app_server_support.rb +1 -3
  179. data/spec/support/shared/integration/knife_support.rb +0 -2
  180. data/spec/support/shared/shared_examples.rb +2 -2
  181. data/spec/support/shared/unit/api_versioning.rb +2 -2
  182. data/spec/support/shared/unit/application_dot_d.rb +9 -6
  183. data/spec/support/shared/unit/provider/file.rb +2 -2
  184. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
  185. data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
  186. data/spec/support/shared/unit/script_resource.rb +4 -4
  187. data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
  188. data/spec/tiny_server.rb +51 -66
  189. data/spec/unit/api_client_v1_spec.rb +2 -2
  190. data/spec/unit/application_spec.rb +1 -1
  191. data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
  192. data/spec/unit/audit/audit_reporter_spec.rb +32 -23
  193. data/spec/unit/audit/control_group_data_spec.rb +19 -14
  194. data/spec/unit/chef_class_spec.rb +1 -1
  195. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
  196. data/spec/unit/chef_fs/diff_spec.rb +4 -4
  197. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
  198. data/spec/unit/chef_fs/file_system_spec.rb +2 -2
  199. data/spec/unit/chef_fs/parallelizer.rb +5 -7
  200. data/spec/unit/cookbook/metadata_spec.rb +98 -98
  201. data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
  202. data/spec/unit/cookbook_loader_spec.rb +24 -24
  203. data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
  204. data/spec/unit/daemon_spec.rb +1 -1
  205. data/spec/unit/data_bag_item_spec.rb +18 -18
  206. data/spec/unit/data_bag_spec.rb +2 -2
  207. data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
  208. data/spec/unit/data_collector/messages_spec.rb +2 -2
  209. data/spec/unit/data_collector_spec.rb +19 -19
  210. data/spec/unit/dsl/audit_spec.rb +3 -3
  211. data/spec/unit/dsl/data_query_spec.rb +3 -2
  212. data/spec/unit/dsl/declare_resource_spec.rb +10 -10
  213. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
  214. data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
  215. data/spec/unit/environment_spec.rb +6 -6
  216. data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
  217. data/spec/unit/file_access_control_spec.rb +3 -3
  218. data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
  219. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
  220. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
  221. data/spec/unit/http/basic_client_spec.rb +20 -0
  222. data/spec/unit/http/validate_content_length_spec.rb +8 -8
  223. data/spec/unit/http_spec.rb +14 -0
  224. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
  225. data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
  226. data/spec/unit/knife/bootstrap_spec.rb +8 -6
  227. data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
  228. data/spec/unit/knife/client_edit_spec.rb +2 -2
  229. data/spec/unit/knife/configure_client_spec.rb +2 -2
  230. data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
  231. data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
  232. data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
  233. data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
  234. data/spec/unit/knife/core/node_editor_spec.rb +3 -3
  235. data/spec/unit/knife/core/ui_spec.rb +2 -2
  236. data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
  237. data/spec/unit/knife/data_bag_show_spec.rb +3 -2
  238. data/spec/unit/knife/key_create_spec.rb +14 -14
  239. data/spec/unit/knife/key_delete_spec.rb +2 -2
  240. data/spec/unit/knife/key_edit_spec.rb +16 -16
  241. data/spec/unit/knife/key_list_spec.rb +6 -6
  242. data/spec/unit/knife/key_show_spec.rb +4 -4
  243. data/spec/unit/knife/status_spec.rb +3 -2
  244. data/spec/unit/knife/user_create_spec.rb +4 -4
  245. data/spec/unit/knife_spec.rb +7 -6
  246. data/spec/unit/lwrp_spec.rb +6 -6
  247. data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
  248. data/spec/unit/mixin/command_spec.rb +17 -14
  249. data/spec/unit/mixin/deprecation_spec.rb +1 -1
  250. data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
  251. data/spec/unit/mixin/params_validate_spec.rb +53 -52
  252. data/spec/unit/mixin/powershell_out_spec.rb +2 -2
  253. data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
  254. data/spec/unit/mixin/shell_out_spec.rb +1 -1
  255. data/spec/unit/mixin/xml_escape_spec.rb +3 -3
  256. data/spec/unit/node_spec.rb +2 -2
  257. data/spec/unit/platform/query_helpers_spec.rb +3 -3
  258. data/spec/unit/property_spec.rb +4 -4
  259. data/spec/unit/provider/cookbook_file_spec.rb +4 -4
  260. data/spec/unit/provider/cron/unix_spec.rb +4 -4
  261. data/spec/unit/provider/cron_spec.rb +2 -2
  262. data/spec/unit/provider/deploy_spec.rb +8 -8
  263. data/spec/unit/provider/dsc_resource_spec.rb +11 -10
  264. data/spec/unit/provider/dsc_script_spec.rb +9 -9
  265. data/spec/unit/provider/env/windows_spec.rb +8 -8
  266. data/spec/unit/provider/file/content_spec.rb +6 -6
  267. data/spec/unit/provider/file_spec.rb +4 -4
  268. data/spec/unit/provider/launchd_spec.rb +2 -1
  269. data/spec/unit/provider/link_spec.rb +155 -0
  270. data/spec/unit/provider/mount/mount_spec.rb +5 -5
  271. data/spec/unit/provider/mount/solaris_spec.rb +48 -48
  272. data/spec/unit/provider/osx_profile_spec.rb +6 -0
  273. data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
  274. data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
  275. data/spec/unit/provider/package/rubygems_spec.rb +50 -44
  276. data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
  277. data/spec/unit/provider/package/yum_spec.rb +61 -60
  278. data/spec/unit/provider/package_spec.rb +2 -2
  279. data/spec/unit/provider/powershell_script_spec.rb +4 -4
  280. data/spec/unit/provider/remote_directory_spec.rb +1 -1
  281. data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
  282. data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
  283. data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
  284. data/spec/unit/provider/remote_file_spec.rb +4 -4
  285. data/spec/unit/provider/script_spec.rb +4 -4
  286. data/spec/unit/provider/service/debian_service_spec.rb +4 -4
  287. data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
  288. data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
  289. data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
  290. data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
  291. data/spec/unit/provider/service/windows_spec.rb +10 -10
  292. data/spec/unit/provider/systemd_unit_spec.rb +2 -2
  293. data/spec/unit/provider/template/content_spec.rb +8 -8
  294. data/spec/unit/provider/template_spec.rb +8 -8
  295. data/spec/unit/provider/user/dscl_spec.rb +51 -51
  296. data/spec/unit/provider/user/linux_spec.rb +76 -0
  297. data/spec/unit/provider/user/pw_spec.rb +3 -6
  298. data/spec/unit/provider/user/solaris_spec.rb +5 -5
  299. data/spec/unit/provider/user/windows_spec.rb +3 -3
  300. data/spec/unit/provider/user_spec.rb +2 -2
  301. data/spec/unit/provider/yum_repository_spec.rb +35 -0
  302. data/spec/unit/provider_resolver_spec.rb +306 -264
  303. data/spec/unit/recipe_spec.rb +8 -7
  304. data/spec/unit/resource/apt_repository_spec.rb +4 -4
  305. data/spec/unit/resource/apt_update_spec.rb +4 -4
  306. data/spec/unit/resource/conditional_spec.rb +46 -0
  307. data/spec/unit/resource/dsc_resource_spec.rb +8 -8
  308. data/spec/unit/resource/dsc_script_spec.rb +4 -4
  309. data/spec/unit/resource/freebsd_package_spec.rb +6 -6
  310. data/spec/unit/resource/launchd_spec.rb +3 -2
  311. data/spec/unit/resource/osx_profile_spec.rb +3 -2
  312. data/spec/unit/resource/remote_file_spec.rb +6 -6
  313. data/spec/unit/resource/service_spec.rb +14 -14
  314. data/spec/unit/resource/user_spec.rb +1 -1
  315. data/spec/unit/resource/yum_repository_spec.rb +49 -0
  316. data/spec/unit/resource_collection_spec.rb +4 -4
  317. data/spec/unit/resource_definition_spec.rb +11 -11
  318. data/spec/unit/resource_reporter_spec.rb +4 -4
  319. data/spec/unit/resource_resolver_spec.rb +6 -6
  320. data/spec/unit/resource_spec.rb +36 -16
  321. data/spec/unit/run_context/child_run_context_spec.rb +4 -4
  322. data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
  323. data/spec/unit/run_context_spec.rb +8 -8
  324. data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
  325. data/spec/unit/runner_spec.rb +2 -2
  326. data/spec/unit/search/query_spec.rb +15 -14
  327. data/spec/unit/user_v1_spec.rb +8 -8
  328. data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
  329. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
  330. data/spec/unit/util/dsc/resource_store.rb +8 -6
  331. data/spec/unit/util/editor_spec.rb +6 -6
  332. data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
  333. data/tasks/bin/bundle-platform +1 -0
  334. data/tasks/bin/bundler_patch.rb +27 -0
  335. data/tasks/cbgb.rb +2 -2
  336. data/tasks/maintainers.rb +2 -2
  337. metadata +37 -8
  338. data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -18,7 +18,7 @@ describe "Resource.load_current_value" do
18
18
  before { Namer.incrementing_value = 0 }
19
19
 
20
20
  let(:resource_name) { :"load_current_value_dsl#{Namer.current_index}" }
21
- let(:resource_class) {
21
+ let(:resource_class) do
22
22
  result = Class.new(Chef::Resource) do
23
23
  def self.to_s; resource_name.to_s; end
24
24
 
@@ -37,7 +37,7 @@ describe "Resource.load_current_value" do
37
37
  end
38
38
  result.resource_name resource_name
39
39
  result
40
- }
40
+ end
41
41
 
42
42
  # Pull on resource_class to initialize it
43
43
  before { resource_class }
@@ -56,11 +56,11 @@ describe "Resource.load_current_value" do
56
56
  let(:resource) do
57
57
  e = self
58
58
  r = nil
59
- converge {
59
+ converge do
60
60
  r = public_send(e.resource_name, "blah") do
61
61
  x "desired"
62
62
  end
63
- }
63
+ end
64
64
  r
65
65
  end
66
66
 
@@ -83,17 +83,17 @@ describe "Resource.load_current_value" do
83
83
  end
84
84
 
85
85
  context "and identity: :i and :d with desired_state: false" do
86
- before {
86
+ before do
87
87
  resource_class.class_eval do
88
88
  property :i, identity: true
89
89
  property :d, desired_state: false
90
90
  end
91
- }
91
+ end
92
92
 
93
- before {
93
+ before do
94
94
  resource.i "desired_i"
95
95
  resource.d "desired_d"
96
- }
96
+ end
97
97
 
98
98
  it "i, name and d are passed to load_current_value, but not x" do
99
99
  expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)"
@@ -101,17 +101,17 @@ describe "Resource.load_current_value" do
101
101
  end
102
102
 
103
103
  context "and name_property: :i and :d with desired_state: false" do
104
- before {
104
+ before do
105
105
  resource_class.class_eval do
106
106
  property :i, name_property: true
107
107
  property :d, desired_state: false
108
108
  end
109
- }
109
+ end
110
110
 
111
- before {
111
+ before do
112
112
  resource.i "desired_i"
113
113
  resource.d "desired_d"
114
- }
114
+ end
115
115
 
116
116
  it "i, name and d are passed to load_current_value, but not x" do
117
117
  expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)"
@@ -123,10 +123,10 @@ describe "Resource.load_current_value" do
123
123
  let(:resource) do
124
124
  e = self
125
125
  r = nil
126
- converge {
126
+ converge do
127
127
  r = public_send(e.resource_name, "blah") do
128
128
  end
129
- }
129
+ end
130
130
  r
131
131
  end
132
132
 
@@ -135,16 +135,16 @@ describe "Resource.load_current_value" do
135
135
  end
136
136
  end
137
137
 
138
- let (:subresource_name) {
138
+ let (:subresource_name) do
139
139
  :"load_current_value_subresource_dsl#{Namer.current_index}"
140
- }
141
- let (:subresource_class) {
140
+ end
141
+ let (:subresource_class) do
142
142
  r = Class.new(resource_class) do
143
143
  property :y, default: lazy { "default_y #{Namer.incrementing_value}" }
144
144
  end
145
145
  r.resource_name subresource_name
146
146
  r
147
- }
147
+ end
148
148
 
149
149
  # Pull on subresource_class to initialize it
150
150
  before { subresource_class }
@@ -152,11 +152,11 @@ describe "Resource.load_current_value" do
152
152
  let(:subresource) do
153
153
  e = self
154
154
  r = nil
155
- converge {
155
+ converge do
156
156
  r = public_send(e.subresource_name, "blah") do
157
157
  x "desired"
158
158
  end
159
- }
159
+ end
160
160
  r
161
161
  end
162
162
 
@@ -170,14 +170,14 @@ describe "Resource.load_current_value" do
170
170
  end
171
171
 
172
172
  context "And a child resource class with load_current_value" do
173
- before {
173
+ before do
174
174
  subresource_class.load_current_value do
175
175
  y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
176
176
  select { |name, p| p.is_set?(self) }.
177
177
  map { |name, p| "#{name}=#{p.get(self)}" }.
178
178
  join(", ") })"
179
179
  end
180
- }
180
+ end
181
181
 
182
182
  it "the overridden load_current_value is used" do
183
183
  current_resource = subresource.current_value
@@ -187,7 +187,7 @@ describe "Resource.load_current_value" do
187
187
  end
188
188
 
189
189
  context "and a child resource class with load_current_value calling super()" do
190
- before {
190
+ before do
191
191
  subresource_class.load_current_value do
192
192
  super()
193
193
  y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
@@ -195,7 +195,7 @@ describe "Resource.load_current_value" do
195
195
  map { |name, p| "#{name}=#{p.get(self)}" }.
196
196
  join(", ") })"
197
197
  end
198
- }
198
+ end
199
199
 
200
200
  it "the original load_current_value is called as well as the child one" do
201
201
  current_resource = subresource.current_value
@@ -112,7 +112,11 @@ EOM
112
112
  file "cookbooks/x/recipes/default.rb", <<EOM
113
113
  ruby_block "sleeping" do
114
114
  block do
115
- sleep 10
115
+ retries = 200
116
+ while IO.read(Chef::Config[:log_location]) !~ /Chef client [0-9]+ is running, will wait for it to finish and then run./
117
+ sleep 0.1
118
+ raise "we ran out of retries" if ( retries -= 1 ) <= 0
119
+ end
116
120
  end
117
121
  end
118
122
  EOM
@@ -125,51 +129,38 @@ file_cache_path "#{path_to('config/cache')}"
125
129
  EOM
126
130
  # We have a timeout protection here so that if due to some bug
127
131
  # run_lock gets stuck we can discover it.
128
- expect {
132
+ expect do
129
133
  Timeout.timeout(120) do
130
134
  chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..")
131
135
 
132
- # Instantiate the first chef-solo run
133
- s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
134
- -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
136
+ threads = []
135
137
 
136
- # Give it some time to progress
137
- sleep 5
138
+ # Instantiate the first chef-solo run
139
+ threads << Thread.new do
140
+ s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
141
+ Process.waitpid(s1)
142
+ end
138
143
 
139
144
  # Instantiate the second chef-solo run
140
- s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
141
- -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
145
+ threads << Thread.new do
146
+ s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
147
+ Process.waitpid(s2)
148
+ end
142
149
 
143
- Process.waitpid(s1)
144
- Process.waitpid(s2)
150
+ threads.each(&:join)
145
151
  end
146
- }.not_to raise_error
152
+ end.not_to raise_error
147
153
 
148
154
  # Unfortunately file / directory helpers in integration tests
149
155
  # are implemented using before(:each) so we need to do all below
150
156
  # checks in one example.
151
157
  run_log = File.read(path_to("logs/runs.log"))
152
158
 
159
+ # second run should have a message which indicates it's waiting for the first run
160
+ expect(run_log).to match(/Chef client [0-9]+ is running, will wait for it to finish and then run./)
161
+
153
162
  # both of the runs should succeed
154
163
  expect(run_log.lines.reject { |l| !l.include? "INFO: Chef Run complete in" }.length).to eq(2)
155
-
156
- # second run should have a message which indicates it's waiting for the first run
157
- pid_lines = run_log.lines.reject { |l| !l.include? "Chef-client pid:" }
158
- expect(pid_lines.length).to eq(2)
159
- pids = pid_lines.map { |l| l.split(" ").last }
160
- expect(run_log).to include("Chef client #{pids[0]} is running, will wait for it to finish and then run.")
161
-
162
- # second run should start after first run ends
163
- starts = [ ]
164
- ends = [ ]
165
- run_log.lines.each_with_index do |line, index|
166
- if line.include? "Chef-client pid:"
167
- starts << index
168
- elsif line.include? "INFO: Chef Run complete in"
169
- ends << index
170
- end
171
- end
172
- expect(starts[1]).to be > ends[0]
173
164
  end
174
165
 
175
166
  end
@@ -42,6 +42,6 @@ webrick_opts = DEFAULT_OPTIONS.merge(server_opts)
42
42
  pp :webrick_opts => webrick_opts
43
43
 
44
44
  server = WEBrick::HTTPServer.new(webrick_opts)
45
- trap "INT" do server.shutdown end
45
+ trap("INT") { server.shutdown }
46
46
 
47
47
  server.start
@@ -152,6 +152,7 @@ RSpec.configure do |config|
152
152
  config.filter_run_excluding :solaris_only => true unless solaris?
153
153
  config.filter_run_excluding :system_windows_service_gem_only => true unless system_windows_service_gem?
154
154
  config.filter_run_excluding :unix_only => true unless unix?
155
+ config.filter_run_excluding :linux_only => true unless linux?
155
156
  config.filter_run_excluding :aix_only => true unless aix?
156
157
  config.filter_run_excluding :debian_family_only => true unless debian_family?
157
158
  config.filter_run_excluding :supports_cloexec => true unless supports_cloexec?
@@ -49,21 +49,21 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do
49
49
  end
50
50
 
51
51
  it "should not leak when retrieving and reading the ACE from a file", :volatile do
52
- expect {
52
+ expect do
53
53
  sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid }
54
54
  GC.start
55
- }.not_to leak_memory(:warmup => 50, :iterations => 100)
55
+ end.not_to leak_memory(:warmup => 50, :iterations => 100)
56
56
  end
57
57
 
58
58
  it "should not leak when creating a new ACL and setting it on a file", :volatile do
59
59
  securable_object = Security::SecurableObject.new(@monkeyfoo)
60
- expect {
60
+ expect do
61
61
  securable_object.dacl = Chef::ReservedNames::Win32::Security::ACL.create([
62
62
  Chef::ReservedNames::Win32::Security::ACE.access_allowed(Chef::ReservedNames::Win32::Security::SID.Everyone, Chef::ReservedNames::Win32::API::Security::GENERIC_READ),
63
63
  Chef::ReservedNames::Win32::Security::ACE.access_denied(Chef::ReservedNames::Win32::Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL),
64
64
  ])
65
65
  GC.start
66
- }.not_to leak_memory(:warmup => 50, :iterations => 100)
66
+ end.not_to leak_memory(:warmup => 50, :iterations => 100)
67
67
  end
68
68
 
69
69
  end
@@ -84,6 +84,28 @@ def canonicalize_path(path)
84
84
  windows? ? path.tr("/", '\\') : path
85
85
  end
86
86
 
87
+ # Makes a temp directory with a canonical path on any platform.
88
+ # Only really needed to work around an issue on Windows where
89
+ # Ruby's temp library generates paths with short names.
90
+ def make_canonical_temp_directory
91
+ temp_directory = Dir.mktmpdir
92
+ if windows?
93
+ # On Windows, temporary file / directory path names may have shortened
94
+ # subdirectory names due to reliance on the TMP and TEMP environment variables
95
+ # in some Windows APIs and duplicated logic in Ruby's temp file implementation.
96
+ # To work around this in the unit test context, we obtain the long (canonical)
97
+ # path name via a Windows system call so that this path name can be used
98
+ # in expectations that assume the ability to canonically name paths in comparisons.
99
+ # Note that this was not an issue prior to Ruby 2.2 -- with Ruby 2.2,
100
+ # some Chef code started to use long file names, while Ruby's temp file implementation
101
+ # continued to return the shortened names -- this would cause these particular tests to
102
+ # fail if the username happened to be longer than 8 characters.
103
+ Chef::ReservedNames::Win32::File.get_long_path_name(temp_directory)
104
+ else
105
+ temp_directory
106
+ end
107
+ end
108
+
87
109
  # Check if a cmd exists on the PATH
88
110
  def which(cmd)
89
111
  paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
@@ -126,6 +126,10 @@ def unix?
126
126
  !windows?
127
127
  end
128
128
 
129
+ def linux?
130
+ !!(RUBY_PLATFORM =~ /linux/)
131
+ end
132
+
129
133
  def os_x?
130
134
  !!(RUBY_PLATFORM =~ /darwin/)
131
135
  end
@@ -169,7 +173,7 @@ def selinux_enabled?
169
173
  when 0
170
174
  return true
171
175
  else
172
- raise RuntimeError, "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}"
176
+ raise "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}"
173
177
  end
174
178
  else
175
179
  # We assume selinux is not enabled if selinux utils are not
@@ -230,8 +230,9 @@ shared_context "audit phase failed with error" do
230
230
  end
231
231
 
232
232
  shared_context "audit phase completed with failed controls" do
233
- let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => true,
234
- :num_failed => 1, :num_total => 3) }
233
+ let(:audit_runner) do
234
+ instance_double("Chef::Audit::Runner", :failed? => true,
235
+ :num_failed => 1, :num_total => 3) end
235
236
 
236
237
  let(:audit_error) do
237
238
  err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
@@ -400,9 +400,9 @@ shared_examples_for "a configured file resource" do
400
400
  end
401
401
 
402
402
  context "when the target file is a symlink", :not_supported_on_win2k3 do
403
- let(:symlink_target) {
403
+ let(:symlink_target) do
404
404
  File.join(CHEF_SPEC_DATA, "file-test-target")
405
- }
405
+ end
406
406
 
407
407
  describe "when configured not to manage symlink's target" do
408
408
  before(:each) do
@@ -820,9 +820,9 @@ shared_examples_for "a configured file resource" do
820
820
  end
821
821
 
822
822
  describe "when path is specified with windows separator", :windows_only do
823
- let(:path) {
823
+ let(:path) do
824
824
  File.join(test_file_dir, make_tmpname(file_base)).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)
825
- }
825
+ end
826
826
 
827
827
  before do
828
828
  @notified_resource = Chef::Resource.new("punk", resource.run_context)
@@ -1035,6 +1035,7 @@ shared_context Chef::Resource::File do
1035
1035
  end
1036
1036
 
1037
1037
  before do
1038
+ FileUtils.rm_rf(test_file_dir)
1038
1039
  FileUtils.mkdir_p(test_file_dir)
1039
1040
  end
1040
1041
 
@@ -52,27 +52,27 @@ module ChefHTTPShared
52
52
 
53
53
  # just a normal file
54
54
  # (expected_content should be uncompressed)
55
- @api.get("/nyan_cat.png", 200) {
55
+ @api.get("/nyan_cat.png", 200) do
56
56
  File.open(nyan_uncompressed_filename, "rb") do |f|
57
57
  f.read
58
58
  end
59
- }
59
+ end
60
60
 
61
61
  # this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
62
62
  # (expected_content should be compressed)
63
- @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
63
+ @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
64
64
  File.open(nyan_compressed_filename, "rb") do |f|
65
65
  f.read
66
66
  end
67
- }
67
+ end
68
68
 
69
69
  # this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
70
70
  # (expected_content should be uncompressed)
71
- @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
71
+ @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
72
72
  File.open(nyan_compressed_filename, "rb") do |f|
73
73
  f.read
74
74
  end
75
- }
75
+ end
76
76
 
77
77
  #
78
78
  # endpoints that set Content-Length correctly
@@ -83,11 +83,11 @@ module ChefHTTPShared
83
83
  {
84
84
  "Content-Length" => nyan_uncompressed_size.to_s,
85
85
  }
86
- ) {
86
+ ) do
87
87
  File.open(nyan_uncompressed_filename, "rb") do |f|
88
88
  f.read
89
89
  end
90
- }
90
+ end
91
91
 
92
92
  # (expected_content should be uncompressed)
93
93
  @api.get("/nyan_cat_content_length_compressed.png", 200, nil,
@@ -96,11 +96,11 @@ module ChefHTTPShared
96
96
  "Content-Type" => "application/gzip",
97
97
  "Content-Encoding" => "gzip",
98
98
  }
99
- ) {
99
+ ) do
100
100
  File.open(nyan_compressed_filename, "rb") do |f|
101
101
  f.read
102
102
  end
103
- }
103
+ end
104
104
 
105
105
  #
106
106
  # endpoints that simulate truncated downloads (bad content-length header)
@@ -111,11 +111,11 @@ module ChefHTTPShared
111
111
  {
112
112
  "Content-Length" => (nyan_uncompressed_size + 1).to_s,
113
113
  }
114
- ) {
114
+ ) do
115
115
  File.open(nyan_uncompressed_filename, "rb") do |f|
116
116
  f.read
117
117
  end
118
- }
118
+ end
119
119
 
120
120
  # (expected_content should be uncompressed)
121
121
  @api.get("/nyan_cat_truncated_compressed.png", 200, nil,
@@ -124,11 +124,11 @@ module ChefHTTPShared
124
124
  "Content-Type" => "application/gzip",
125
125
  "Content-Encoding" => "gzip",
126
126
  }
127
- ) {
127
+ ) do
128
128
  File.open(nyan_compressed_filename, "rb") do |f|
129
129
  f.read
130
130
  end
131
- }
131
+ end
132
132
 
133
133
  #
134
134
  # in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
@@ -140,11 +140,11 @@ module ChefHTTPShared
140
140
  "Content-Length" => (nyan_uncompressed_size + 1).to_s,
141
141
  "Transfer-Encoding" => "anything",
142
142
  }
143
- ) {
143
+ ) do
144
144
  File.open(nyan_uncompressed_filename, "rb") do |f|
145
145
  f.read
146
146
  end
147
- }
147
+ end
148
148
 
149
149
  #
150
150
  # 403 with a Content-Length