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
@@ -181,7 +181,7 @@ describe Chef::CookbookLoader do
181
181
  aa.to_hash["metadata"].recipes.keys.should include("openldap")
182
182
  expected_desc = "Main Open LDAP configuration"
183
183
  aa.to_hash["metadata"].recipes["openldap"].should == expected_desc
184
- raw = Chef::JSONCompat.to_json(aa.to_hash["metadata"].recipes)
184
+ raw = aa.to_hash["metadata"].recipes.to_json
185
185
  search_str = "\"openldap\":\""
186
186
  key_idx = raw.index(search_str)
187
187
  key_idx.should be > 0
@@ -0,0 +1,160 @@
1
+ #
2
+ # Author:: Daniel DeLeo (<dan@getchef.com>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::CookbookUploader do
22
+
23
+ let(:http_client) { double("Chef::REST") }
24
+
25
+ let(:cookbook_loader) do
26
+ loader = Chef::CookbookLoader.new(File.join(CHEF_SPEC_DATA, "cookbooks"))
27
+ loader.load_cookbooks
28
+ loader
29
+ end
30
+
31
+ let(:apache2_cookbook) { cookbook_loader.cookbooks_by_name["apache2"] }
32
+
33
+ let(:java_cookbook) { cookbook_loader.cookbooks_by_name["java"] }
34
+
35
+ let(:cookbooks_to_upload) { [apache2_cookbook, java_cookbook] }
36
+
37
+ let(:checksums_of_cookbook_files) { apache2_cookbook.checksums.merge(java_cookbook.checksums) }
38
+
39
+ let(:checksums_set) do
40
+ checksums_of_cookbook_files.keys.inject({}) do |set, cksum|
41
+ set[cksum] = nil
42
+ set
43
+ end
44
+ end
45
+
46
+ let(:sandbox_commit_uri) { "https://chef.example.org/sandboxes/abc123" }
47
+
48
+ let(:uploader) { described_class.new(cookbooks_to_upload, :rest => http_client) }
49
+
50
+ it "has a list of cookbooks to upload" do
51
+ expect(uploader.cookbooks).to eq(cookbooks_to_upload)
52
+ end
53
+
54
+ it "creates an HTTP client with default configuration when not initialized with one" do
55
+ default_http_client = double("Chef::REST")
56
+ expect(Chef::REST).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(default_http_client)
57
+ uploader = described_class.new(cookbooks_to_upload)
58
+ expect(uploader.rest).to eq(default_http_client)
59
+ end
60
+
61
+ describe "uploading cookbooks" do
62
+
63
+ def url_for(cksum)
64
+ "https://storage.example.com/#{cksum}"
65
+ end
66
+
67
+ let(:sandbox_response) do
68
+ sandbox_checksums = cksums_not_on_remote.inject({}) do |cksum_map, cksum|
69
+ cksum_map[cksum] = { "needs_upload" => true, "url" => url_for(cksum)}
70
+ cksum_map
71
+ end
72
+ { "checksums" => sandbox_checksums, "uri" => sandbox_commit_uri }
73
+ end
74
+
75
+ def expect_sandbox_create
76
+ expect(http_client).to receive(:post).
77
+ with("sandboxes", {:checksums => checksums_set}).
78
+ and_return(sandbox_response)
79
+ end
80
+
81
+ def expect_checksum_upload
82
+ checksums_of_cookbook_files.each do |md5, file_path|
83
+ next unless cksums_not_on_remote.include?(md5)
84
+
85
+ upload_headers = {
86
+ "content-type" => "application/x-binary",
87
+ "content-md5" => an_instance_of(String),
88
+ "accept" => "application/json"
89
+ }
90
+
91
+ expect(http_client).to receive(:put).
92
+ with(url_for(md5), IO.binread(file_path), upload_headers)
93
+
94
+ end
95
+ end
96
+
97
+ def expect_sandbox_commit
98
+ expect(http_client).to receive(:put).with(sandbox_commit_uri, {:is_completed => true})
99
+ end
100
+
101
+ def expect_cookbook_create
102
+ cookbooks_to_upload.each do |cookbook|
103
+
104
+ expect(http_client).to receive(:put).
105
+ with(cookbook.save_url, cookbook)
106
+
107
+ end
108
+ end
109
+
110
+ context "when no files exist on the server" do
111
+
112
+ let(:cksums_not_on_remote) do
113
+ checksums_of_cookbook_files.keys
114
+ end
115
+
116
+ it "uploads all files in a sandbox transaction, then creates cookbooks on the server" do
117
+ expect_sandbox_create
118
+ expect_checksum_upload
119
+ expect_sandbox_commit
120
+ expect_cookbook_create
121
+
122
+ uploader.upload_cookbooks
123
+ end
124
+
125
+ end
126
+
127
+ context "when some files exist on the server" do
128
+
129
+ let(:cksums_not_on_remote) do
130
+ checksums_of_cookbook_files.keys[0, 1]
131
+ end
132
+
133
+ it "uploads all files in a sandbox transaction, then creates cookbooks on the server" do
134
+ expect_sandbox_create
135
+ expect_checksum_upload
136
+ expect_sandbox_commit
137
+ expect_cookbook_create
138
+
139
+ uploader.upload_cookbooks
140
+ end
141
+
142
+ end
143
+
144
+ context "when all files already exist on the server" do
145
+
146
+ let(:cksums_not_on_remote) { [] }
147
+
148
+ it "uploads all files in a sandbox transaction, then creates cookbooks on the server" do
149
+ expect_sandbox_create
150
+ expect_checksum_upload
151
+ expect_sandbox_commit
152
+ expect_cookbook_create
153
+
154
+ uploader.upload_cookbooks
155
+ end
156
+
157
+ end
158
+ end
159
+
160
+ end
@@ -420,10 +420,6 @@ describe Chef::CookbookVersion do
420
420
  end
421
421
  end
422
422
 
423
- include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
424
- let(:subject) { Chef::CookbookVersion.new("tatft", '/tmp/blah') }
425
- end
426
-
427
423
  end
428
424
 
429
425
  end
@@ -166,7 +166,7 @@ describe Chef::DataBagItem do
166
166
  before(:each) do
167
167
  @data_bag_item.data_bag('mars_volta')
168
168
  @data_bag_item.raw_data = { "id" => "octahedron", "snooze" => { "finally" => :world_will }}
169
- @deserial = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@data_bag_item))
169
+ @deserial = Chef::JSONCompat.from_json(@data_bag_item.to_json)
170
170
  end
171
171
 
172
172
  it "should deserialize to a Chef::DataBagItem object" do
@@ -184,10 +184,6 @@ describe Chef::DataBagItem do
184
184
  it "should have a matching 'snooze' key" do
185
185
  @deserial["snooze"].should == { "finally" => "world_will" }
186
186
  end
187
-
188
- include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
189
- let(:subject) { @data_bag_item }
190
- end
191
187
  end
192
188
 
193
189
  describe "when converting to a string" do
@@ -58,7 +58,7 @@ describe Chef::DataBag do
58
58
  describe "deserialize" do
59
59
  before(:each) do
60
60
  @data_bag.name('mars_volta')
61
- @deserial = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@data_bag))
61
+ @deserial = Chef::JSONCompat.from_json(@data_bag.to_json)
62
62
  end
63
63
 
64
64
  it "should deserialize to a Chef::DataBag object" do
@@ -73,10 +73,6 @@ describe Chef::DataBag do
73
73
  end
74
74
  end
75
75
 
76
- include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
77
- let(:subject) { @data_bag }
78
- end
79
-
80
76
  end
81
77
 
82
78
  describe "when saving" do
@@ -46,7 +46,7 @@ describe Chef::Deprecation do
46
46
  end
47
47
 
48
48
  method_snapshot_file = File.join(CHEF_SPEC_DATA, "file-providers-method-snapshot-chef-11-4.json")
49
- method_snapshot = Chef::JSONCompat.parse(File.open(method_snapshot_file).read())
49
+ method_snapshot = JSON.parse(File.open(method_snapshot_file).read())
50
50
 
51
51
  method_snapshot.each do |class_name, old_methods|
52
52
  class_object = class_from_string(class_name)
@@ -46,6 +46,18 @@ describe Chef::DSL::Recipe do
46
46
  it "responds to recipe_name" do
47
47
  expect(recipe.recipe_name).to eq(recipe_name)
48
48
  end
49
+
50
+ it "responds to shell_out" do
51
+ expect(recipe.respond_to?(:shell_out)).to be true
52
+ end
53
+
54
+ it "responds to shell_out" do
55
+ expect(recipe.respond_to?(:shell_out!)).to be true
56
+ end
57
+
58
+ it "responds to shell_out" do
59
+ expect(recipe.respond_to?(:shell_out_with_systems_locale)).to be true
60
+ end
49
61
  end
50
62
 
51
63
  context "when included in a class that defines the required interface directly" do
@@ -100,17 +100,6 @@ describe Chef::EncryptedDataBagItem::Decryptor do
100
100
  let(:plaintext_data) { {"foo" => "bar"} }
101
101
  let(:encryption_key) { "passwd" }
102
102
  let(:decryption_key) { encryption_key }
103
- let(:json_wrapped_data) { Chef::JSONCompat.to_json({"json_wrapper" => plaintext_data}) }
104
-
105
- shared_examples "decryption examples" do
106
- it "decrypts the encrypted value" do
107
- decryptor.decrypted_data.should eq(json_wrapped_data)
108
- end
109
-
110
- it "unwraps the encrypted data and returns it" do
111
- decryptor.for_decrypted_item.should eq plaintext_data
112
- end
113
- end
114
103
 
115
104
  context "when decrypting a version 2 (JSON+aes-256-cbc+hmac-sha256+random iv) encrypted value" do
116
105
  let(:encrypted_value) do
@@ -123,8 +112,6 @@ describe Chef::EncryptedDataBagItem::Decryptor do
123
112
  Base64.encode64(raw_hmac)
124
113
  end
125
114
 
126
- include_examples "decryption examples"
127
-
128
115
  it "rejects the data if the hmac is wrong" do
129
116
  encrypted_value["hmac"] = bogus_hmac
130
117
  lambda { decryptor.for_decrypted_item }.should raise_error(Chef::EncryptedDataBagItem::DecryptionFailure)
@@ -147,7 +134,13 @@ describe Chef::EncryptedDataBagItem::Decryptor do
147
134
  decryptor.should be_a_kind_of Chef::EncryptedDataBagItem::Decryptor::Version1Decryptor
148
135
  end
149
136
 
150
- include_examples "decryption examples"
137
+ it "decrypts the encrypted value" do
138
+ decryptor.decrypted_data.should eq({"json_wrapper" => plaintext_data}.to_json)
139
+ end
140
+
141
+ it "unwraps the encrypted data and returns it" do
142
+ decryptor.for_decrypted_item.should eq plaintext_data
143
+ end
151
144
 
152
145
  describe "and the decryption step returns invalid data" do
153
146
  it "raises a decryption failure error" do
@@ -196,7 +196,7 @@ describe Chef::Environment do
196
196
 
197
197
  %w{name description cookbook_versions}.each do |t|
198
198
  it "should include '#{t}'" do
199
- @json.should =~ /"#{t}":#{Regexp.escape(Chef::JSONCompat.to_json(@environment.send(t.to_sym)))}/
199
+ @json.should =~ /"#{t}":#{Regexp.escape(@environment.send(t.to_sym).to_json)}/
200
200
  end
201
201
  end
202
202
 
@@ -207,10 +207,6 @@ describe Chef::Environment do
207
207
  it "should include 'chef_type'" do
208
208
  @json.should =~ /"chef_type":"environment"/
209
209
  end
210
-
211
- include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
212
- let(:subject) { @environment }
213
- end
214
210
  end
215
211
 
216
212
  describe "from_json" do
@@ -226,7 +222,7 @@ describe Chef::Environment do
226
222
  "json_class" => "Chef::Environment",
227
223
  "chef_type" => "environment"
228
224
  }
229
- @environment = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@data))
225
+ @environment = Chef::JSONCompat.from_json(@data.to_json)
230
226
  end
231
227
 
232
228
  it "should return a Chef::Environment" do
@@ -424,7 +420,7 @@ describe Chef::Environment do
424
420
  "description" => "desc",
425
421
  "chef_type" => "environment"
426
422
  }
427
- IO.should_receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(Chef::JSONCompat.to_json(environment_hash))
423
+ IO.should_receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(JSON.dump(environment_hash))
428
424
  environment = Chef::Environment.load('foo')
429
425
 
430
426
  environment.should be_a_kind_of(Chef::Environment)
@@ -74,11 +74,5 @@ describe Chef::Exceptions do
74
74
  it "should have an exception class of #{exception} which inherits from #{expected_super_class}" do
75
75
  lambda{ raise exception }.should raise_error(expected_super_class)
76
76
  end
77
-
78
- if exception.methods.include?(:to_json)
79
- include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
80
- let(:subject) { exception }
81
- end
82
- end
83
77
  end
84
78
  end
@@ -0,0 +1,128 @@
1
+ #--
2
+ # Author:: Daniel DeLeo (<dan@getchef.com>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/http/json_input'
21
+
22
+ describe Chef::HTTP::JSONInput do
23
+
24
+ let(:json_encoder) { described_class.new() }
25
+
26
+ let(:url) { URI.parse("http://example.com") }
27
+ let(:headers) { {} }
28
+
29
+ def handle_request
30
+ json_encoder.handle_request(http_method, url, headers, data)
31
+ end
32
+
33
+ it "passes the response unmodified" do
34
+ http_response = double("Net::HTTPSuccess")
35
+ request = double("Chef::HTTP::HTTPRequest")
36
+ return_value = "response body"
37
+
38
+ result = json_encoder.handle_response(http_response, request, return_value)
39
+ expect(result).to eq([http_response, request, return_value])
40
+ end
41
+
42
+ it "doesn't handle streaming responses" do
43
+ http_response = double("Net::HTTPSuccess")
44
+ expect(json_encoder.stream_response_handler(http_response)).to be nil
45
+ end
46
+
47
+ it "does nothing for stream completion" do
48
+ http_response = double("Net::HTTPSuccess")
49
+ request = double("Chef::HTTP::HTTPRequest")
50
+ return_value = "response body"
51
+
52
+ result = json_encoder.handle_response(http_response, request, return_value)
53
+ expect(result).to eq([http_response, request, return_value])
54
+ end
55
+
56
+ context "when handling a request with no body" do
57
+
58
+ let(:http_method) { :get }
59
+ let(:data) { nil }
60
+
61
+ it "passes the request unmodified" do
62
+ expect(handle_request).to eq([http_method, url, headers, data])
63
+ end
64
+ end
65
+
66
+ context "when the request should be serialized" do
67
+
68
+ let(:http_method) { :put }
69
+ let(:data) { {foo: "bar"} }
70
+ let(:expected_data) { %q[{"foo":"bar"}] }
71
+
72
+ context "and the request has a ruby object as the body and no explicit content-type" do
73
+
74
+ it "serializes the body to json" do
75
+ # Headers Hash get mutated, so we start by asserting it's empty:
76
+ expect(headers).to be_empty
77
+
78
+ expect(handle_request).to eq([http_method, url, headers, expected_data])
79
+
80
+ # Now the headers Hash should have json content type:
81
+ expect(headers).to have_key("Content-Type")
82
+ expect(headers["Content-Type"]).to eq("application/json")
83
+ end
84
+ end
85
+
86
+ context "ant the request has an explicit content type of json" do
87
+
88
+ it "serializes the body to json when content-type is all lowercase" do
89
+ headers["content-type"] = "application/json"
90
+
91
+ expect(handle_request).to eq([http_method, url, headers, expected_data])
92
+
93
+ # Content-Type header should be normalized:
94
+ expect(headers.size).to eq(1)
95
+ expect(headers).to have_key("Content-Type")
96
+ expect(headers["Content-Type"]).to eq("application/json")
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ context "when handling a request with an explicit content type other than json" do
104
+
105
+ let(:http_method) { :put }
106
+ let(:data) { "some arbitrary bytes" }
107
+
108
+ it "does not serialize the body to json when content type is given as lowercase" do
109
+ headers["content-type"] = "application/x-binary"
110
+
111
+ expect(handle_request).to eq([http_method, url, headers, data])
112
+
113
+ # not normalized
114
+ expect(headers).to eq({"content-type" => "application/x-binary"})
115
+ end
116
+
117
+ it "does not serialize the body to json when content type is given in capitalized form" do
118
+ headers["Content-Type"] = "application/x-binary"
119
+
120
+ expect(handle_request).to eq([http_method, url, headers, data])
121
+
122
+ # not normalized
123
+ expect(headers).to eq({"Content-Type" => "application/x-binary"})
124
+ end
125
+
126
+ end
127
+
128
+ end