chef 12.4.3-universal-mingw32 → 12.5.1-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +21 -25
  3. data/Gemfile +46 -0
  4. data/README.md +4 -4
  5. data/Rakefile +4 -110
  6. data/bin/chef-service-manager +3 -1
  7. data/distro/common/html/knife_cookbook_site.html +18 -18
  8. data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
  9. data/lib/chef.rb +1 -1
  10. data/lib/chef/application.rb +1 -1
  11. data/lib/chef/application/apply.rb +19 -1
  12. data/lib/chef/application/client.rb +11 -5
  13. data/lib/chef/application/knife.rb +2 -2
  14. data/lib/chef/application/solo.rb +1 -1
  15. data/lib/chef/application/windows_service_manager.rb +19 -12
  16. data/lib/chef/chef_class.rb +46 -0
  17. data/lib/chef/chef_fs/config.rb +22 -24
  18. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
  19. data/lib/chef/chef_fs/file_pattern.rb +4 -15
  20. data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
  21. data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
  22. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
  23. data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
  24. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
  25. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
  26. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
  27. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
  28. data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
  29. data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
  30. data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
  31. data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
  32. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
  33. data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
  34. data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
  35. data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
  36. data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
  37. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
  38. data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
  39. data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
  40. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
  41. data/lib/chef/chef_fs/knife.rb +35 -7
  42. data/lib/chef/chef_fs/path_utils.rb +65 -34
  43. data/lib/chef/client.rb +2 -3
  44. data/lib/chef/config.rb +34 -2
  45. data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
  46. data/lib/chef/cookbook/metadata.rb +25 -3
  47. data/lib/chef/cookbook/synchronizer.rb +1 -1
  48. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  49. data/lib/chef/cookbook_version.rb +3 -3
  50. data/lib/chef/delayed_evaluator.rb +21 -0
  51. data/lib/chef/deprecation/mixin/template.rb +1 -2
  52. data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
  53. data/lib/chef/deprecation/provider/file.rb +1 -1
  54. data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
  55. data/lib/chef/deprecation/provider/remote_file.rb +1 -2
  56. data/lib/chef/deprecation/provider/template.rb +1 -1
  57. data/lib/chef/deprecation/warnings.rb +3 -4
  58. data/lib/chef/dsl/reboot_pending.rb +3 -2
  59. data/lib/chef/dsl/recipe.rb +26 -7
  60. data/lib/chef/dsl/resources.rb +2 -2
  61. data/lib/chef/event_dispatch/base.rb +51 -22
  62. data/lib/chef/event_dispatch/dispatcher.rb +21 -6
  63. data/lib/chef/event_dispatch/dsl.rb +64 -0
  64. data/lib/chef/exceptions.rb +28 -1
  65. data/lib/chef/file_content_management/tempfile.rb +1 -1
  66. data/lib/chef/formatters/base.rb +3 -0
  67. data/lib/chef/formatters/doc.rb +56 -6
  68. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
  69. data/lib/chef/formatters/minimal.rb +2 -2
  70. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
  71. data/lib/chef/http/http_request.rb +1 -1
  72. data/lib/chef/knife.rb +35 -55
  73. data/lib/chef/knife/bootstrap.rb +41 -0
  74. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
  75. data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
  76. data/lib/chef/knife/bootstrap/templates/README.md +3 -4
  77. data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
  78. data/lib/chef/knife/cookbook_create.rb +1 -1
  79. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  80. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  81. data/lib/chef/knife/cookbook_site_share.rb +6 -6
  82. data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
  83. data/lib/chef/knife/core/bootstrap_context.rb +12 -4
  84. data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
  85. data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
  86. data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
  87. data/lib/chef/knife/core/node_presenter.rb +24 -1
  88. data/lib/chef/knife/core/object_loader.rb +1 -0
  89. data/lib/chef/knife/core/subcommand_loader.rb +131 -146
  90. data/lib/chef/knife/node_run_list_remove.rb +12 -1
  91. data/lib/chef/knife/null.rb +10 -0
  92. data/lib/chef/knife/rehash.rb +62 -0
  93. data/lib/chef/knife/search.rb +3 -3
  94. data/lib/chef/knife/ssh.rb +52 -30
  95. data/lib/chef/knife/ssl_check.rb +3 -2
  96. data/lib/chef/knife/user_edit.rb +1 -2
  97. data/lib/chef/local_mode.rb +5 -0
  98. data/lib/chef/log.rb +5 -1
  99. data/lib/chef/mixin/deprecation.rb +8 -8
  100. data/lib/chef/mixin/params_validate.rb +362 -135
  101. data/lib/chef/mixin/template.rb +48 -0
  102. data/lib/chef/mixin/which.rb +1 -1
  103. data/lib/chef/mixin/wide_string.rb +72 -0
  104. data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
  105. data/lib/chef/mixin/windows_env_helper.rb +4 -1
  106. data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
  107. data/lib/chef/monkey_patches/win32/registry.rb +72 -0
  108. data/lib/chef/node.rb +116 -3
  109. data/lib/chef/node_map.rb +2 -2
  110. data/lib/chef/platform/handler_map.rb +0 -5
  111. data/lib/chef/platform/provider_mapping.rb +5 -6
  112. data/lib/chef/platform/query_helpers.rb +46 -4
  113. data/lib/chef/platform/rebooter.rb +1 -1
  114. data/lib/chef/platform/service_helpers.rb +30 -32
  115. data/lib/chef/policy_builder.rb +1 -8
  116. data/lib/chef/policy_builder/dynamic.rb +186 -0
  117. data/lib/chef/policy_builder/expand_node_object.rb +30 -15
  118. data/lib/chef/policy_builder/policyfile.rb +155 -18
  119. data/lib/chef/property.rb +568 -0
  120. data/lib/chef/provider.rb +222 -13
  121. data/lib/chef/provider/batch.rb +8 -0
  122. data/lib/chef/provider/deploy.rb +5 -7
  123. data/lib/chef/provider/directory.rb +14 -2
  124. data/lib/chef/provider/dsc_resource.rb +5 -9
  125. data/lib/chef/provider/group/pw.rb +1 -1
  126. data/lib/chef/provider/ifconfig.rb +2 -2
  127. data/lib/chef/provider/lwrp_base.rb +1 -75
  128. data/lib/chef/provider/mount.rb +7 -3
  129. data/lib/chef/provider/package.rb +1 -1
  130. data/lib/chef/provider/package/dpkg.rb +5 -11
  131. data/lib/chef/provider/package/rpm.rb +2 -2
  132. data/lib/chef/provider/package/rubygems.rb +1 -1
  133. data/lib/chef/provider/package/windows/msi.rb +2 -2
  134. data/lib/chef/provider/package/yum.rb +17 -5
  135. data/lib/chef/provider/powershell_script.rb +59 -23
  136. data/lib/chef/provider/registry_key.rb +5 -5
  137. data/lib/chef/provider/remote_directory.rb +190 -102
  138. data/lib/chef/provider/service.rb +12 -2
  139. data/lib/chef/provider/service/aix.rb +1 -1
  140. data/lib/chef/provider/service/debian.rb +3 -5
  141. data/lib/chef/provider/service/freebsd.rb +1 -1
  142. data/lib/chef/provider/service/gentoo.rb +3 -3
  143. data/lib/chef/provider/service/init.rb +3 -3
  144. data/lib/chef/provider/service/insserv.rb +2 -4
  145. data/lib/chef/provider/service/invokercd.rb +2 -4
  146. data/lib/chef/provider/service/macosx.rb +5 -1
  147. data/lib/chef/provider/service/openbsd.rb +2 -1
  148. data/lib/chef/provider/service/redhat.rb +52 -16
  149. data/lib/chef/provider/service/simple.rb +2 -2
  150. data/lib/chef/provider/service/systemd.rb +3 -5
  151. data/lib/chef/provider/service/upstart.rb +4 -6
  152. data/lib/chef/provider/subversion.rb +13 -7
  153. data/lib/chef/provider/template/content.rb +16 -6
  154. data/lib/chef/provider/user/solaris.rb +32 -4
  155. data/lib/chef/provider/windows_script.rb +3 -5
  156. data/lib/chef/provider_resolver.rb +2 -2
  157. data/lib/chef/recipe.rb +1 -8
  158. data/lib/chef/resource.rb +563 -90
  159. data/lib/chef/resource/action_class.rb +83 -0
  160. data/lib/chef/resource/chef_gem.rb +3 -3
  161. data/lib/chef/resource/deploy.rb +8 -2
  162. data/lib/chef/resource/dsc_script.rb +2 -0
  163. data/lib/chef/resource/file/verification.rb +7 -1
  164. data/lib/chef/resource/lwrp_base.rb +1 -7
  165. data/lib/chef/resource/registry_key.rb +1 -1
  166. data/lib/chef/resource/service.rb +10 -2
  167. data/lib/chef/resource/subversion.rb +5 -0
  168. data/lib/chef/resource/windows_script.rb +6 -2
  169. data/lib/chef/resource/yum_package.rb +10 -1
  170. data/lib/chef/resource_resolver.rb +3 -3
  171. data/lib/chef/run_context.rb +402 -83
  172. data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
  173. data/lib/chef/run_lock.rb +30 -21
  174. data/lib/chef/util/powershell/ps_credential.rb +4 -0
  175. data/lib/chef/util/windows.rb +0 -32
  176. data/lib/chef/util/windows/net_group.rb +85 -106
  177. data/lib/chef/util/windows/net_use.rb +35 -71
  178. data/lib/chef/util/windows/net_user.rb +0 -1
  179. data/lib/chef/util/windows/volume.rb +19 -19
  180. data/lib/chef/version.rb +3 -3
  181. data/lib/chef/win32/api.rb +1 -0
  182. data/lib/chef/win32/api/file.rb +20 -0
  183. data/lib/chef/win32/api/net.rb +163 -43
  184. data/lib/chef/win32/api/registry.rb +51 -0
  185. data/lib/chef/win32/api/system.rb +23 -0
  186. data/lib/chef/win32/api/unicode.rb +0 -43
  187. data/lib/chef/win32/crypto.rb +2 -1
  188. data/lib/chef/win32/file.rb +28 -3
  189. data/lib/chef/win32/mutex.rb +1 -2
  190. data/lib/chef/win32/net.rb +162 -8
  191. data/lib/chef/win32/process.rb +13 -0
  192. data/lib/chef/win32/registry.rb +35 -30
  193. data/lib/chef/win32/security.rb +1 -1
  194. data/lib/chef/win32/security/token.rb +1 -1
  195. data/lib/chef/win32/system.rb +62 -0
  196. data/lib/chef/win32/unicode.rb +7 -2
  197. data/lib/chef/win32/version.rb +0 -4
  198. data/lib/chef/workstation_config_loader.rb +3 -158
  199. data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
  200. data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
  201. data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
  202. data/spec/data/dsc_lcm.pfx +0 -0
  203. data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
  204. data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
  205. data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
  206. data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
  207. data/spec/functional/knife/ssh_spec.rb +16 -0
  208. data/spec/functional/rebooter_spec.rb +1 -1
  209. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  210. data/spec/functional/resource/dsc_resource_spec.rb +2 -0
  211. data/spec/functional/resource/dsc_script_spec.rb +91 -2
  212. data/spec/functional/resource/group_spec.rb +67 -44
  213. data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
  214. data/spec/functional/resource/windows_service_spec.rb +1 -1
  215. data/spec/functional/run_lock_spec.rb +368 -189
  216. data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
  217. data/spec/functional/win32/service_manager_spec.rb +2 -2
  218. data/spec/integration/client/client_spec.rb +51 -0
  219. data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
  220. data/spec/integration/knife/download_spec.rb +4 -0
  221. data/spec/integration/knife/list_spec.rb +8 -0
  222. data/spec/integration/knife/upload_spec.rb +1 -1
  223. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
  224. data/spec/integration/recipes/remote_directory.rb +74 -0
  225. data/spec/integration/recipes/resource_action_spec.rb +363 -0
  226. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
  227. data/spec/integration/recipes/resource_load_spec.rb +206 -0
  228. data/spec/spec_helper.rb +9 -0
  229. data/spec/support/platform_helpers.rb +13 -0
  230. data/spec/support/shared/context/win32.rb +34 -0
  231. data/spec/support/shared/functional/win32_service.rb +2 -1
  232. data/spec/support/shared/functional/windows_script.rb +63 -26
  233. data/spec/support/shared/unit/mock_shellout.rb +46 -0
  234. data/spec/support/shared/unit/provider/file.rb +10 -4
  235. data/spec/unit/application/client_spec.rb +16 -3
  236. data/spec/unit/application/knife_spec.rb +2 -2
  237. data/spec/unit/application/solo_spec.rb +4 -3
  238. data/spec/unit/chef_class_spec.rb +23 -4
  239. data/spec/unit/chef_fs/path_util_spec.rb +108 -0
  240. data/spec/unit/client_spec.rb +6 -1
  241. data/spec/unit/config_spec.rb +31 -0
  242. data/spec/unit/cookbook/metadata_spec.rb +23 -3
  243. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  244. data/spec/unit/deprecation_spec.rb +3 -6
  245. data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
  246. data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
  247. data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
  248. data/spec/unit/formatters/doc_spec.rb +32 -0
  249. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
  250. data/spec/unit/json_compat_spec.rb +4 -3
  251. data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
  252. data/spec/unit/knife/bootstrap_spec.rb +55 -3
  253. data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
  254. data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
  255. data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
  256. data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
  257. data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
  258. data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
  259. data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
  260. data/spec/unit/knife/ssl_check_spec.rb +4 -0
  261. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
  262. data/spec/unit/mixin/params_validate_spec.rb +4 -2
  263. data/spec/unit/mixin/template_spec.rb +5 -1
  264. data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
  265. data/spec/unit/node_spec.rb +220 -0
  266. data/spec/unit/platform/query_helpers_spec.rb +146 -3
  267. data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
  268. data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
  269. data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
  270. data/spec/unit/property/state_spec.rb +506 -0
  271. data/spec/unit/property/validation_spec.rb +663 -0
  272. data/spec/unit/property_spec.rb +1094 -0
  273. data/spec/unit/provider/deploy_spec.rb +5 -5
  274. data/spec/unit/provider/directory_spec.rb +35 -0
  275. data/spec/unit/provider/dsc_resource_spec.rb +3 -10
  276. data/spec/unit/provider/ifconfig_spec.rb +22 -2
  277. data/spec/unit/provider/mount/aix_spec.rb +2 -1
  278. data/spec/unit/provider/mount/mount_spec.rb +6 -0
  279. data/spec/unit/provider/mount/windows_spec.rb +14 -0
  280. data/spec/unit/provider/mount_spec.rb +12 -1
  281. data/spec/unit/provider/package/dpkg_spec.rb +8 -1
  282. data/spec/unit/provider/package/rpm_spec.rb +18 -1
  283. data/spec/unit/provider/package/rubygems_spec.rb +18 -0
  284. data/spec/unit/provider/package/yum_spec.rb +97 -24
  285. data/spec/unit/provider/powershell_script_spec.rb +106 -0
  286. data/spec/unit/provider/registry_key_spec.rb +12 -0
  287. data/spec/unit/provider/remote_directory_spec.rb +1 -2
  288. data/spec/unit/provider/service/aix_service_spec.rb +3 -3
  289. data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
  290. data/spec/unit/provider/service/macosx_spec.rb +4 -4
  291. data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
  292. data/spec/unit/provider/service/redhat_spec.rb +88 -8
  293. data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
  294. data/spec/unit/provider/service/windows_spec.rb +211 -200
  295. data/spec/unit/provider/subversion_spec.rb +50 -31
  296. data/spec/unit/provider/template/content_spec.rb +93 -2
  297. data/spec/unit/provider/user/solaris_spec.rb +66 -9
  298. data/spec/unit/provider_resolver_spec.rb +707 -650
  299. data/spec/unit/provider_spec.rb +1 -3
  300. data/spec/unit/recipe_spec.rb +0 -4
  301. data/spec/unit/resource/deploy_spec.rb +7 -1
  302. data/spec/unit/resource/dsc_script_spec.rb +4 -0
  303. data/spec/unit/resource/file/verification_spec.rb +33 -5
  304. data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
  305. data/spec/unit/resource/service_spec.rb +4 -4
  306. data/spec/unit/resource/subversion_spec.rb +4 -0
  307. data/spec/unit/resource/yum_package_spec.rb +10 -1
  308. data/spec/unit/resource_spec.rb +2 -2
  309. data/spec/unit/run_context/child_run_context_spec.rb +133 -0
  310. data/spec/unit/run_context_spec.rb +7 -0
  311. data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
  312. data/spec/unit/win32/registry_spec.rb +394 -0
  313. data/tasks/external_tests.rb +47 -23
  314. data/tasks/maintainers.rb +155 -14
  315. metadata +64 -53
  316. data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
  317. data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
  318. data/spec/unit/provider/powershell_spec.rb +0 -80
  319. data/spec/unit/registry_helper_spec.rb +0 -376
  320. data/spec/unit/workstation_config_loader_spec.rb +0 -283
@@ -20,25 +20,6 @@
20
20
  require 'spec_helper'
21
21
  require 'chef/win32/registry'
22
22
 
23
- describe Chef::Resource::RegistryKey, :unix_only do
24
- before(:all) do
25
- events = Chef::EventDispatch::Dispatcher.new
26
- node = Chef::Node.new
27
- ohai = Ohai::System.new
28
- ohai.all_plugins
29
- node.consume_external_attrs(ohai.data,{})
30
- run_context = Chef::RunContext.new(node, {}, events)
31
- @resource = Chef::Resource::RegistryKey.new("HKCU\\Software", run_context)
32
- end
33
- context "when load_current_resource is run on a non-windows node" do
34
- it "throws an exception because you don't have a windows registry (derp)" do
35
- @resource.key("HKCU\\Software\\Opscode")
36
- @resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
37
- expect{@resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32NotWindows)
38
- end
39
- end
40
- end
41
-
42
23
  describe 'Chef::Win32::Registry', :windows_only do
43
24
 
44
25
  before(:all) do
@@ -130,6 +111,9 @@ describe 'Chef::Win32::Registry', :windows_only do
130
111
  it "returns true if the value exists" do
131
112
  expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
132
113
  end
114
+ it "returns true if the value exists with a case mismatch on the value name" do
115
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals"})).to eq(true)
116
+ end
133
117
  it "returns false if the value does not exist" do
134
118
  expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})).to eq(false)
135
119
  end
@@ -145,6 +129,9 @@ describe 'Chef::Win32::Registry', :windows_only do
145
129
  it "returns true if the value exists" do
146
130
  expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
147
131
  end
132
+ it "returns true if the value exists with a case mismatch on the value name" do
133
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals"})).to eq(true)
134
+ end
148
135
  it "throws an exception if the value does not exist" do
149
136
  expect {@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
150
137
  end
@@ -160,6 +147,9 @@ describe 'Chef::Win32::Registry', :windows_only do
160
147
  it "returns true if all the data matches" do
161
148
  expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
162
149
  end
150
+ it "returns true if all the data matches with a case mismatch on the data name" do
151
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
152
+ end
163
153
  it "returns false if the name does not exist" do
164
154
  expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(false)
165
155
  end
@@ -181,6 +171,9 @@ describe 'Chef::Win32::Registry', :windows_only do
181
171
  it "returns true if all the data matches" do
182
172
  expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
183
173
  end
174
+ it "returns true if all the data matches with a case mismatch on the data name" do
175
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
176
+ end
184
177
  it "throws an exception if the name does not exist" do
185
178
  expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
186
179
  end
@@ -544,11 +537,11 @@ describe 'Chef::Win32::Registry', :windows_only do
544
537
  end
545
538
 
546
539
  after(:all) do
547
- ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software\\Root", ::Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg|
548
- reg.delete_key("Trunk", true)
540
+ ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software", ::Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg|
541
+ reg.delete_key("Root", true)
549
542
  end
550
- ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software\\Root", ::Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg|
551
- reg.delete_key("Trunk", true)
543
+ ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software", ::Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg|
544
+ reg.delete_key("Root", true)
552
545
  end
553
546
  end
554
547
 
@@ -33,7 +33,7 @@ end
33
33
  # directories.
34
34
  #
35
35
 
36
- describe "Chef::Application::WindowsServiceManager", :windows_only, :system_windows_service_gem_only do
36
+ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_windows_service_gem_only, :appveyor_only do
37
37
 
38
38
  include_context "using Win32::Service"
39
39
 
@@ -43,7 +43,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
43
43
  end
44
44
 
45
45
  it "throws an error with required missing options" do
46
- test_service.each do |key,value|
46
+ [:service_name, :service_display_name, :service_description, :service_file_path].each do |key|
47
47
  service_def = test_service.dup
48
48
  service_def.delete(key)
49
49
 
@@ -303,6 +303,57 @@ EOM
303
303
 
304
304
  end
305
305
 
306
+ when_the_repository "has a cookbook that generates deprecation warnings" do
307
+ before do
308
+ file 'cookbooks/x/recipes/default.rb', <<-EOM
309
+ class ::MyResource < Chef::Resource
310
+ use_automatic_resource_name
311
+ property :x, default: []
312
+ property :y, default: {}
313
+ end
314
+
315
+ my_resource 'blah' do
316
+ 1.upto(10) do
317
+ x nil
318
+ end
319
+ x nil
320
+ end
321
+ EOM
322
+ end
323
+
324
+ def match_indices(regex, str)
325
+ result = []
326
+ pos = 0
327
+ while match = regex.match(str, pos)
328
+ result << match.begin(0)
329
+ pos = match.end(0) + 1
330
+ end
331
+ result
332
+ end
333
+
334
+ it "should output each deprecation warning only once, at the end of the run" do
335
+ file 'config/client.rb', <<EOM
336
+ local_mode true
337
+ cookbook_path "#{path_to('cookbooks')}"
338
+ # Mimick what happens when you are on the console
339
+ formatters << :doc
340
+ log_level :warn
341
+ EOM
342
+
343
+ ENV.delete('CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS')
344
+
345
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
346
+ expect(result.error?).to be_falsey
347
+
348
+ # Search to the end of the client run in the output
349
+ run_complete = result.stdout.index("Running handlers complete")
350
+ expect(run_complete).to be >= 0
351
+
352
+ # Make sure there is exactly one result for each, and that it occurs *after* the complete message.
353
+ expect(match_indices(/nil currently does not overwrite the value of/, result.stdout)).to match([ be > run_complete ])
354
+ end
355
+ end
356
+
306
357
  when_the_repository "has a cookbook with only an audit recipe" do
307
358
 
308
359
  before do
@@ -24,6 +24,8 @@ describe 'chef_repo_path tests', :workstation do
24
24
  include IntegrationSupport
25
25
  include KnifeSupport
26
26
 
27
+ let(:error_rel_path_outside_repo) { /^ERROR: Attempt to use relative path '' when current directory is outside the repository path/ }
28
+
27
29
  # TODO alternate repo_path / *_path
28
30
  context 'alternate *_path' do
29
31
  when_the_repository 'has clients and clients2, cookbooks and cookbooks2, etc.' do
@@ -109,14 +111,14 @@ EOM
109
111
  context 'when cwd is at the top level' do
110
112
  before { cwd '.' }
111
113
  it 'knife list --local -Rfp fails' do
112
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
114
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
113
115
  end
114
116
  end
115
117
 
116
118
  context 'when cwd is inside the data_bags directory' do
117
119
  before { cwd 'data_bags' }
118
120
  it 'knife list --local -Rfp fails' do
119
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
121
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
120
122
  end
121
123
  end
122
124
 
@@ -192,14 +194,14 @@ EOM
192
194
  context 'when cwd is inside the data_bags directory' do
193
195
  before { cwd 'data_bags' }
194
196
  it 'knife list --local -Rfp fails' do
195
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
197
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
196
198
  end
197
199
  end
198
200
 
199
201
  context 'when cwd is inside chef_repo2' do
200
202
  before { cwd 'chef_repo2' }
201
203
  it 'knife list -Rfp fails' do
202
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
204
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
203
205
  end
204
206
  end
205
207
 
@@ -225,14 +227,14 @@ EOM
225
227
  context 'when cwd is at the top level' do
226
228
  before { cwd '.' }
227
229
  it 'knife list --local -Rfp fails' do
228
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
230
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
229
231
  end
230
232
  end
231
233
 
232
234
  context 'when cwd is inside the data_bags directory' do
233
235
  before { cwd 'data_bags' }
234
236
  it 'knife list --local -Rfp fails' do
235
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
237
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
236
238
  end
237
239
  end
238
240
 
@@ -445,7 +447,7 @@ EOM
445
447
  context 'when cwd is at the top level' do
446
448
  before { cwd '.' }
447
449
  it 'knife list --local -Rfp fails' do
448
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
450
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
449
451
  end
450
452
  end
451
453
 
@@ -621,14 +623,14 @@ EOM
621
623
  context 'when cwd is at the top level' do
622
624
  before { cwd '.' }
623
625
  it 'knife list --local -Rfp fails' do
624
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
626
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
625
627
  end
626
628
  end
627
629
 
628
630
  context 'when cwd is inside the data_bags directory' do
629
631
  before { cwd 'data_bags' }
630
632
  it 'knife list --local -Rfp fails' do
631
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
633
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
632
634
  end
633
635
  end
634
636
 
@@ -782,7 +784,7 @@ EOM
782
784
  context 'when cwd is at the top level' do
783
785
  before { cwd '.' }
784
786
  it 'knife list --local -Rfp fails' do
785
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
787
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
786
788
  end
787
789
  end
788
790
 
@@ -823,7 +825,7 @@ EOM
823
825
  context 'when cwd is inside chef_repo2/data_bags' do
824
826
  before { cwd 'chef_repo2/data_bags' }
825
827
  it 'knife list --local -Rfp fails' do
826
- knife('list --local -Rfp').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
828
+ knife('list --local -Rfp').should_fail(error_rel_path_outside_repo)
827
829
  end
828
830
  end
829
831
  end
@@ -1113,11 +1113,13 @@ Created /acls/clients/foo-validator.json
1113
1113
  Created /acls/containers
1114
1114
  Created /acls/containers/clients.json
1115
1115
  Created /acls/containers/containers.json
1116
+ Created /acls/containers/cookbook_artifacts.json
1116
1117
  Created /acls/containers/cookbooks.json
1117
1118
  Created /acls/containers/data.json
1118
1119
  Created /acls/containers/environments.json
1119
1120
  Created /acls/containers/groups.json
1120
1121
  Created /acls/containers/nodes.json
1122
+ Created /acls/containers/policies.json
1121
1123
  Created /acls/containers/roles.json
1122
1124
  Created /acls/containers/sandboxes.json
1123
1125
  Created /acls/containers/x.json
@@ -1139,11 +1141,13 @@ Created /clients/foo-validator.json
1139
1141
  Created /containers
1140
1142
  Created /containers/clients.json
1141
1143
  Created /containers/containers.json
1144
+ Created /containers/cookbook_artifacts.json
1142
1145
  Created /containers/cookbooks.json
1143
1146
  Created /containers/data.json
1144
1147
  Created /containers/environments.json
1145
1148
  Created /containers/groups.json
1146
1149
  Created /containers/nodes.json
1150
+ Created /containers/policies.json
1147
1151
  Created /containers/roles.json
1148
1152
  Created /containers/sandboxes.json
1149
1153
  Created /containers/x.json
@@ -702,11 +702,13 @@ foo-validator.json
702
702
  /acls/containers:
703
703
  clients.json
704
704
  containers.json
705
+ cookbook_artifacts.json
705
706
  cookbooks.json
706
707
  data.json
707
708
  environments.json
708
709
  groups.json
709
710
  nodes.json
711
+ policies.json
710
712
  roles.json
711
713
  sandboxes.json
712
714
 
@@ -733,11 +735,13 @@ foo-validator.json
733
735
  /containers:
734
736
  clients.json
735
737
  containers.json
738
+ cookbook_artifacts.json
736
739
  cookbooks.json
737
740
  data.json
738
741
  environments.json
739
742
  groups.json
740
743
  nodes.json
744
+ policies.json
741
745
  roles.json
742
746
  sandboxes.json
743
747
 
@@ -804,11 +808,13 @@ foo-validator.json
804
808
  /acls/containers:
805
809
  clients.json
806
810
  containers.json
811
+ cookbook_artifacts.json
807
812
  cookbooks.json
808
813
  data.json
809
814
  environments.json
810
815
  groups.json
811
816
  nodes.json
817
+ policies.json
812
818
  roles.json
813
819
  sandboxes.json
814
820
 
@@ -835,11 +841,13 @@ foo-validator.json
835
841
  /containers:
836
842
  clients.json
837
843
  containers.json
844
+ cookbook_artifacts.json
838
845
  cookbooks.json
839
846
  data.json
840
847
  environments.json
841
848
  groups.json
842
849
  nodes.json
850
+ policies.json
843
851
  roles.json
844
852
  sandboxes.json
845
853
 
@@ -198,7 +198,7 @@ Created /nodes/y.json
198
198
  Created /roles/y.json
199
199
  Created /users/y.json
200
200
  EOM
201
- knife('diff --name-status /').should_succeed ''
201
+ knife('diff /').should_succeed ''
202
202
  end
203
203
 
204
204
  it 'knife upload --no-diff adds the new files' do
@@ -119,7 +119,7 @@ describe "Recipe DSL methods" do
119
119
  recipe = converge {
120
120
  backcompat_thingy 'blah' do; end
121
121
  }
122
- expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'resource_name :backcompat_thingy'./)
122
+ expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'provides :backcompat_thingy'./)
123
123
  expect(BaseThingy.created_resource).not_to be_nil
124
124
  end
125
125
  end
@@ -794,21 +794,6 @@ describe "Recipe DSL methods" do
794
794
  end
795
795
  end
796
796
 
797
- context "when Thingy9 provides :thingy9" do
798
- before(:context) {
799
- class RecipeDSLSpecNamespace::Thingy9 < BaseThingy
800
- resource_name :thingy9
801
- end
802
- }
803
-
804
- it "declaring a resource providing the same :thingy9 produces a warning" do
805
- expect(Chef::Log).to receive(:warn).with("You declared a new resource RecipeDSLSpecNamespace::Thingy9AlternateProvider for resource thingy9, but it comes alphabetically after RecipeDSLSpecNamespace::Thingy9 and has the same filters ({}), so it will not be used. Use override: true if you want to use it for thingy9.")
806
- class RecipeDSLSpecNamespace::Thingy9AlternateProvider < BaseThingy
807
- resource_name :thingy9
808
- end
809
- end
810
- end
811
-
812
797
  context "when Thingy10 provides :thingy10" do
813
798
  before(:context) {
814
799
  class RecipeDSLSpecNamespace::Thingy10 < BaseThingy
@@ -0,0 +1,74 @@
1
+ require 'support/shared/integration/integration_helper'
2
+
3
+ describe Chef::Resource::RemoteDirectory do
4
+ include IntegrationSupport
5
+ include Chef::Mixin::ShellOut
6
+
7
+ # Until Cheffish::RSpec has cookbook support, we have to run the whole client
8
+ let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
9
+
10
+ # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
11
+ # following constraints are satisfied:
12
+ # * Windows: windows can only run batch scripts as bare executables. Rubygems
13
+ # creates batch wrappers for installed gems, but we don't have batch wrappers
14
+ # in the source tree.
15
+ # * Other `chef-client` in PATH: A common case is running the tests on a
16
+ # machine that has omnibus chef installed. In that case we need to ensure
17
+ # we're running `chef-client` from the source tree and not the external one.
18
+ # cf. CHEF-4914
19
+ let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
20
+
21
+ when_the_repository "has a cookbook with a source_dir with two subdirectories, each with one file and subdir in a different alphabetical order" do
22
+ before do
23
+ file 'config/client.rb', <<-EOM
24
+ local_mode true
25
+ cookbook_path "#{path_to('cookbooks')}"
26
+ EOM
27
+ directory "cookbooks/test" do
28
+ directory "files/default/source_dir" do
29
+ directory "sub1" do
30
+ file "aaa", ""
31
+ file "zzz/file", ""
32
+ end
33
+ directory "sub2" do
34
+ file "aaa/file", ""
35
+ file "zzz", ""
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ context "and a recipe is run with a remote_directory that syncs source_dir with different mode and file_mode" do
42
+ let!(:dest_dir) { path_to("dest_dir") }
43
+ before do
44
+ directory "cookbooks/test" do
45
+ file "recipes/default.rb", <<-EOM
46
+ remote_directory #{dest_dir.inspect} do
47
+ source "source_dir"
48
+ mode "0754"
49
+ files_mode 0777
50
+ end
51
+ EOM
52
+ end
53
+ shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", :cwd => chef_dir)
54
+ end
55
+
56
+ def mode_of(path)
57
+ path = path_to(path)
58
+ stat = File.stat(path)
59
+ (stat.mode & 0777).to_s(8)
60
+ end
61
+
62
+ it "creates all directories and files with the correct permissions" do
63
+ expect(mode_of("dest_dir/sub1")).to eq "754"
64
+ expect(mode_of("dest_dir/sub1/aaa")).to eq "777"
65
+ expect(mode_of("dest_dir/sub1/zzz")).to eq "754"
66
+ expect(mode_of("dest_dir/sub1/zzz/file")).to eq "777"
67
+ expect(mode_of("dest_dir/sub2")).to eq "754"
68
+ expect(mode_of("dest_dir/sub2/aaa")).to eq "754"
69
+ expect(mode_of("dest_dir/sub2/aaa/file")).to eq "777"
70
+ expect(mode_of("dest_dir/sub2/zzz")).to eq "777"
71
+ end
72
+ end
73
+ end
74
+ end