chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +10 -0
  3. data/README.md +1 -1
  4. data/distro/common/html/_sources/index.txt +5 -2
  5. data/distro/common/html/_sources/knife_serve.txt +19 -0
  6. data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
  7. data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
  8. data/distro/common/html/_static/basic.css +1 -1
  9. data/distro/common/html/_static/doctools.js +1 -1
  10. data/distro/common/html/_static/searchtools.js +1 -1
  11. data/distro/common/html/_static/websupport.js +1 -1
  12. data/distro/common/html/ctl_chef_client.html +19 -9
  13. data/distro/common/html/ctl_chef_server.html +7 -1
  14. data/distro/common/html/ctl_chef_shell.html +3 -4
  15. data/distro/common/html/ctl_chef_solo.html +12 -7
  16. data/distro/common/html/index.html +19 -12
  17. data/distro/common/html/knife.html +1 -2
  18. data/distro/common/html/knife_bootstrap.html +16 -5
  19. data/distro/common/html/knife_client.html +8 -5
  20. data/distro/common/html/knife_common_options.html +11 -12
  21. data/distro/common/html/knife_configure.html +2 -3
  22. data/distro/common/html/knife_cookbook.html +16 -17
  23. data/distro/common/html/knife_cookbook_site.html +19 -18
  24. data/distro/common/html/knife_data_bag.html +6 -7
  25. data/distro/common/html/knife_delete.html +2 -3
  26. data/distro/common/html/knife_deps.html +2 -3
  27. data/distro/common/html/knife_diff.html +3 -4
  28. data/distro/common/html/knife_download.html +6 -7
  29. data/distro/common/html/knife_edit.html +0 -1
  30. data/distro/common/html/knife_environment.html +3 -4
  31. data/distro/common/html/knife_exec.html +0 -1
  32. data/distro/common/html/knife_index_rebuild.html +0 -1
  33. data/distro/common/html/knife_list.html +5 -6
  34. data/distro/common/html/knife_node.html +13 -6
  35. data/distro/common/html/knife_raw.html +0 -1
  36. data/distro/common/html/knife_recipe_list.html +0 -1
  37. data/distro/common/html/knife_role.html +1 -2
  38. data/distro/common/html/knife_search.html +2 -3
  39. data/distro/common/html/knife_serve.html +79 -0
  40. data/distro/common/html/knife_show.html +1 -2
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +12 -9
  43. data/distro/common/html/knife_ssl_fetch.html +9 -10
  44. data/distro/common/html/knife_status.html +2 -3
  45. data/distro/common/html/knife_tag.html +0 -1
  46. data/distro/common/html/knife_upload.html +3 -4
  47. data/distro/common/html/knife_user.html +2 -3
  48. data/distro/common/html/knife_using.html +0 -1
  49. data/distro/common/html/knife_xargs.html +3 -4
  50. data/distro/common/html/search.html +0 -1
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/lib/chef/api_client.rb +1 -1
  53. data/lib/chef/application.rb +24 -67
  54. data/lib/chef/application/client.rb +1 -1
  55. data/lib/chef/application/knife.rb +1 -1
  56. data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
  57. data/lib/chef/chef_fs/command_line.rb +2 -3
  58. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
  59. data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
  60. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
  61. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
  62. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
  63. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
  64. data/lib/chef/config.rb +26 -2
  65. data/lib/chef/config_fetcher.rb +1 -1
  66. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  67. data/lib/chef/cookbook/metadata.rb +1 -1
  68. data/lib/chef/cookbook/synchronizer.rb +50 -8
  69. data/lib/chef/cookbook_uploader.rb +9 -23
  70. data/lib/chef/cookbook_version.rb +3 -2
  71. data/lib/chef/data_bag.rb +1 -1
  72. data/lib/chef/data_bag_item.rb +1 -1
  73. data/lib/chef/dsl/recipe.rb +1 -14
  74. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  75. data/lib/chef/environment.rb +1 -1
  76. data/lib/chef/exceptions.rb +2 -24
  77. data/lib/chef/file_content_management/tempfile.rb +8 -1
  78. data/lib/chef/formatters/base.rb +0 -7
  79. data/lib/chef/http.rb +12 -19
  80. data/lib/chef/http/json_input.rb +12 -1
  81. data/lib/chef/json_compat.rb +45 -64
  82. data/lib/chef/knife.rb +2 -5
  83. data/lib/chef/knife/bootstrap.rb +2 -2
  84. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  85. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  86. data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
  87. data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
  88. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
  89. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  90. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
  91. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
  92. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  93. data/lib/chef/knife/cookbook_site_install.rb +10 -34
  94. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  95. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  96. data/lib/chef/knife/cookbook_site_share.rb +3 -3
  97. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  98. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  99. data/lib/chef/knife/cookbook_upload.rb +1 -1
  100. data/lib/chef/knife/core/subcommand_loader.rb +0 -24
  101. data/lib/chef/knife/core/ui.rb +8 -7
  102. data/lib/chef/knife/deps.rb +2 -3
  103. data/lib/chef/knife/serve.rb +2 -1
  104. data/lib/chef/local_mode.rb +105 -0
  105. data/lib/chef/mixin/file_class.rb +1 -4
  106. data/lib/chef/mixin/shell_out.rb +15 -0
  107. data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
  108. data/lib/chef/node.rb +1 -1
  109. data/lib/chef/platform/query_helpers.rb +1 -5
  110. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  111. data/lib/chef/provider.rb +2 -0
  112. data/lib/chef/provider/cookbook_file.rb +0 -1
  113. data/lib/chef/provider/deploy.rb +0 -1
  114. data/lib/chef/provider/deploy/revision.rb +1 -1
  115. data/lib/chef/provider/env.rb +10 -25
  116. data/lib/chef/provider/env/windows.rb +23 -10
  117. data/lib/chef/provider/execute.rb +0 -3
  118. data/lib/chef/provider/file.rb +0 -3
  119. data/lib/chef/provider/git.rb +0 -6
  120. data/lib/chef/provider/group/dscl.rb +9 -27
  121. data/lib/chef/provider/group/gpasswd.rb +0 -3
  122. data/lib/chef/provider/group/groupmod.rb +0 -4
  123. data/lib/chef/provider/group/suse.rb +0 -3
  124. data/lib/chef/provider/group/usermod.rb +0 -3
  125. data/lib/chef/provider/link.rb +22 -5
  126. data/lib/chef/provider/log.rb +15 -4
  127. data/lib/chef/provider/mdadm.rb +0 -3
  128. data/lib/chef/provider/mount/mount.rb +0 -2
  129. data/lib/chef/provider/mount/solaris.rb +0 -2
  130. data/lib/chef/provider/package.rb +0 -1
  131. data/lib/chef/provider/package/apt.rb +0 -3
  132. data/lib/chef/provider/package/dpkg.rb +0 -1
  133. data/lib/chef/provider/package/easy_install.rb +0 -4
  134. data/lib/chef/provider/package/freebsd/base.rb +0 -3
  135. data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
  136. data/lib/chef/provider/package/freebsd/port.rb +0 -2
  137. data/lib/chef/provider/package/ips.rb +0 -3
  138. data/lib/chef/provider/package/paludis.rb +0 -5
  139. data/lib/chef/provider/package/portage.rb +0 -2
  140. data/lib/chef/provider/package/rpm.rb +2 -4
  141. data/lib/chef/provider/package/rubygems.rb +0 -4
  142. data/lib/chef/provider/package/smartos.rb +0 -3
  143. data/lib/chef/provider/package/windows/msi.rb +0 -2
  144. data/lib/chef/provider/package/yum.rb +0 -4
  145. data/lib/chef/provider/package/zypper.rb +0 -3
  146. data/lib/chef/provider/registry_key.rb +0 -2
  147. data/lib/chef/provider/remote_directory.rb +0 -1
  148. data/lib/chef/provider/remote_file.rb +0 -1
  149. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
  150. data/lib/chef/provider/remote_file/content.rb +0 -1
  151. data/lib/chef/provider/remote_file/fetcher.rb +0 -2
  152. data/lib/chef/provider/remote_file/ftp.rb +0 -1
  153. data/lib/chef/provider/resource_update.rb +0 -3
  154. data/lib/chef/provider/service/freebsd.rb +0 -3
  155. data/lib/chef/provider/service/init.rb +0 -3
  156. data/lib/chef/provider/service/macosx.rb +0 -1
  157. data/lib/chef/provider/service/redhat.rb +0 -2
  158. data/lib/chef/provider/service/simple.rb +0 -3
  159. data/lib/chef/provider/service/solaris.rb +0 -3
  160. data/lib/chef/provider/service/systemd.rb +15 -14
  161. data/lib/chef/provider/service/windows.rb +0 -3
  162. data/lib/chef/provider/subversion.rb +0 -2
  163. data/lib/chef/provider/template.rb +0 -2
  164. data/lib/chef/provider/template/content.rb +0 -1
  165. data/lib/chef/provider/user/dscl.rb +156 -549
  166. data/lib/chef/provider/user/solaris.rb +0 -1
  167. data/lib/chef/provider/user/useradd.rb +0 -3
  168. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  169. data/lib/chef/providers.rb +0 -1
  170. data/lib/chef/resource.rb +1 -4
  171. data/lib/chef/resource/freebsd_package.rb +2 -10
  172. data/lib/chef/resource/lwrp_base.rb +1 -12
  173. data/lib/chef/resource/user.rb +0 -18
  174. data/lib/chef/resource_collection.rb +1 -1
  175. data/lib/chef/resource_reporter.rb +10 -10
  176. data/lib/chef/resources.rb +0 -1
  177. data/lib/chef/role.rb +3 -3
  178. data/lib/chef/run_list.rb +1 -1
  179. data/lib/chef/tasks/chef_repo.rake +131 -264
  180. data/lib/chef/user.rb +1 -1
  181. data/lib/chef/util/path_helper.rb +2 -2
  182. data/lib/chef/version.rb +9 -1
  183. data/lib/chef/win32/api/system.rb +0 -9
  184. data/spec/data/bootstrap/test-hints.erb +1 -1
  185. data/spec/data/bootstrap/test.erb +1 -1
  186. data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
  187. data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
  188. data/spec/functional/knife/exec_spec.rb +1 -1
  189. data/spec/functional/mixin/shell_out_spec.rb +48 -0
  190. data/spec/functional/resource/base.rb +0 -10
  191. data/spec/functional/resource/group_spec.rb +1 -5
  192. data/spec/functional/resource/link_spec.rb +8 -0
  193. data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
  194. data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
  195. data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
  196. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
  197. data/spec/integration/knife/chefignore_spec.rb +1 -1
  198. data/spec/integration/knife/common_options_spec.rb +50 -3
  199. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
  200. data/spec/integration/knife/delete_spec.rb +1 -1
  201. data/spec/integration/knife/deps_spec.rb +1 -1
  202. data/spec/integration/knife/diff_spec.rb +3 -3
  203. data/spec/integration/knife/download_spec.rb +3 -3
  204. data/spec/integration/knife/list_spec.rb +1 -1
  205. data/spec/integration/knife/raw_spec.rb +1 -11
  206. data/spec/integration/knife/redirection_spec.rb +1 -1
  207. data/spec/integration/knife/serve_spec.rb +2 -2
  208. data/spec/integration/knife/show_spec.rb +1 -1
  209. data/spec/integration/knife/upload_spec.rb +9 -9
  210. data/spec/spec_helper.rb +0 -9
  211. data/spec/support/pedant/pedant_config.rb +2 -1
  212. data/spec/support/pedant/run_pedant.rb +2 -1
  213. data/spec/support/platform_helpers.rb +5 -24
  214. data/spec/support/shared/integration/integration_helper.rb +2 -1
  215. data/spec/support/shared/matchers.rb +17 -0
  216. data/spec/tiny_server.rb +1 -2
  217. data/spec/unit/api_client_spec.rb +3 -3
  218. data/spec/unit/application_spec.rb +9 -32
  219. data/spec/unit/config_fetcher_spec.rb +1 -1
  220. data/spec/unit/cookbook/metadata_spec.rb +3 -7
  221. data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
  222. data/spec/unit/cookbook_loader_spec.rb +1 -1
  223. data/spec/unit/cookbook_uploader_spec.rb +160 -0
  224. data/spec/unit/cookbook_version_spec.rb +0 -4
  225. data/spec/unit/data_bag_item_spec.rb +1 -5
  226. data/spec/unit/data_bag_spec.rb +1 -5
  227. data/spec/unit/deprecation_spec.rb +1 -1
  228. data/spec/unit/dsl/recipe_spec.rb +12 -0
  229. data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
  230. data/spec/unit/environment_spec.rb +3 -7
  231. data/spec/unit/exceptions_spec.rb +0 -6
  232. data/spec/unit/http/json_input_spec.rb +128 -0
  233. data/spec/unit/json_compat_spec.rb +17 -58
  234. data/spec/unit/knife/client_create_spec.rb +3 -3
  235. data/spec/unit/knife/configure_client_spec.rb +6 -5
  236. data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
  237. data/spec/unit/knife/cookbook_download_spec.rb +5 -5
  238. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
  239. data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
  240. data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
  241. data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
  242. data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
  243. data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
  244. data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
  245. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
  246. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
  247. data/spec/unit/knife/tag_create_spec.rb +3 -3
  248. data/spec/unit/knife/tag_delete_spec.rb +3 -3
  249. data/spec/unit/knife/user_create_spec.rb +1 -1
  250. data/spec/unit/knife_spec.rb +14 -14
  251. data/spec/unit/lwrp_spec.rb +1 -21
  252. data/spec/unit/mixin/shell_out_spec.rb +92 -0
  253. data/spec/unit/node_spec.rb +0 -4
  254. data/spec/unit/platform/query_helpers_spec.rb +0 -23
  255. data/spec/unit/provider/env/windows_spec.rb +34 -70
  256. data/spec/unit/provider/env_spec.rb +11 -76
  257. data/spec/unit/provider/group/dscl_spec.rb +1 -38
  258. data/spec/unit/provider/log_spec.rb +18 -0
  259. data/spec/unit/provider/package/rpm_spec.rb +0 -12
  260. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
  261. data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
  262. data/spec/unit/provider/user/dscl_spec.rb +264 -660
  263. data/spec/unit/provider/user/useradd_spec.rb +0 -1
  264. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  265. data/spec/unit/provider_spec.rb +12 -0
  266. data/spec/unit/recipe_spec.rb +0 -41
  267. data/spec/unit/resource_collection_spec.rb +1 -5
  268. data/spec/unit/resource_reporter_spec.rb +3 -51
  269. data/spec/unit/resource_spec.rb +3 -14
  270. data/spec/unit/rest_spec.rb +1 -4
  271. data/spec/unit/role_spec.rb +0 -10
  272. data/spec/unit/run_list_spec.rb +1 -5
  273. data/spec/unit/user_spec.rb +1 -5
  274. metadata +20 -100
  275. data/lib/chef/mixin/windows_env_helper.rb +0 -56
  276. data/lib/chef/provider/dsc_script.rb +0 -175
  277. data/lib/chef/resource/dsc_script.rb +0 -126
  278. data/lib/chef/streaming_cookbook_uploader.rb +0 -205
  279. data/lib/chef/util/dsc/configuration_generator.rb +0 -115
  280. data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
  281. data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
  282. data/lib/chef/util/dsc/resource_info.rb +0 -26
  283. data/lib/chef/util/powershell/cmdlet.rb +0 -136
  284. data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
  285. data/spec/data/mac_users/10.7-8.plist.xml +0 -559
  286. data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
  287. data/spec/data/mac_users/10.7.plist.xml +0 -559
  288. data/spec/data/mac_users/10.7.shadow.xml +0 -11
  289. data/spec/data/mac_users/10.8.plist.xml +0 -559
  290. data/spec/data/mac_users/10.8.shadow.xml +0 -21
  291. data/spec/data/mac_users/10.9.plist.xml +0 -560
  292. data/spec/data/mac_users/10.9.shadow.xml +0 -21
  293. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
  294. data/spec/functional/resource/dsc_script_spec.rb +0 -382
  295. data/spec/functional/resource/env_spec.rb +0 -182
  296. data/spec/functional/resource/user/dscl_spec.rb +0 -199
  297. data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
  298. data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
  299. data/spec/support/shared/shared_examples.rb +0 -10
  300. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
  301. data/spec/unit/formatters/base_spec.rb +0 -48
  302. data/spec/unit/provider/dsc_script_spec.rb +0 -174
  303. data/spec/unit/resource/dsc_script_spec.rb +0 -98
  304. data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
  305. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
  306. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
  307. data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -34,7 +34,7 @@ describe Chef::Knife::CookbookSiteShare do
34
34
  @cookbook_loader.stub(:[]).and_return(@cookbook)
35
35
  Chef::CookbookLoader.stub(:new).and_return(@cookbook_loader)
36
36
 
37
- @cookbook_uploader = Chef::CookbookUploader.new('herpderp', File.join(CHEF_SPEC_DATA, 'cookbooks'), :rest => "norest")
37
+ @cookbook_uploader = Chef::CookbookUploader.new('herpderp', :rest => "norest")
38
38
  Chef::CookbookUploader.stub(:new).and_return(@cookbook_uploader)
39
39
  @cookbook_uploader.stub(:validate_cookbooks).and_return(true)
40
40
  Chef::CookbookSiteStreamingUploader.stub(:create_build_dir).and_return(Dir.mktmpdir)
@@ -77,7 +77,7 @@ describe Chef::Knife::CookbookSiteShare do
77
77
 
78
78
  it 'should make a tarball of the cookbook' do
79
79
  @knife.should_receive(:shell_out!) do |args|
80
- args.to_s.should match /tar -czf/
80
+ args.to_s.should match(/tar -czf/)
81
81
  end
82
82
  @knife.run
83
83
  end
@@ -108,16 +108,16 @@ describe Chef::Knife::CookbookSiteShare do
108
108
  File.stub(:open).and_return(true)
109
109
  end
110
110
 
111
- it 'should post the cookbook to "https://supermarket.getchef.com"' do
112
- response_text = {:uri => 'https://supermarket.getchef.com/cookbooks/cookbook_name'}.to_json
111
+ it 'should post the cookbook to "http://cookbooks.opscode.com"' do
112
+ response_text = {:uri => 'http://cookbooks.opscode.com/cookbooks/cookbook_name'}.to_json
113
113
  @upload_response.stub(:body).and_return(response_text)
114
114
  @upload_response.stub(:code).and_return(201)
115
- Chef::CookbookSiteStreamingUploader.should_receive(:post).with(/supermarket\.getchef\.com/, anything(), anything(), anything())
115
+ Chef::CookbookSiteStreamingUploader.should_receive(:post).with(/cookbooks\.opscode\.com/, anything(), anything(), anything())
116
116
  @knife.run
117
117
  end
118
118
 
119
119
  it 'should alert the user when a version already exists' do
120
- response_text = Chef::JSONCompat.to_json({:error_messages => ['Version already exists']})
120
+ response_text = {:error_messages => ['Version already exists']}.to_json
121
121
  @upload_response.stub(:body).and_return(response_text)
122
122
  @upload_response.stub(:code).and_return(409)
123
123
  lambda { @knife.run }.should raise_error(SystemExit)
@@ -125,7 +125,7 @@ describe Chef::Knife::CookbookSiteShare do
125
125
  end
126
126
 
127
127
  it 'should pass any errors on to the user' do
128
- response_text = Chef::JSONCompat.to_json({:error_messages => ["You're holding it wrong"]})
128
+ response_text = {:error_messages => ["You're holding it wrong"]}.to_json
129
129
  @upload_response.stub(:body).and_return(response_text)
130
130
  @upload_response.stub(:code).and_return(403)
131
131
  lambda { @knife.run }.should raise_error(SystemExit)
@@ -133,7 +133,7 @@ describe Chef::Knife::CookbookSiteShare do
133
133
  end
134
134
 
135
135
  it 'should print the body if no errors are exposed on failure' do
136
- response_text = Chef::JSONCompat.to_json({:system_error => "Your call was dropped", :reason => "There's a map for that"})
136
+ response_text = {:system_error => "Your call was dropped", :reason => "There's a map for that"}.to_json
137
137
  @upload_response.stub(:body).and_return(response_text)
138
138
  @upload_response.stub(:code).and_return(500)
139
139
  @knife.ui.should_receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered
@@ -61,8 +61,9 @@ describe Chef::Knife::CookbookUpload do
61
61
  test_cookbook = Chef::CookbookVersion.new('test_cookbook', '/tmp/blah')
62
62
  cookbook_loader.stub(:each).and_yield("test_cookbook", test_cookbook)
63
63
  cookbook_loader.stub(:cookbook_names).and_return(["test_cookbook"])
64
- Chef::CookbookUploader.should_receive(:new).with( kind_of(Array), kind_of(Array),
65
- {:force=>nil, :concurrency => 3}).and_return(double("Chef::CookbookUploader", :upload_cookbooks=> true))
64
+ Chef::CookbookUploader.should_receive(:new).
65
+ with( kind_of(Array), { :force => nil, :concurrency => 3}).
66
+ and_return(double("Chef::CookbookUploader", :upload_cookbooks=> true))
66
67
  knife.run
67
68
  end
68
69
  end
@@ -116,13 +116,13 @@ EXPECTED
116
116
  describe "when JSON attributes are given" do
117
117
  let(:config) { {:first_boot_attributes => {:baz => :quux}} }
118
118
  it "adds the attributes to first_boot" do
119
- Chef::JSONCompat.to_json(bootstrap_context.first_boot).should eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list}))
119
+ bootstrap_context.first_boot.to_json.should eq({:baz => :quux, :run_list => run_list}.to_json)
120
120
  end
121
121
  end
122
122
 
123
123
  describe "when JSON attributes are NOT given" do
124
124
  it "sets first_boot equal to run_list" do
125
- Chef::JSONCompat.to_json(bootstrap_context.first_boot).should eq(Chef::JSONCompat.to_json({:run_list => run_list}))
125
+ bootstrap_context.first_boot.to_json.should eq({:run_list => run_list}.to_json)
126
126
  end
127
127
  end
128
128
 
@@ -194,7 +194,7 @@ EXPECTED
194
194
  describe "when a bootstrap_version is not specified" do
195
195
  it "should send the latest current to the installer" do
196
196
  # Intentionally hard coded in order not to replicate the logic.
197
- bootstrap_context.latest_current_chef_version_string.should eq("-v 11")
197
+ bootstrap_context.latest_current_chef_version_string.should eq("-v #{Chef::VERSION.to_i}")
198
198
  end
199
199
  end
200
200
  end
@@ -73,72 +73,7 @@ describe Chef::Knife::SubcommandLoader do
73
73
  @loader.site_subcommands.should include(expected_command)
74
74
  end
75
75
 
76
- # https://github.com/opscode/chef-dk/issues/227
77
- #
78
- # `knife` in ChefDK isn't from a gem install, it's directly run from a clone
79
- # of the source, but there can be one or more versions of chef also installed
80
- # as a gem. If the gem install contains a command that doesn't exist in the
81
- # source tree of the "primary" chef install, it can be loaded and cause an
82
- # error. We also want to ensure that we only load builtin commands from the
83
- # "primary" chef install.
84
- context "when a different version of chef is also installed as a gem" do
85
-
86
- let(:all_found_commands) do
87
- [
88
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/bootstrap.rb",
89
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_bulk_delete.rb",
90
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_create.rb",
91
- # We use the fake version 1.0.0 because that version doesn't exist,
92
- # which ensures it won't ever equal "chef-#{Chef::VERSION}"
93
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/bootstrap.rb",
94
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/client_bulk_delete.rb",
95
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/client_create.rb",
96
- # This command is "extra" compared to what's in the embedded/apps/chef install:
97
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/data_bag_secret_options.rb",
98
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-vault-2.2.4/lib/chef/knife/decrypt.rb",
99
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-spork-1.4.1/lib/chef/knife/spork-bump.rb",
100
- # These are fake commands that have names designed to test that the
101
- # regex is strict enough
102
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-foo-#{Chef::VERSION}/lib/chef/knife/chef-foo.rb",
103
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/foo-chef-#{Chef::VERSION}/lib/chef/knife/foo-chef.rb",
104
- # In a real scenario, we'd use rubygems APIs to only select the most
105
- # recent gem, but for this test we want to check that we're doing the
106
- # right thing both when the plugin version matches and does not match
107
- # the current chef version. Looking at
108
- # `SubcommandLoader::MATCHES_THIS_CHEF_GEM` and
109
- # `SubcommandLoader::MATCHES_CHEF_GEM` should make it clear why we want
110
- # to test these two cases.
111
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-bar-1.0.0/lib/chef/knife/chef-bar.rb",
112
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/bar-chef-1.0.0/lib/chef/knife/bar-chef.rb"
113
- ]
114
- end
115
-
116
- let(:expected_valid_commands) do
117
- [
118
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/bootstrap.rb",
119
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_bulk_delete.rb",
120
- "/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_create.rb",
121
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-vault-2.2.4/lib/chef/knife/decrypt.rb",
122
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-spork-1.4.1/lib/chef/knife/spork-bump.rb",
123
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-foo-#{Chef::VERSION}/lib/chef/knife/chef-foo.rb",
124
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/foo-chef-#{Chef::VERSION}/lib/chef/knife/foo-chef.rb",
125
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-bar-1.0.0/lib/chef/knife/chef-bar.rb",
126
- "/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/bar-chef-1.0.0/lib/chef/knife/bar-chef.rb"
127
- ]
128
- end
129
-
130
- before do
131
- expect(@loader).to receive(:find_files_latest_gems).with("chef/knife/*.rb").and_return(all_found_commands)
132
- expect(@loader).to receive(:find_subcommands_via_dirglob).and_return({})
133
- end
134
-
135
- it "ignores commands from the non-matching gem install" do
136
- expect(@loader.find_subcommands_via_rubygems.values).to eq(expected_valid_commands)
137
- end
138
-
139
- end
140
-
141
- describe "finding 3rd party plugins" do
76
+ describe "finding 3rd party plugins" do
142
77
  let(:env_home) { "/home/alice" }
143
78
  let(:manifest_path) { env_home + "/.chef/plugin_manifest.json" }
144
79
 
@@ -21,6 +21,7 @@ require 'spec_helper'
21
21
  require 'chef/data_bag_item'
22
22
  require 'chef/encrypted_data_bag_item'
23
23
  require 'tempfile'
24
+ require 'json'
24
25
 
25
26
  Chef::Knife::DataBagFromFile.load_deps
26
27
 
@@ -45,7 +46,7 @@ describe Chef::Knife::DataBagFromFile do
45
46
  "greeting" => "hello",
46
47
  "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true }}
47
48
  }
48
- @db_file.write(Chef::JSONCompat.to_json(@plain_data))
49
+ @db_file.write(@plain_data.to_json)
49
50
  @db_file.flush
50
51
  @knife.instance_variable_set(:@name_args, ['bag_name', @db_file.path])
51
52
  end
@@ -9,15 +9,15 @@ describe Chef::Knife::TagCreate do
9
9
  @node = Chef::Node.new
10
10
  @node.stub :save
11
11
  Chef::Node.stub(:load).and_return @node
12
- @stdout = StringIO.new
13
- @knife.ui.stub(:stdout).and_return(@stdout)
12
+ @stderr = StringIO.new
13
+ @knife.ui.stub(:stderr).and_return(@stderr)
14
14
  end
15
15
 
16
16
  describe "run" do
17
17
  it "can create tags on a node" do
18
18
  @knife.run
19
19
  @node.tags.should == ["happytag"]
20
- @stdout.string.should match /created tags happytag.+node webmonkey.example.com/i
20
+ @stderr.string.should match /created tags happytag.+node webmonkey.example.com/i
21
21
  end
22
22
  end
23
23
  end
@@ -10,8 +10,8 @@ describe Chef::Knife::TagDelete do
10
10
  @node.stub :save
11
11
  @node.tags << "sadtag" << "happytag"
12
12
  Chef::Node.stub(:load).and_return @node
13
- @stdout = StringIO.new
14
- @knife.ui.stub(:stdout).and_return(@stdout)
13
+ @stderr = StringIO.new
14
+ @knife.ui.stub(:stderr).and_return(@stderr)
15
15
  end
16
16
 
17
17
  describe "run" do
@@ -19,7 +19,7 @@ describe Chef::Knife::TagDelete do
19
19
  @node.tags.should == ["sadtag", "happytag"]
20
20
  @knife.run
21
21
  @node.tags.should == ["happytag"]
22
- @stdout.string.should match /deleted.+sadtag/i
22
+ @stderr.string.should match /deleted.+sadtag/i
23
23
  end
24
24
  end
25
25
  end
@@ -46,7 +46,7 @@ describe Chef::Knife::UserCreate do
46
46
  Chef::User.should_receive(:new).and_return(@user)
47
47
  @user.should_receive(:create)
48
48
  @knife.run
49
- @stdout.string.should match /created user.+a_user/i
49
+ @stderr.string.should match /created user.+a_user/i
50
50
  end
51
51
 
52
52
  it "sets the password" do
@@ -41,7 +41,7 @@ describe Chef::Knife do
41
41
  Chef::Log.stub(level_sym)
42
42
  end
43
43
  Chef::Knife.stub(:puts)
44
- @stdout = StringIO.new
44
+ @stderr = StringIO.new
45
45
  end
46
46
 
47
47
  describe "selecting a config file" do
@@ -241,7 +241,7 @@ describe Chef::Knife do
241
241
  end
242
242
 
243
243
  it "exits if no subcommand matches the CLI args" do
244
- Chef::Knife.ui.stub(:stdout).and_return(@stdout)
244
+ Chef::Knife.ui.stub(:stderr).and_return(@stderr)
245
245
  Chef::Knife.ui.should_receive(:fatal)
246
246
  lambda {Chef::Knife.run(%w{fuuu uuuu fuuuu})}.should raise_error(SystemExit) { |e| e.status.should_not == 0 }
247
247
  end
@@ -326,7 +326,7 @@ describe Chef::Knife do
326
326
  @knife.stub(:run).and_raise(Net::HTTPServerException.new("401 Unauthorized", response))
327
327
  @knife.run_with_pretty_exceptions
328
328
  @stderr.string.should match(/ERROR: Failed to authenticate to/)
329
- @stdout.string.should match(/Response: y u no syncronize your clock\?/)
329
+ @stderr.string.should match(/Response: y u no syncronize your clock\?/)
330
330
  end
331
331
 
332
332
  it "formats 403s nicely" do
@@ -337,7 +337,7 @@ describe Chef::Knife do
337
337
  @knife.stub(:username).and_return("sadpanda")
338
338
  @knife.run_with_pretty_exceptions
339
339
  @stderr.string.should match(%r[ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action])
340
- @stdout.string.should match(%r[Response: y u no administrator])
340
+ @stderr.string.should match(%r[Response: y u no administrator])
341
341
  end
342
342
 
343
343
  it "formats 400s nicely" do
@@ -347,7 +347,7 @@ describe Chef::Knife do
347
347
  @knife.stub(:run).and_raise(Net::HTTPServerException.new("400 Bad Request", response))
348
348
  @knife.run_with_pretty_exceptions
349
349
  @stderr.string.should match(%r[ERROR: The data in your request was invalid])
350
- @stdout.string.should match(%r[Response: y u search wrong])
350
+ @stderr.string.should match(%r[Response: y u search wrong])
351
351
  end
352
352
 
353
353
  it "formats 404s nicely" do
@@ -357,7 +357,7 @@ describe Chef::Knife do
357
357
  @knife.stub(:run).and_raise(Net::HTTPServerException.new("404 Not Found", response))
358
358
  @knife.run_with_pretty_exceptions
359
359
  @stderr.string.should match(%r[ERROR: The object you are looking for could not be found])
360
- @stdout.string.should match(%r[Response: nothing to see here])
360
+ @stderr.string.should match(%r[Response: nothing to see here])
361
361
  end
362
362
 
363
363
  it "formats 500s nicely" do
@@ -367,7 +367,7 @@ describe Chef::Knife do
367
367
  @knife.stub(:run).and_raise(Net::HTTPFatalError.new("500 Internal Server Error", response))
368
368
  @knife.run_with_pretty_exceptions
369
369
  @stderr.string.should match(%r[ERROR: internal server error])
370
- @stdout.string.should match(%r[Response: sad trombone])
370
+ @stderr.string.should match(%r[Response: sad trombone])
371
371
  end
372
372
 
373
373
  it "formats 502s nicely" do
@@ -377,7 +377,7 @@ describe Chef::Knife do
377
377
  @knife.stub(:run).and_raise(Net::HTTPFatalError.new("502 Bad Gateway", response))
378
378
  @knife.run_with_pretty_exceptions
379
379
  @stderr.string.should match(%r[ERROR: bad gateway])
380
- @stdout.string.should match(%r[Response: sadder trombone])
380
+ @stderr.string.should match(%r[Response: sadder trombone])
381
381
  end
382
382
 
383
383
  it "formats 503s nicely" do
@@ -387,7 +387,7 @@ describe Chef::Knife do
387
387
  @knife.stub(:run).and_raise(Net::HTTPFatalError.new("503 Service Unavailable", response))
388
388
  @knife.run_with_pretty_exceptions
389
389
  @stderr.string.should match(%r[ERROR: Service temporarily unavailable])
390
- @stdout.string.should match(%r[Response: saddest trombone])
390
+ @stderr.string.should match(%r[Response: saddest trombone])
391
391
  end
392
392
 
393
393
  it "formats other HTTP errors nicely" do
@@ -397,15 +397,15 @@ describe Chef::Knife do
397
397
  @knife.stub(:run).and_raise(Net::HTTPServerException.new("402 Payment Required", response))
398
398
  @knife.run_with_pretty_exceptions
399
399
  @stderr.string.should match(%r[ERROR: Payment Required])
400
- @stdout.string.should match(%r[Response: nobugfixtillyoubuy])
400
+ @stderr.string.should match(%r[Response: nobugfixtillyoubuy])
401
401
  end
402
402
 
403
403
  it "formats NameError and NoMethodError nicely" do
404
404
  @knife.stub(:run).and_raise(NameError.new("Undefined constant FUUU"))
405
405
  @knife.run_with_pretty_exceptions
406
406
  @stderr.string.should match(%r[ERROR: knife encountered an unexpected error])
407
- @stdout.string.should match(%r[This may be a bug in the 'knife' knife command or plugin])
408
- @stdout.string.should match(%r[Exception: NameError: Undefined constant FUUU])
407
+ @stderr.string.should match(%r[This may be a bug in the 'knife' knife command or plugin])
408
+ @stderr.string.should match(%r[Exception: NameError: Undefined constant FUUU])
409
409
  end
410
410
 
411
411
  it "formats missing private key errors nicely" do
@@ -413,7 +413,7 @@ describe Chef::Knife do
413
413
  @knife.stub(:api_key).and_return("/home/root/.chef/no-key-here.pem")
414
414
  @knife.run_with_pretty_exceptions
415
415
  @stderr.string.should match(%r[ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem])
416
- @stdout.string.should match(%r[Check your configuration file and ensure that your private key is readable])
416
+ @stderr.string.should match(%r[Check your configuration file and ensure that your private key is readable])
417
417
  end
418
418
 
419
419
  it "formats connection refused errors nicely" do
@@ -423,7 +423,7 @@ describe Chef::Knife do
423
423
  # *nix = Errno::ECONNREFUSED: Connection refused
424
424
  # win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it.
425
425
  @stderr.string.should match(%r[ERROR: Network Error: .* - y u no shut up])
426
- @stdout.string.should match(%r[Check your knife configuration and network settings])
426
+ @stderr.string.should match(%r[Check your knife configuration and network settings])
427
427
  end
428
428
  end
429
429
 
@@ -231,28 +231,8 @@ describe "LWRP" do
231
231
  expect(child.default_action).to eq(:dont_eat)
232
232
  end
233
233
  end
234
-
235
- context "when actions are already defined" do
236
- let(:child) do
237
- Class.new(parent) do
238
- actions :eat
239
- actions :sleep
240
- actions :drink
241
- end
242
- end
243
-
244
- def raise_if_deprecated!
245
- if Chef::VERSION.split('.').first.to_i > 11
246
- raise "This test should be removed and the associated code should be removed!"
247
- end
248
- end
249
-
250
- it "ammends actions when they are already defined" do
251
- raise_if_deprecated!
252
- expect(child.actions).to eq([:eat, :sleep, :drink])
253
- end
254
- end
255
234
  end
235
+
256
236
  end
257
237
 
258
238
  describe "Lightweight Chef::Provider" do
@@ -104,6 +104,98 @@ describe Chef::Mixin::ShellOut do
104
104
 
105
105
  should_emit_deprecation_warning_about :command_log_prepend, :log_tag
106
106
  end
107
+ end
108
+
109
+ describe "#shell_out_with_systems_locale" do
110
+ before(:each) do
111
+ @original_env = ENV.to_hash
112
+ ENV.clear
113
+ end
114
+
115
+ after(:each) do
116
+ ENV.clear
117
+ ENV.update(@original_env)
118
+ end
119
+
120
+ let(:shell_out) { Chef::Mixin::ShellOut }
121
+ let(:cmd) { "echo '#{rand(1000)}'" }
122
+
123
+ describe "when the last argument is a Hash" do
124
+ describe "and environment is an option" do
125
+ it "should not change environment['LC_ALL'] when set to nil" do
126
+ options = { :environment => { 'LC_ALL' => nil } }
127
+ shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
128
+ shell_out.shell_out_with_systems_locale(cmd, options)
129
+ end
130
+
131
+ it "should not change environment['LC_ALL'] when set to non-nil" do
132
+ options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
133
+ shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
134
+ shell_out.shell_out_with_systems_locale(cmd, options)
135
+ end
136
+
137
+ it "should set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
138
+ options = { :environment => { 'HOME' => '/Users/morty' } }
139
+ shell_out.should_receive(:shell_out).with(
140
+ cmd,
141
+ { :environment => {
142
+ 'HOME' => '/Users/morty',
143
+ 'LC_ALL' => nil }
144
+ }
145
+ ).and_return(true)
146
+ shell_out.shell_out_with_systems_locale(cmd, options)
147
+ end
148
+ end
107
149
 
150
+ describe "and env is an option" do
151
+ it "should not change env when set to nil" do
152
+ options = { :env => { 'LC_ALL' => nil } }
153
+ shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
154
+ shell_out.shell_out_with_systems_locale(cmd, options)
155
+ end
156
+
157
+ it "should not change env when set to non-nil" do
158
+ options = { :env => { 'LC_ALL' => 'en_US.UTF-8'}}
159
+ shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
160
+ shell_out.shell_out_with_systems_locale(cmd, options)
161
+ end
162
+
163
+ it "should set env['LC_ALL'] to nil when 'LC_ALL' not present" do
164
+ options = { :env => { 'HOME' => '/Users/morty' } }
165
+ shell_out.should_receive(:shell_out).with(
166
+ cmd,
167
+ { :env => {
168
+ 'HOME' => '/Users/morty',
169
+ 'LC_ALL' => nil }
170
+ }
171
+ ).and_return(true)
172
+ shell_out.shell_out_with_systems_locale(cmd, options)
173
+ end
174
+ end
175
+
176
+ describe "and no env/environment option is present" do
177
+ it "should add environment option and set environment['LC_ALL'] to nil" do
178
+ options = { :user => 'morty' }
179
+ shell_out.should_receive(:shell_out).with(
180
+ cmd,
181
+ { :environment => { 'LC_ALL' => nil },
182
+ :user => 'morty'
183
+ }
184
+ ).and_return(true)
185
+ shell_out.shell_out_with_systems_locale(cmd, options)
186
+ end
187
+ end
188
+ end
189
+
190
+ describe "when the last argument is not a Hash" do
191
+ it "should add environment options and set environment['LC_ALL'] to nil" do
192
+ shell_out.should_receive(:shell_out).with(
193
+ cmd,
194
+ { :environment => { 'LC_ALL' => nil } }
195
+ ).and_return(true)
196
+ shell_out.shell_out_with_systems_locale(cmd)
197
+ end
198
+ end
108
199
  end
200
+
109
201
  end