microwave 1.0.4 → 11.400.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/CONTRIBUTING.md +155 -0
  2. data/README.md +89 -0
  3. data/Rakefile +2 -2
  4. data/bin/chef-apply +25 -0
  5. data/bin/chef-shell +34 -0
  6. data/bin/chef-solo +0 -2
  7. data/bin/shef +6 -5
  8. data/lib/chef.rb +2 -4
  9. data/spec/data/big_json.json +2 -1
  10. data/spec/data/big_json_plus_one.json +2 -1
  11. data/spec/data/cookbooks/chefignore +2 -0
  12. data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
  13. data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
  14. data/spec/data/git_bundles/sinatra-test-app-with-callback-files.gitbundle +0 -0
  15. data/spec/data/git_bundles/sinatra-test-app-with-symlinks.gitbundle +0 -0
  16. data/spec/data/git_bundles/sinatra-test-app.gitbundle +0 -0
  17. data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
  18. data/spec/data/nodes/default.rb +3 -3
  19. data/spec/data/nodes/test.example.com.rb +3 -3
  20. data/spec/data/nodes/test.rb +3 -3
  21. data/spec/data/partial_one.erb +1 -0
  22. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
  23. data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
  24. data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
  25. data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
  26. data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
  27. data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
  28. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  29. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
  30. data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
  31. data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
  32. data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
  33. data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
  34. data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
  35. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  36. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
  37. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
  38. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
  39. data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
  40. data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
  41. data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
  42. data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
  43. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  44. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
  45. data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
  46. data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
  47. data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
  48. data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
  49. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  50. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
  51. data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
  52. data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
  53. data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
  54. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  55. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
  56. data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
  57. data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
  58. data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
  59. data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
  60. data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
  61. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
  62. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
  63. data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
  64. data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
  65. data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
  66. data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
  67. data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
  68. data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
  69. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  70. data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
  71. data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
  72. data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
  73. data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
  74. data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
  75. data/spec/data/shef-config.rb +10 -0
  76. data/spec/functional/dsl/registry_helper_spec.rb +63 -0
  77. data/spec/functional/knife/cookbook_delete_spec.rb +0 -2
  78. data/spec/functional/knife/exec_spec.rb +4 -6
  79. data/spec/functional/knife/smoke_test.rb +34 -0
  80. data/spec/functional/knife/ssh_spec.rb +64 -3
  81. data/spec/functional/resource/cookbook_file_spec.rb +33 -2
  82. data/spec/functional/resource/deploy_revision_spec.rb +515 -0
  83. data/spec/functional/resource/directory_spec.rb +4 -0
  84. data/spec/functional/resource/file_spec.rb +56 -22
  85. data/spec/functional/resource/link_spec.rb +12 -10
  86. data/spec/functional/resource/registry_spec.rb +572 -0
  87. data/spec/functional/resource/remote_directory_spec.rb +142 -36
  88. data/spec/functional/resource/remote_file_spec.rb +28 -3
  89. data/spec/functional/resource/template_spec.rb +23 -2
  90. data/spec/functional/run_lock_spec.rb +238 -0
  91. data/spec/functional/shell_spec.rb +101 -0
  92. data/spec/functional/tiny_server_spec.rb +5 -4
  93. data/spec/functional/win32/registry_helper_spec.rb +632 -0
  94. data/spec/functional/win32/security_spec.rb +37 -0
  95. data/spec/spec_helper.rb +15 -3
  96. data/spec/stress/win32/security_spec.rb +5 -5
  97. data/spec/support/chef_helpers.rb +14 -3
  98. data/spec/support/lib/chef/resource/cat.rb +3 -5
  99. data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
  100. data/spec/support/lib/chef/resource/zen_master.rb +8 -10
  101. data/spec/support/matchers/leak.rb +1 -1
  102. data/spec/support/platform_helpers.rb +18 -0
  103. data/spec/support/shared/functional/directory_resource.rb +85 -23
  104. data/spec/support/shared/functional/file_resource.rb +198 -53
  105. data/spec/support/shared/functional/securable_resource.rb +140 -105
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
  107. data/spec/support/shared/unit/file_system_support.rb +110 -0
  108. data/spec/support/shared/unit/platform_introspector.rb +162 -0
  109. data/spec/tiny_server.rb +29 -10
  110. data/spec/unit/api_client/registration_spec.rb +172 -0
  111. data/spec/unit/api_client_spec.rb +156 -103
  112. data/spec/unit/application/apply.rb +84 -0
  113. data/spec/unit/application/knife_spec.rb +5 -0
  114. data/spec/unit/application_spec.rb +57 -2
  115. data/spec/unit/chef_fs/diff_spec.rb +329 -0
  116. data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
  117. data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
  118. data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
  119. data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
  120. data/spec/unit/chef_fs/file_system_spec.rb +136 -0
  121. data/spec/unit/client_spec.rb +188 -16
  122. data/spec/unit/config_spec.rb +54 -4
  123. data/spec/unit/cookbook/chefignore_spec.rb +2 -1
  124. data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
  125. data/spec/unit/cookbook_loader_spec.rb +153 -91
  126. data/spec/unit/cookbook_manifest_spec.rb +81 -81
  127. data/spec/unit/cookbook_spec.rb +3 -20
  128. data/spec/unit/cookbook_version_spec.rb +23 -122
  129. data/spec/unit/digester_spec.rb +50 -0
  130. data/spec/unit/dsl/data_query_spec.rb +66 -0
  131. data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
  132. data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
  133. data/spec/unit/encrypted_data_bag_item_spec.rb +126 -10
  134. data/spec/unit/environment_spec.rb +0 -130
  135. data/spec/unit/exceptions_spec.rb +2 -3
  136. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +23 -3
  137. data/spec/unit/json_compat_spec.rb +69 -0
  138. data/spec/unit/knife/bootstrap_spec.rb +81 -28
  139. data/spec/unit/knife/client_reregister_spec.rb +23 -22
  140. data/spec/unit/knife/configure_spec.rb +29 -26
  141. data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
  142. data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
  143. data/spec/unit/knife/cookbook_test_spec.rb +1 -0
  144. data/spec/unit/knife/cookbook_upload_spec.rb +41 -2
  145. data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -1
  146. data/spec/unit/knife/core/ui_spec.rb +156 -7
  147. data/spec/unit/knife/data_bag_create_spec.rb +14 -0
  148. data/spec/unit/knife/data_bag_edit_spec.rb +14 -4
  149. data/spec/unit/knife/data_bag_from_file_spec.rb +17 -5
  150. data/spec/unit/knife/data_bag_show_spec.rb +11 -4
  151. data/spec/unit/knife/index_rebuild_spec.rb +96 -33
  152. data/spec/unit/knife/knife_help.rb +7 -7
  153. data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
  154. data/spec/unit/knife/ssh_spec.rb +121 -15
  155. data/spec/unit/knife/status_spec.rb +2 -2
  156. data/spec/unit/knife/user_create_spec.rb +86 -0
  157. data/spec/unit/knife/user_delete_spec.rb +39 -0
  158. data/spec/unit/knife/user_edit_spec.rb +42 -0
  159. data/spec/unit/knife/user_list_spec.rb +32 -0
  160. data/spec/unit/knife/user_reregister_spec.rb +53 -0
  161. data/spec/unit/knife/user_show_spec.rb +41 -0
  162. data/spec/unit/knife_spec.rb +53 -0
  163. data/spec/unit/lwrp_spec.rb +59 -17
  164. data/spec/unit/mixin/checksum_spec.rb +2 -2
  165. data/spec/unit/mixin/deep_merge_spec.rb +56 -491
  166. data/spec/unit/mixin/deprecation_spec.rb +23 -0
  167. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
  168. data/spec/unit/mixin/params_validate_spec.rb +4 -2
  169. data/spec/unit/mixin/securable_spec.rb +5 -3
  170. data/spec/unit/mixin/template_spec.rb +119 -0
  171. data/spec/unit/node/attribute_spec.rb +272 -137
  172. data/spec/unit/node/immutable_collections_spec.rb +139 -0
  173. data/spec/unit/node_spec.rb +411 -339
  174. data/spec/unit/platform_spec.rb +8 -8
  175. data/spec/unit/provider/breakpoint_spec.rb +8 -8
  176. data/spec/unit/provider/cookbook_file_spec.rb +4 -8
  177. data/spec/unit/provider/deploy/revision_spec.rb +2 -8
  178. data/spec/unit/provider/deploy_spec.rb +6 -40
  179. data/spec/unit/provider/directory_spec.rb +103 -68
  180. data/spec/unit/provider/erl_call_spec.rb +0 -2
  181. data/spec/unit/provider/file_spec.rb +69 -59
  182. data/spec/unit/provider/git_spec.rb +0 -10
  183. data/spec/unit/provider/group/groupadd_spec.rb +1 -1
  184. data/spec/unit/provider/group/usermod_spec.rb +2 -2
  185. data/spec/unit/provider/http_request_spec.rb +28 -69
  186. data/spec/unit/provider/ifconfig_spec.rb +2 -2
  187. data/spec/unit/provider/link_spec.rb +1 -1
  188. data/spec/unit/provider/ohai_spec.rb +4 -4
  189. data/spec/unit/provider/package/apt_spec.rb +0 -1
  190. data/spec/unit/provider/package/ips_spec.rb +0 -1
  191. data/spec/unit/provider/package/rubygems_spec.rb +0 -18
  192. data/spec/unit/provider/package/yum_spec.rb +79 -15
  193. data/spec/unit/provider/package_spec.rb +7 -5
  194. data/spec/unit/provider/registry_key_spec.rb +269 -0
  195. data/spec/unit/provider/remote_directory_spec.rb +24 -7
  196. data/spec/unit/provider/remote_file_spec.rb +36 -0
  197. data/spec/unit/provider/route_spec.rb +3 -6
  198. data/spec/unit/provider/ruby_block_spec.rb +8 -0
  199. data/spec/unit/provider/service/arch_service_spec.rb +4 -4
  200. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  201. data/spec/unit/provider/service/freebsd_service_spec.rb +4 -4
  202. data/spec/unit/provider/service/init_service_spec.rb +26 -3
  203. data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
  204. data/spec/unit/provider/service/invokercd_service_spec.rb +3 -3
  205. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  206. data/spec/unit/provider/service/simple_service_spec.rb +3 -3
  207. data/spec/unit/provider/service/upstart_service_spec.rb +7 -7
  208. data/spec/unit/provider/service_spec.rb +2 -2
  209. data/spec/unit/provider/subversion_spec.rb +1 -1
  210. data/spec/unit/provider/template_spec.rb +35 -11
  211. data/spec/unit/provider/user/dscl_spec.rb +57 -31
  212. data/spec/unit/provider/user_spec.rb +7 -16
  213. data/spec/unit/provider_spec.rb +4 -3
  214. data/spec/unit/recipe_spec.rb +10 -8
  215. data/spec/unit/registry_helper_spec.rb +376 -0
  216. data/spec/unit/resource/log_spec.rb +9 -0
  217. data/spec/unit/resource/registry_key_spec.rb +171 -0
  218. data/spec/unit/resource/remote_file_spec.rb +21 -23
  219. data/spec/unit/resource/ruby_block_spec.rb +7 -3
  220. data/spec/unit/resource/service_spec.rb +11 -0
  221. data/spec/unit/resource_spec.rb +27 -4
  222. data/spec/unit/rest/auth_credentials_spec.rb +2 -14
  223. data/spec/unit/rest_spec.rb +122 -187
  224. data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
  225. data/spec/unit/run_context_spec.rb +18 -4
  226. data/spec/unit/run_list_spec.rb +0 -209
  227. data/spec/unit/run_lock_spec.rb +37 -0
  228. data/spec/unit/runner_spec.rb +101 -2
  229. data/spec/unit/scan_access_control_spec.rb +4 -4
  230. data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
  231. data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
  232. data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +12 -12
  233. data/spec/unit/shell_out_spec.rb +18 -0
  234. data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
  235. data/spec/unit/user_spec.rb +255 -0
  236. metadata +162 -157
  237. data/README.rdoc +0 -177
  238. data/spec/unit/certificate_spec.rb +0 -76
  239. data/spec/unit/checksum_cache_spec.rb +0 -209
  240. data/spec/unit/checksum_spec.rb +0 -94
  241. data/spec/unit/couchdb_spec.rb +0 -274
  242. data/spec/unit/index_queue_spec.rb +0 -391
  243. data/spec/unit/json_compat_spect.rb +0 -53
  244. data/spec/unit/mixin/language_spec.rb +0 -305
  245. data/spec/unit/openid_registration_spec.rb +0 -153
  246. data/spec/unit/solr_query/query_transform_spec.rb +0 -454
  247. data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
  248. data/spec/unit/solr_query_spec.rb +0 -203
  249. data/spec/unit/webui_user_spec.rb +0 -238
@@ -1,53 +0,0 @@
1
- #
2
- # Author:: Juanje Ojeda (<juanje.ojeda@gmail.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, 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 File.expand_path('../../spec_helper', __FILE__)
20
- require 'chef/json_compat'
21
-
22
- describe Chef::JSONCompat do
23
- describe "with a file with 1000 or less nested entries" do
24
- before(:all) do
25
- @json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))
26
- @hash = Chef::JSONCompat.from_json(@json)
27
- end
28
-
29
- describe "when a big json file is loaded" do
30
- it "should create a Hash from the file" do
31
- @hash.should be_kind_of(Hash)
32
- end
33
- it "should has 'test' as a 1000th nested value" do
34
- @hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
35
- end
36
- end
37
- end
38
- describe "with a file with more than 1000 nested entries" do
39
- before(:all) do
40
- @json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json_plus_one.json'))
41
- @hash = Chef::JSONCompat.from_json(@json, {:max_nesting => 1001})
42
- end
43
-
44
- describe "when a big json file is loaded" do
45
- it "should create a Hash from the file" do
46
- @hash.should be_kind_of(Hash)
47
- end
48
- it "should has 'test' as a 1001th nested value" do
49
- @hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
50
- end
51
- end
52
- end
53
- end
@@ -1,305 +0,0 @@
1
- #
2
- # Author:: Seth Falcon (<seth@opscode.com>)
3
- # Copyright:: Copyright (c) 2010 Opscode, 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/mixin/language'
21
-
22
- class LanguageTester
23
- include Chef::Mixin::Language
24
- end
25
-
26
- describe Chef::Mixin::Language do
27
- before(:each) do
28
- @language = LanguageTester.new
29
- @node = Hash.new
30
- @language.stub!(:node).and_return(@node)
31
- @platform_hash = {}
32
- %w{openbsd freebsd}.each do |x|
33
- @platform_hash[x] = {
34
- "default" => x,
35
- "1.2.3" => "#{x}-1.2.3"
36
- }
37
- end
38
- @platform_hash["debian"] = {["5", "6"] => "debian-5/6", "default" => "debian"}
39
- @platform_hash["default"] = "default"
40
-
41
- @platform_family_hash = {
42
- "debian" => "debian value",
43
- [:rhel, :fedora] => "redhatty value",
44
- "suse" => "suse value",
45
- :default => "default value"
46
- }
47
- end
48
-
49
- it "returns a default value when there is no known platform" do
50
- @node = Hash.new
51
- @language.value_for_platform(@platform_hash).should == "default"
52
- end
53
-
54
- it "returns a default value when there is no known platform family" do
55
- @language.value_for_platform_family(@platform_family_hash).should == "default value"
56
- end
57
-
58
- it "returns a default value when the current platform doesn't match" do
59
- @node[:platform] = "not-a-known-platform"
60
- @language.value_for_platform(@platform_hash).should == "default"
61
- end
62
-
63
- it "returns a default value when current platform_family doesn't match" do
64
- @node[:platform_family] = "ultra-derived-linux"
65
- @language.value_for_platform_family(@platform_family_hash).should == "default value"
66
- end
67
-
68
- it "returns a value based on the current platform" do
69
- @node[:platform] = "openbsd"
70
- @language.value_for_platform(@platform_hash).should == "openbsd"
71
- end
72
-
73
- it "returns a value based on the current platform family" do
74
- @node[:platform_family] = "debian"
75
- @language.value_for_platform_family(@platform_family_hash).should == "debian value"
76
- end
77
-
78
- it "returns a version-specific value based on the current platform" do
79
- @node[:platform] = "openbsd"
80
- @node[:platform_version] = "1.2.3"
81
- @language.value_for_platform(@platform_hash).should == "openbsd-1.2.3"
82
- end
83
-
84
- it "returns a value based on the current platform if version not found" do
85
- @node[:platform] = "openbsd"
86
- @node[:platform_version] = "0.0.0"
87
- @language.value_for_platform(@platform_hash).should == "openbsd"
88
- end
89
-
90
- describe "when platform versions is an array" do
91
- it "returns a version-specific value based on the current platform" do
92
- @node[:platform] = "debian"
93
- @node[:platform_version] = "6"
94
- @language.value_for_platform(@platform_hash).should == "debian-5/6"
95
- end
96
-
97
- it "returns a value based on the current platform if version not found" do
98
- @node[:platform] = "debian"
99
- @node[:platform_version] = "0.0.0"
100
- @language.value_for_platform(@platform_hash).should == "debian"
101
- end
102
- end
103
-
104
- describe "when checking platform?" do
105
- before(:each) do
106
- @language = LanguageTester.new
107
- @node = Hash.new
108
- @language.stub!(:node).and_return(@node)
109
- end
110
-
111
- it "returns true if the node is a provided platform and platforms are provided as symbols" do
112
- @node[:platform] = 'ubuntu'
113
- @language.platform?([:redhat, :ubuntu]).should == true
114
- end
115
-
116
- it "returns true if the node is a provided platform and platforms are provided as strings" do
117
- @node[:platform] = 'ubuntu'
118
- @language.platform?(["redhat", "ubuntu"]).should == true
119
- end
120
-
121
- it "returns false if the node is not of the provided platforms" do
122
- @node[:platform] = 'ubuntu'
123
- @language.platform?(:splatlinux).should == false
124
- end
125
- end
126
-
127
- describe "when checking platform_family?" do
128
- before(:each) do
129
- @language = LanguageTester.new
130
- @node = Hash.new
131
- @language.stub!(:node).and_return(@node)
132
- end
133
-
134
- it "returns true if the node is in a provided platform family and families are provided as symbols" do
135
- @node[:platform_family] = 'debian'
136
- @language.platform_family?([:rhel, :debian]).should == true
137
- end
138
-
139
- it "returns true if the node is a provided platform and platforms are provided as strings" do
140
- @node[:platform_family] = 'rhel'
141
- @language.platform_family?(["rhel", "debian"]).should == true
142
- end
143
-
144
- it "returns false if the node is not of the provided platforms" do
145
- @node[:platform_family] = 'suse'
146
- @language.platform_family?(:splatlinux).should == false
147
- end
148
-
149
- it "returns false if the node is not of the provided platforms and platform_family is not set" do
150
- @language.platform_family?(:splatlinux).should == false
151
- end
152
-
153
- end
154
- # NOTE: this is a regression test for bug CHEF-1514
155
- describe "when the value is an array" do
156
- before do
157
- @platform_hash = {
158
- "debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] },
159
- "ubuntu" => { "default" => [ :restart, :reload, :status ] },
160
- "centos" => { "default" => [ :restart, :reload, :status ] },
161
- "redhat" => { "default" => [ :restart, :reload, :status ] },
162
- "fedora" => { "default" => [ :restart, :reload, :status ] },
163
- "default" => { "default" => [:restart, :reload ] }}
164
- end
165
-
166
- it "returns the correct default for a given platform" do
167
- @node[:platform] = "debian"
168
- @node[:platform_version] = '9000'
169
- @language.value_for_platform(@platform_hash).should == [ :restart, :reload, :status ]
170
- end
171
-
172
- it "returns the correct platform+version specific value " do
173
- @node[:platform] = "debian"
174
- @node[:platform_version] = '4.0'
175
- @language.value_for_platform(@platform_hash).should == [:restart, :reload]
176
- end
177
- end
178
-
179
- describe "when loading data bags and items" do
180
- it "lists the items in a data bag" do
181
- Chef::DataBag.should_receive(:load).with("bag_name").and_return("item_1" => "http://url_for/item_1", "item_2" => "http://url_for/item_2")
182
- @language.data_bag("bag_name").sort.should == %w[item_1 item_2]
183
- end
184
-
185
- it "validates the name of the data bag you're trying to load" do
186
- lambda {@language.data_bag("!# %^&& ")}.should raise_error(Chef::Exceptions::InvalidDataBagName)
187
- end
188
-
189
- it "fetches a data bag item" do
190
- @item = Chef::DataBagItem.new
191
- @item.data_bag("bag_name")
192
- @item.raw_data = {"id" => "item_name", "FUU" => "FUU"}
193
- Chef::DataBagItem.should_receive(:load).with("bag_name", "item_name").and_return(@item)
194
- @language.data_bag_item("bag_name", "item_name").should == @item
195
- end
196
-
197
- it "validates the name of the data bag you're trying to load an item from" do
198
- lambda {@language.data_bag_item(" %%^& ", "item_name")}.should raise_error(Chef::Exceptions::InvalidDataBagName)
199
- end
200
-
201
- it "validates the id of the data bag item you're trying to load" do
202
- lambda {@language.data_bag_item("bag_name", " 987 (*&()")}.should raise_error(Chef::Exceptions::InvalidDataBagItemID)
203
- end
204
-
205
- it "validates that the id of the data bag item is not nil" do
206
- lambda {@language.data_bag_item("bag_name", nil)}.should raise_error(Chef::Exceptions::InvalidDataBagItemID)
207
- end
208
-
209
- end
210
-
211
- end
212
-
213
- describe Chef::Mixin::Language::PlatformDependentValue do
214
- before do
215
- platform_hash = {
216
- :openbsd => {:default => 'free, functional, secure'},
217
- [:redhat, :centos, :fedora, :scientific] => {:default => '"stable"'},
218
- :ubuntu => {'10.04' => 'using upstart more', :default => 'using init more'},
219
- :default => 'bork da bork'
220
- }
221
- @platform_specific_value = Chef::Mixin::Language::PlatformDependentValue.new(platform_hash)
222
- end
223
-
224
- it "returns the default value when the platform doesn't match" do
225
- @platform_specific_value.value_for_node(:platform => :dos).should == 'bork da bork'
226
- end
227
-
228
- it "returns a value for a platform set as a group" do
229
- @platform_specific_value.value_for_node(:platform => :centos).should == '"stable"'
230
- end
231
-
232
- it "returns a value for the platform when it was set as a symbol but fetched as a string" do
233
- @platform_specific_value.value_for_node(:platform => "centos").should == '"stable"'
234
- end
235
-
236
- it "returns a value for a specific platform version" do
237
- node = {:platform => 'ubuntu', :platform_version => '10.04'}
238
- @platform_specific_value.value_for_node(node).should == 'using upstart more'
239
- end
240
-
241
- it "returns a platform-default value if the platform version doesn't match an explicit one" do
242
- node = {:platform => 'ubuntu', :platform_version => '9.10' }
243
- @platform_specific_value.value_for_node(node).should == 'using init more'
244
- end
245
-
246
- it "returns nil if there is no default and no platforms match" do
247
- # this matches the behavior in the original implementation.
248
- # whether or not it's correct is another matter.
249
- platform_specific_value = Chef::Mixin::Language::PlatformDependentValue.new({})
250
- platform_specific_value.value_for_node(:platform => 'foo').should be_nil
251
- end
252
-
253
- it "raises an argument error if the platform hash is not correctly structured" do
254
- bad_hash = {:ubuntu => :foo} # should be :ubuntu => {:default => 'foo'}
255
- lambda {Chef::Mixin::Language::PlatformDependentValue.new(bad_hash)}.should raise_error(ArgumentError)
256
- end
257
-
258
- end
259
- describe Chef::Mixin::Language::PlatformFamilyDependentValue do
260
- before do
261
- @array_values = [:stop, :start, :reload]
262
-
263
- @platform_family_hash = {
264
- "debian" => "debian value",
265
- [:rhel, "fedora"] => "redhatty value",
266
- "suse" => @array_values,
267
- :gentoo => "gentoo value",
268
- :default => "default value"
269
- }
270
-
271
- @platform_family_value = Chef::Mixin::Language::PlatformFamilyDependentValue.new(@platform_family_hash)
272
- end
273
-
274
- it "returns the default value when the platform family doesn't match" do
275
- @platform_family_value.value_for_node(:platform_family => :os2).should == 'default value'
276
- end
277
-
278
-
279
- it "returns a value for the platform family when it was set as a string but fetched as a symbol" do
280
- @platform_family_value.value_for_node(:platform_family => :debian).should == "debian value"
281
- end
282
-
283
-
284
- it "returns a value for the platform family when it was set as a symbol but fetched as a string" do
285
- @platform_family_value.value_for_node(:platform_family => "gentoo").should == "gentoo value"
286
- end
287
-
288
- it "returns an array value stored for a platform family" do
289
- @platform_family_value.value_for_node(:platform_family => "suse").should == @array_values
290
- end
291
-
292
- it "returns a value for the platform family when it was set within an array hash key as a symbol" do
293
- @platform_family_value.value_for_node(:platform_family => :rhel).should == "redhatty value"
294
- end
295
-
296
- it "returns a value for the platform family when it was set within an array hash key as a string" do
297
- @platform_family_value.value_for_node(:platform_family => "fedora").should == "redhatty value"
298
- end
299
-
300
- it "returns nil if there is no default and no platforms match" do
301
- platform_specific_value = Chef::Mixin::Language::PlatformFamilyDependentValue.new({})
302
- platform_specific_value.value_for_node(:platform_family => 'foo').should be_nil
303
- end
304
-
305
- end
@@ -1,153 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, 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::OpenIDRegistration, "initialize" do
22
- it "should return a new Chef::OpenIDRegistration object" do
23
- Chef::OpenIDRegistration.new.should be_kind_of(Chef::OpenIDRegistration)
24
- end
25
- end
26
-
27
- describe Chef::OpenIDRegistration, "set_password" do
28
- it "should generate a salt for this object" do
29
- oreg = Chef::OpenIDRegistration.new
30
- oreg.salt.should eql(nil)
31
- oreg.set_password("foolio")
32
- oreg.salt.should_not eql(nil)
33
- end
34
-
35
- it "should encrypt the password with the salt and the plaintext password" do
36
- oreg = Chef::OpenIDRegistration.new
37
- oreg.set_password("foolio")
38
- oreg.password.should_not eql(nil)
39
- end
40
- end
41
-
42
- describe Chef::OpenIDRegistration, "to_json" do
43
- it "should serialize itself as json" do
44
- oreg = Chef::OpenIDRegistration.new
45
- oreg.set_password("monkey")
46
- json = oreg.to_json
47
- %w{json_class chef_type name salt password validated}.each do |verify|
48
- json.should =~ /#{verify}/
49
- end
50
- end
51
- end
52
-
53
- describe Chef::OpenIDRegistration, "from_json" do
54
- it "should serialize itself as json" do
55
- oreg = Chef::OpenIDRegistration.new()
56
- oreg.name = "foobar"
57
- oreg.set_password("monkey")
58
- oreg_json = oreg.to_json
59
- nreg = Chef::JSONCompat.from_json(oreg_json)
60
- nreg.should be_a_kind_of(Chef::OpenIDRegistration)
61
- %w{name salt password validated}.each do |verify|
62
- nreg.send(verify.to_sym).should eql(oreg.send(verify.to_sym))
63
- end
64
- end
65
- end
66
-
67
- describe Chef::OpenIDRegistration, "list" do
68
- before(:each) do
69
- @mock_couch = mock("Chef::CouchDB")
70
- @mock_couch.stub!(:list).and_return({
71
- "rows" => [
72
- {
73
- "value" => "a",
74
- "key" => "avenue"
75
- }
76
- ]
77
- })
78
- Chef::CouchDB.stub!(:new).and_return(@mock_couch)
79
- end
80
-
81
- it "should retrieve a list of nodes from CouchDB" do
82
- Chef::OpenIDRegistration.list.should eql(["avenue"])
83
- end
84
-
85
- it "should return just the ids if inflate is false" do
86
- Chef::OpenIDRegistration.list(false).should eql(["avenue"])
87
- end
88
-
89
- it "should return the full objects if inflate is true" do
90
- Chef::OpenIDRegistration.list(true).should eql(["a"])
91
- end
92
- end
93
-
94
- describe Chef::OpenIDRegistration, "load" do
95
- it "should load a registration from couchdb by name" do
96
- @mock_couch = mock("Chef::CouchDB")
97
- Chef::CouchDB.stub!(:new).and_return(@mock_couch)
98
- @mock_couch.should_receive(:load).with("openid_registration", "coffee").and_return(true)
99
- Chef::OpenIDRegistration.load("coffee")
100
- end
101
- end
102
-
103
- describe Chef::OpenIDRegistration, "destroy" do
104
- it "should delete this registration from couchdb" do
105
- @mock_couch = mock("Chef::CouchDB")
106
- @mock_couch.should_receive(:delete).with("openid_registration", "bob", 1).and_return(true)
107
- Chef::CouchDB.stub!(:new).and_return(@mock_couch)
108
- reg = Chef::OpenIDRegistration.new
109
- reg.name = "bob"
110
- reg.couchdb_rev = 1
111
- reg.destroy
112
- end
113
- end
114
-
115
- describe Chef::OpenIDRegistration, "save" do
116
- before(:each) do
117
- @mock_couch = mock("Chef::CouchDB")
118
- Chef::CouchDB.stub!(:new).and_return(@mock_couch)
119
- @reg = Chef::OpenIDRegistration.new
120
- @reg.name = "bob"
121
- @reg.couchdb_rev = 1
122
- end
123
-
124
- it "should save the registration to couchdb" do
125
- @mock_couch.should_receive(:store).with("openid_registration", "bob", @reg).and_return({ "rev" => 33 })
126
- @reg.save
127
- end
128
-
129
- it "should store the new couchdb_rev" do
130
- @mock_couch.stub!(:store).with("openid_registration", "bob", @reg).and_return({ "rev" => 33 })
131
- @reg.save
132
- @reg.couchdb_rev.should eql(33)
133
- end
134
- end
135
-
136
- describe Chef::OpenIDRegistration, "create_design_document" do
137
- it "should create our design document" do
138
- mock_couch = mock("Chef::CouchDB")
139
- mock_couch.should_receive(:create_design_document).with("registrations", Chef::OpenIDRegistration::DESIGN_DOCUMENT)
140
- Chef::CouchDB.stub!(:new).and_return(mock_couch)
141
- Chef::OpenIDRegistration.create_design_document
142
- end
143
- end
144
-
145
- describe Chef::OpenIDRegistration, "has_key?" do
146
- it "should check with CouchDB for a registration with this key" do
147
- @mock_couch = mock("Chef::CouchDB")
148
- @mock_couch.should_receive(:has_key?).with("openid_registration", "bob").and_return(true)
149
- Chef::CouchDB.stub!(:new).and_return(@mock_couch)
150
- Chef::OpenIDRegistration.has_key?("bob")
151
- end
152
- end
153
-