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
@@ -30,6 +30,14 @@ describe Chef::Provider::RubyBlock, "initialize" do
30
30
  end
31
31
 
32
32
  it "should call the block and flag the resource as updated" do
33
+ @provider.run_action(:run)
34
+ $evil_global_evil_laugh.should == :mwahahaha
35
+ @new_resource.should be_updated
36
+ end
37
+
38
+ it "accepts `create' as an alias for `run'" do
39
+ # SEE ALSO: CHEF-3500
40
+ # "create" used to be the default action, it was renamed.
33
41
  @provider.run_action(:create)
34
42
  $evil_global_evil_laugh.should == :mwahahaha
35
43
  @new_resource.should be_updated
@@ -27,7 +27,7 @@ require 'ostruct'
27
27
  describe Chef::Provider::Service::Arch, "load_current_resource" do
28
28
  before(:each) do
29
29
  @node = Chef::Node.new
30
- @node[:command] = {:ps => "ps -ef"}
30
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
31
31
 
32
32
  @events = Chef::EventDispatch::Dispatcher.new
33
33
  @run_context = Chef::RunContext.new(@node, {}, @events)
@@ -96,14 +96,14 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
96
96
  end
97
97
 
98
98
  it "should raise error if the node has a nil ps attribute and no other means to get status" do
99
- @node[:command] = {:ps => nil}
99
+ @node.automatic_attrs[:command] = {:ps => nil}
100
100
  @provider.define_resource_requirements
101
101
  @provider.action = :start
102
102
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
103
103
  end
104
104
 
105
105
  it "should raise error if the node has an empty ps attribute and no other means to get status" do
106
- @node[:command] = {:ps => ""}
106
+ @node.automatic_attrs[:command] = {:ps => ""}
107
107
  @provider.define_resource_requirements
108
108
  @provider.action = :start
109
109
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
@@ -130,7 +130,7 @@ DEFAULT_PS
130
130
  @status = mock("Status", :exitstatus => 0, :stdout => @stdout)
131
131
  @provider.stub!(:shell_out!).and_return(@status)
132
132
 
133
- @node[:command] = {:ps => "ps -ef"}
133
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
134
134
  end
135
135
 
136
136
  it "determines the service is running when it appears in ps" do
@@ -21,7 +21,7 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Debian, "load_current_resource" do
22
22
  before(:each) do
23
23
  @node = Chef::Node.new
24
- @node[:command] = {:ps => 'fuuuu'}
24
+ @node.automatic_attrs[:command] = {:ps => 'fuuuu'}
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
27
 
@@ -21,7 +21,7 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Freebsd do
22
22
  before do
23
23
  @node = Chef::Node.new
24
- @node[:command] = {:ps => "ps -ax"}
24
+ @node.automatic_attrs[:command] = {:ps => "ps -ax"}
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
27
 
@@ -115,13 +115,13 @@ RC_SAMPLE
115
115
  end
116
116
 
117
117
  it "should raise error if the node has a nil ps attribute and no other means to get status" do
118
- @node[:command] = {:ps => nil}
118
+ @node.automatic_attrs[:command] = {:ps => nil}
119
119
  @provider.define_resource_requirements
120
120
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
121
121
  end
122
122
 
123
123
  it "should raise error if the node has an empty ps attribute and no other means to get status" do
124
- @node[:command] = {:ps => ""}
124
+ @node.automatic_attrs[:command] = {:ps => ""}
125
125
  @provider.define_resource_requirements
126
126
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
127
127
  end
@@ -180,7 +180,7 @@ RC_SAMPLE
180
180
 
181
181
  describe "when we have a 'ps' attribute" do
182
182
  before do
183
- @node[:command] = {:ps => "ps -ax"}
183
+ @node.automatic_attrs[:command] = {:ps => "ps -ax"}
184
184
  end
185
185
 
186
186
  it "should shell_out! the node's ps command" do
@@ -21,7 +21,7 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Init, "load_current_resource" do
22
22
  before(:each) do
23
23
  @node = Chef::Node.new
24
- @node[:command] = {:ps => "ps -ef"}
24
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
27
 
@@ -93,10 +93,23 @@ PS
93
93
 
94
94
  end
95
95
 
96
+ describe "when an init command has been specified" do
97
+ before do
98
+ @new_resource.stub!(:init_command).and_return("/opt/chef-server/service/erchef")
99
+ @provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
100
+ end
101
+
102
+ it "should use the init_command if one has been specified" do
103
+ @provider.should_receive(:shell_out!).with("/opt/chef-server/service/erchef start")
104
+ @provider.start_service
105
+ end
106
+
107
+ end
108
+
96
109
  describe "when the node has not specified a ps command" do
97
110
 
98
111
  it "should raise an error if the node has a nil ps attribute" do
99
- @node[:command] = {:ps => nil}
112
+ @node.automatic_attrs[:command] = {:ps => nil}
100
113
  @provider.load_current_resource
101
114
  @provider.action = :start
102
115
  @provider.define_resource_requirements
@@ -104,7 +117,7 @@ PS
104
117
  end
105
118
 
106
119
  it "should raise an error if the node has an empty ps attribute" do
107
- @node[:command] = {:ps => ""}
120
+ @node.automatic_attrs[:command] = {:ps => ""}
108
121
  @provider.load_current_resource
109
122
  @provider.action = :start
110
123
  @provider.define_resource_requirements
@@ -209,4 +222,14 @@ RUNNING_PS
209
222
  @provider.reload_service()
210
223
  end
211
224
  end
225
+
226
+ describe "when a custom command has been specified" do
227
+ before do
228
+ @new_resource.start_command("/etc/init.d/chef startyousillysally")
229
+ end
230
+
231
+ it "should still pass all why run assertions" do
232
+ lambda { @provider.run_action(:start) }.should_not raise_error(Chef::Exceptions::Service)
233
+ end
234
+ end
212
235
  end
@@ -23,7 +23,7 @@ describe Chef::Provider::Service::Insserv do
23
23
  @node = Chef::Node.new
24
24
  @events = Chef::EventDispatch::Dispatcher.new
25
25
  @run_context = Chef::RunContext.new(@node, {}, @events)
26
- @node[:command] = {:ps => "ps -ax"}
26
+ @node.automatic_attrs[:command] = {:ps => "ps -ax"}
27
27
 
28
28
  @new_resource = Chef::Resource::Service.new("initgrediant")
29
29
  @current_resource = Chef::Resource::Service.new("initgrediant")
@@ -21,7 +21,7 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Invokercd, "load_current_resource" do
22
22
  before(:each) do
23
23
  @node = Chef::Node.new
24
- @node[:command] = {:ps => "ps -ef"}
24
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
27
 
@@ -95,14 +95,14 @@ PS
95
95
 
96
96
  describe "when the node has not specified a ps command" do
97
97
  it "should raise error if the node has a nil ps attribute and no other means to get status" do
98
- @node[:command] = {:ps => nil}
98
+ @node.automatic_attrs[:command] = {:ps => nil}
99
99
  @provider.action = :start
100
100
  @provider.define_resource_requirements
101
101
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
102
102
  end
103
103
 
104
104
  it "should raise error if the node has an empty ps attribute and no other means to get status" do
105
- @node[:command] = {:ps => ""}
105
+ @node.automatic_attrs[:command] = {:ps => ""}
106
106
  @provider.action = :start
107
107
  @provider.define_resource_requirements
108
108
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
@@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do
44
44
 
45
45
  before(:each) do
46
46
  @node = Chef::Node.new
47
- @node[:command] = {:ps => 'foo'}
47
+ @node.automatic_attrs[:command] = {:ps => 'foo'}
48
48
  @events = Chef::EventDispatch::Dispatcher.new
49
49
  @run_context = Chef::RunContext.new(@node, {}, @events)
50
50
 
@@ -21,7 +21,7 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Simple, "load_current_resource" do
22
22
  before(:each) do
23
23
  @node = Chef::Node.new
24
- @node[:command] = {:ps => "ps -ef"}
24
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
27
 
@@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ
51
51
  end
52
52
 
53
53
  it "should raise error if the node has a nil ps attribute and no other means to get status" do
54
- @node[:command] = {:ps => nil}
54
+ @node.automatic_attrs[:command] = {:ps => nil}
55
55
  @provider.define_resource_requirements
56
56
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
57
57
  end
58
58
 
59
59
  it "should raise error if the node has an empty ps attribute and no other means to get status" do
60
- @node[:command] = {:ps => ""}
60
+ @node.automatic_attrs[:command] = {:ps => ""}
61
61
  @provider.define_resource_requirements
62
62
  lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
63
63
  end
@@ -21,9 +21,9 @@ require 'spec_helper'
21
21
  describe Chef::Provider::Service::Upstart do
22
22
  before(:each) do
23
23
  @node =Chef::Node.new
24
- @node[:name] = 'upstarter'
25
- @node[:platform] = 'ubuntu'
26
- @node[:platform_version] = '9.10'
24
+ @node.name('upstarter')
25
+ @node.automatic_attrs[:platform] = 'ubuntu'
26
+ @node.automatic_attrs[:platform_version] = '9.10'
27
27
 
28
28
  @events = Chef::EventDispatch::Dispatcher.new
29
29
  @run_context = Chef::RunContext.new(@node, {}, @events)
@@ -38,7 +38,7 @@ describe Chef::Provider::Service::Upstart do
38
38
  end
39
39
 
40
40
  it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do
41
- @node[:platform_version] = '9.04'
41
+ @node.automatic_attrs[:platform_version] = '9.04'
42
42
  #Chef::Platform.stub!(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
43
43
  @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
44
44
  @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/event.d"
@@ -46,14 +46,14 @@ describe Chef::Provider::Service::Upstart do
46
46
  end
47
47
 
48
48
  it "should return /etc/init as the upstart job directory when running on Ubuntu 9.10" do
49
- @node[:platform_version] = '9.10'
49
+ @node.automatic_attrs[:platform_version] = '9.10'
50
50
  @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
51
51
  @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/init"
52
52
  @provider.instance_variable_get(:@upstart_conf_suffix).should == ".conf"
53
53
  end
54
54
 
55
55
  it "should return /etc/init as the upstart job directory by default" do
56
- @node[:platform_version] = '9000'
56
+ @node.automatic_attrs[:platform_version] = '9000'
57
57
  @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
58
58
  @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/init"
59
59
  @provider.instance_variable_get(:@upstart_conf_suffix).should == ".conf"
@@ -62,7 +62,7 @@ describe Chef::Provider::Service::Upstart do
62
62
 
63
63
  describe "load_current_resource" do
64
64
  before(:each) do
65
- @node[:command] = {:ps => "ps -ax"}
65
+ @node.automatic_attrs[:command] = {:ps => "ps -ax"}
66
66
 
67
67
  @current_resource = Chef::Resource::Service.new("rsyslog")
68
68
  Chef::Resource::Service.stub!(:new).and_return(@current_resource)
@@ -36,7 +36,7 @@ describe Chef::Provider::Service do
36
36
  @current_resource.enabled(false)
37
37
  @provider.should_receive(:enable_service).and_return(true)
38
38
  @provider.action_enable
39
- @provider.converge
39
+ @provider.set_updated_status
40
40
  @provider.new_resource.should be_updated
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ describe Chef::Provider::Service do
44
44
  @current_resource.enabled(true)
45
45
  @provider.should_not_receive(:enable_service)
46
46
  @provider.action_enable
47
- @provider.converge
47
+ @provider.set_updated_status
48
48
  @provider.new_resource.should_not be_updated
49
49
  end
50
50
  end
@@ -63,7 +63,7 @@ describe Chef::Provider::Subversion do
63
63
  "Last Changed Author: codeninja\n" +
64
64
  "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
65
65
  "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
66
- ::File.should_receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
66
+ ::File.should_receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
67
67
  ::File.should_receive(:directory?).with("/my/deploy/dir").and_return(true)
68
68
  ::Dir.should_receive(:chdir).with("/my/deploy/dir").and_yield
69
69
  @stdout.stub!(:string).and_return(example_svn_info)
@@ -26,7 +26,9 @@ describe Chef::Provider::Template do
26
26
  Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, @cookbook_repo) }
27
27
 
28
28
  @node = Chef::Node.new
29
- @cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
29
+ cl = Chef::CookbookLoader.new(@cookbook_repo)
30
+ cl.load_cookbooks
31
+ @cookbook_collection = Chef::CookbookCollection.new(cl)
30
32
  @events = Chef::EventDispatch::Dispatcher.new
31
33
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
32
34
 
@@ -45,16 +47,16 @@ describe Chef::Provider::Template do
45
47
  else
46
48
  Struct::Passwd.new("root", "x", 0, 0, "root", "/root", "/bin/bash")
47
49
  end
48
- group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
50
+ group_struct = mock("Group Ent", :name => "root", :passwd => "x", :gid => 0)
49
51
  Etc.stub!(:getpwuid).and_return(passwd_struct)
50
52
  Etc.stub!(:getgrgid).and_return(group_struct)
51
53
  end
52
54
 
53
55
  describe "when creating the template" do
54
56
 
55
- before do
56
-
57
+ before do
57
58
  end
59
+
58
60
  after do
59
61
  FileUtils.rm(@rendered_file_location) if ::File.exist?(@rendered_file_location)
60
62
  end
@@ -87,7 +89,7 @@ describe Chef::Provider::Template do
87
89
  it "creates the template with the rendered content" do
88
90
  @access_controls.stub!(:requires_changes?).and_return(true)
89
91
  @access_controls.should_receive(:set_all!)
90
- @node[:slappiness] = "a warm gun"
92
+ @node.normal[:slappiness] = "a warm gun"
91
93
  @provider.should_receive(:backup)
92
94
  @provider.run_action(:create)
93
95
  IO.read(@rendered_file_location).should == "slappiness is a warm gun"
@@ -107,12 +109,35 @@ describe Chef::Provider::Template do
107
109
  it "creates the template with the rendered content for the create if missing action" do
108
110
  @access_controls.stub!(:requires_changes?).and_return(true)
109
111
  @access_controls.should_receive(:set_all!)
110
- @node[:slappiness] = "happiness"
112
+ @node.normal[:slappiness] = "happiness"
111
113
  @provider.should_receive(:backup)
112
114
  @provider.run_action(:create_if_missing)
113
115
  IO.read(@rendered_file_location).should == "slappiness is happiness"
114
116
  @resource.should be_updated_by_last_action
115
117
  end
118
+
119
+ context "and no access control settings are set on the resource" do
120
+ context "on a Unix system" do
121
+ before do
122
+ Chef::Platform.stub!(:windows?).and_return(false)
123
+ end
124
+
125
+ it "sets access control metadata on the new resource" do
126
+ @access_controls.stub!(:requires_changes?).and_return(false)
127
+ @access_controls.should_receive(:set_all!)
128
+ @node.normal[:slappiness] = "happiness"
129
+ @provider.should_receive(:backup)
130
+ @provider.run_action(:create)
131
+ IO.read(@rendered_file_location).should == "slappiness is happiness"
132
+ @resource.should be_updated_by_last_action
133
+
134
+ # Veracity of actual data checked in functional tests
135
+ @resource.owner.should be_a_kind_of(String)
136
+ @resource.group.should be_a_kind_of(String)
137
+ @resource.mode.should be_a_kind_of(String)
138
+ end
139
+ end
140
+ end
116
141
  end
117
142
 
118
143
  describe "when the target file has the wrong content" do
@@ -121,7 +146,7 @@ describe Chef::Provider::Template do
121
146
  end
122
147
 
123
148
  it "overwrites the file with the updated content when the create action is run" do
124
- @node[:slappiness] = "a warm gun"
149
+ @node.normal[:slappiness] = "a warm gun"
125
150
  @access_controls.stub!(:requires_changes?).and_return(false)
126
151
  @access_controls.should_receive(:set_all!)
127
152
  @provider.should_receive(:backup)
@@ -144,7 +169,7 @@ describe Chef::Provider::Template do
144
169
  it "doesn't overwrite the file when the create if missing action is run" do
145
170
  @access_controls.stub!(:requires_changes?).and_return(false)
146
171
  @access_controls.should_not_receive(:set_all!)
147
- @node[:slappiness] = "a warm gun"
172
+ @node.normal[:slappiness] = "a warm gun"
148
173
  @provider.should_not_receive(:backup)
149
174
  @provider.run_action(:create_if_missing)
150
175
  IO.read(@rendered_file_location).should == "blargh"
@@ -154,7 +179,6 @@ describe Chef::Provider::Template do
154
179
 
155
180
  describe "when the target has the correct content" do
156
181
  before do
157
- Chef::ChecksumCache.instance.reset!
158
182
  File.open(@rendered_file_location, "w") { |f| f.print "slappiness is a warm gun" }
159
183
  @current_resource.checksum('4ff94a87794ed9aefe88e734df5a66fc8727a179e9496cbd88e3b5ec762a5ee9')
160
184
  @access_controls = mock("access controls")
@@ -162,7 +186,7 @@ describe Chef::Provider::Template do
162
186
  end
163
187
 
164
188
  it "does not backup the original or overwrite it" do
165
- @node[:slappiness] = "a warm gun"
189
+ @node.normal[:slappiness] = "a warm gun"
166
190
  @access_controls.stub!(:requires_changes?).and_return(false)
167
191
  @provider.should_not_receive(:backup)
168
192
  FileUtils.should_not_receive(:mv)
@@ -171,7 +195,7 @@ describe Chef::Provider::Template do
171
195
  end
172
196
 
173
197
  it "does not backup the original or overwrite it on create if missing" do
174
- @node[:slappiness] = "a warm gun"
198
+ @node.normal[:slappiness] = "a warm gun"
175
199
  @access_controls.stub!(:requires_changes?).and_return(false)
176
200
  @provider.should_not_receive(:backup)
177
201
  FileUtils.should_not_receive(:mv)
@@ -54,6 +54,12 @@ describe Chef::Provider::User::Dscl do
54
54
  @provider.should_receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
55
55
  lambda { @provider.safe_dscl("cmd /Path args") }.should raise_error(Chef::Exceptions::DsclCommandFailed)
56
56
  end
57
+
58
+ it "raises an exception when dscl reports 'eDSRecordNotFound'" do
59
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
60
+ @provider.should_receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
61
+ lambda { @provider.safe_dscl("cmd /Path args") }.should raise_error(Chef::Exceptions::DsclCommandFailed)
62
+ end
57
63
  end
58
64
 
59
65
  describe "get_free_uid" do
@@ -324,42 +330,62 @@ describe Chef::Provider::User::Dscl do
324
330
  end
325
331
 
326
332
  describe "when the user does not yet exist and chef is creating it" do
327
- before do
328
- @new_resource.comment "#mockssuck"
329
- @new_resource.gid 1001
330
- end
331
-
332
- it "creates the user, comment field, sets uid, gid, configures the home directory, sets the shell, and sets the password" do
333
- @provider.should_receive :dscl_create_user
334
- @provider.should_receive :dscl_create_comment
335
- @provider.should_receive :set_uid
336
- @provider.should_receive :dscl_set_gid
337
- @provider.should_receive :modify_home
338
- @provider.should_receive :dscl_set_shell
339
- @provider.should_receive :modify_password
340
- @provider.create_user
341
- end
333
+ context "with a numeric gid" do
334
+ before do
335
+ @new_resource.comment "#mockssuck"
336
+ @new_resource.gid 1001
337
+ end
342
338
 
343
- it "creates the user and sets the comment field" do
344
- @provider.should_receive(:safe_dscl).with("create /Users/toor").and_return(true)
345
- @provider.dscl_create_user
346
- end
347
-
348
- it "sets the comment field" do
349
- @provider.should_receive(:safe_dscl).with("create /Users/toor RealName '#mockssuck'").and_return(true)
350
- @provider.dscl_create_comment
351
- end
339
+ it "creates the user, comment field, sets uid, gid, configures the home directory, sets the shell, and sets the password" do
340
+ @provider.should_receive :dscl_create_user
341
+ @provider.should_receive :dscl_create_comment
342
+ @provider.should_receive :set_uid
343
+ @provider.should_receive :dscl_set_gid
344
+ @provider.should_receive :modify_home
345
+ @provider.should_receive :dscl_set_shell
346
+ @provider.should_receive :modify_password
347
+ @provider.create_user
348
+ end
352
349
 
353
- it "should run safe_dscl with create /Users/user PrimaryGroupID to set the users primary group" do
354
- @provider.should_receive(:safe_dscl).with("create /Users/toor PrimaryGroupID '1001'").and_return(true)
355
- @provider.dscl_set_gid
356
- end
350
+ it "creates the user and sets the comment field" do
351
+ @provider.should_receive(:safe_dscl).with("create /Users/toor").and_return(true)
352
+ @provider.dscl_create_user
353
+ end
354
+
355
+ it "sets the comment field" do
356
+ @provider.should_receive(:safe_dscl).with("create /Users/toor RealName '#mockssuck'").and_return(true)
357
+ @provider.dscl_create_comment
358
+ end
359
+
360
+ it "should run safe_dscl with create /Users/user PrimaryGroupID to set the users primary group" do
361
+ @provider.should_receive(:safe_dscl).with("create /Users/toor PrimaryGroupID '1001'").and_return(true)
362
+ @provider.dscl_set_gid
363
+ end
357
364
 
358
- it "should run safe_dscl with create /Users/user UserShell to set the users login shell" do
359
- @provider.should_receive(:safe_dscl).with("create /Users/toor UserShell '/usr/bin/false'").and_return(true)
360
- @provider.dscl_set_shell
365
+ it "should run safe_dscl with create /Users/user UserShell to set the users login shell" do
366
+ @provider.should_receive(:safe_dscl).with("create /Users/toor UserShell '/usr/bin/false'").and_return(true)
367
+ @provider.dscl_set_shell
368
+ end
361
369
  end
362
370
 
371
+ context "with a non-numeric gid" do
372
+ before do
373
+ @new_resource.comment "#mockssuck"
374
+ @new_resource.gid "newgroup"
375
+ end
376
+
377
+ it "should map the group name to a numeric ID when the group exists" do
378
+ @provider.should_receive(:safe_dscl).with("read /Groups/newgroup PrimaryGroupID").ordered.and_return("PrimaryGroupID: 1001\n")
379
+ @provider.should_receive(:safe_dscl).with("create /Users/toor PrimaryGroupID '1001'").ordered.and_return(true)
380
+ @provider.dscl_set_gid
381
+ end
382
+
383
+ it "should raise an exception when the group does not exist" do
384
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
385
+ @provider.should_receive(:shell_out).with('dscl . -read /Groups/newgroup PrimaryGroupID').and_return(shell_return)
386
+ lambda { @provider.dscl_set_gid }.should raise_error(Chef::Exceptions::GroupIDNotFound)
387
+ end
388
+ end
363
389
  end
364
390
 
365
391
  describe "when the user exists and chef is managing it" do