chef 12.0.0.alpha.1-x86-mingw32 → 12.0.0.alpha.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/application.rb +8 -1
- data/lib/chef/application/apply.rb +4 -0
- data/lib/chef/application/client.rb +7 -7
- data/lib/chef/application/solo.rb +21 -13
- data/lib/chef/chef_fs/chef_fs_data_store.rb +60 -6
- data/lib/chef/chef_fs/config.rb +78 -4
- data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +2 -2
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +76 -2
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +30 -0
- data/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +2 -1
- data/lib/chef/chef_fs/file_system.rb +0 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +5 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +73 -13
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +44 -5
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/org_entry.rb +34 -0
- data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +58 -0
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +57 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +13 -4
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/client.rb +8 -2
- data/lib/chef/config.rb +75 -57
- data/lib/chef/config_fetcher.rb +6 -21
- data/lib/chef/dsl/data_query.rb +48 -3
- data/lib/chef/dsl/platform_introspection.rb +42 -0
- data/lib/chef/dsl/reboot_pending.rb +6 -3
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +12 -0
- data/lib/chef/exceptions.rb +2 -0
- data/lib/chef/http/basic_client.rb +14 -0
- data/lib/chef/http/json_output.rb +7 -2
- data/lib/chef/knife.rb +36 -121
- data/lib/chef/knife/bootstrap.rb +68 -54
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -1
- data/lib/chef/knife/bootstrap/chef-aix.erb +5 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +70 -29
- data/lib/chef/knife/search.rb +56 -12
- data/lib/chef/knife/serve.rb +1 -1
- data/lib/chef/local_mode.rb +10 -4
- data/lib/chef/mixin/deep_merge.rb +6 -3
- data/lib/chef/mixin/shell_out.rb +33 -17
- data/lib/chef/null_logger.rb +72 -0
- data/lib/chef/platform.rb +2 -1
- data/lib/chef/platform/provider_mapping.rb +1 -1
- data/lib/chef/platform/rebooter.rb +54 -0
- data/lib/chef/provider/ifconfig.rb +15 -16
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/mount/solaris.rb +102 -64
- data/lib/chef/provider/package/aix.rb +4 -12
- data/lib/chef/provider/package/ips.rb +8 -12
- data/lib/chef/provider/package/macports.rb +4 -12
- data/lib/chef/provider/package/pacman.rb +2 -6
- data/lib/chef/provider/package/portage.rb +2 -6
- data/lib/chef/provider/package/rpm.rb +4 -12
- data/lib/chef/provider/package/solaris.rb +4 -12
- data/lib/chef/provider/reboot.rb +69 -0
- data/lib/chef/provider/service/debian.rb +10 -10
- data/lib/chef/provider/service/freebsd.rb +89 -73
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/init.rb +6 -4
- data/lib/chef/provider/service/insserv.rb +3 -3
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/simple.rb +6 -4
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +9 -9
- data/lib/chef/provider/service/upstart.rb +6 -6
- data/lib/chef/provider/subversion.rb +6 -6
- data/lib/chef/provider/user/dscl.rb +32 -28
- data/lib/chef/provider/user/windows.rb +6 -6
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +0 -1
- data/lib/chef/resource.rb +3 -5
- data/lib/chef/resource/mount.rb +9 -0
- data/lib/chef/resource/reboot.rb +48 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +25 -0
- data/lib/chef/search/query.rb +122 -14
- data/lib/chef/util/path_helper.rb +54 -6
- data/lib/chef/util/windows/net_user.rb +4 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +1 -5
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/workstation_config_loader.rb +177 -0
- data/spec/functional/http/simple_spec.rb +57 -1
- data/spec/functional/mixin/shell_out_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +51 -0
- data/spec/functional/rebooter_spec.rb +105 -0
- data/spec/functional/resource/deploy_revision_spec.rb +0 -4
- data/spec/functional/resource/file_spec.rb +26 -3
- data/spec/functional/resource/group_spec.rb +5 -3
- data/spec/functional/resource/link_spec.rb +16 -16
- data/spec/functional/resource/reboot_spec.rb +103 -0
- data/spec/integration/client/client_spec.rb +4 -8
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -2
- data/spec/integration/knife/delete_spec.rb +39 -0
- data/spec/integration/knife/deps_spec.rb +30 -20
- data/spec/integration/knife/download_spec.rb +77 -1
- data/spec/integration/knife/list_spec.rb +221 -0
- data/spec/integration/knife/raw_spec.rb +1 -1
- data/spec/integration/knife/show_spec.rb +2 -2
- data/spec/integration/knife/upload_spec.rb +154 -1
- data/spec/support/pedant/run_pedant.rb +0 -1
- data/spec/support/shared/functional/http.rb +8 -1
- data/spec/support/shared/integration/integration_helper.rb +11 -19
- data/spec/support/shared/unit/platform_introspector.rb +22 -0
- data/spec/unit/application/apply.rb +11 -1
- data/spec/unit/application/solo_spec.rb +19 -3
- data/spec/unit/chef_fs/config_spec.rb +58 -0
- data/spec/unit/config_fetcher_spec.rb +1 -3
- data/spec/unit/config_spec.rb +247 -220
- data/spec/unit/dsl/data_query_spec.rb +165 -23
- data/spec/unit/dsl/reboot_pending_spec.rb +1 -7
- data/spec/unit/encrypted_data_bag_item_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +354 -182
- data/spec/unit/knife/core/bootstrap_context_spec.rb +67 -30
- data/spec/unit/knife_spec.rb +3 -30
- data/spec/unit/mixin/deep_merge_spec.rb +14 -0
- data/spec/unit/mixin/shell_out_spec.rb +134 -64
- data/spec/unit/provider/ifconfig/debian_spec.rb +19 -9
- data/spec/unit/provider/ifconfig/redhat_spec.rb +16 -14
- data/spec/unit/provider/ifconfig_spec.rb +3 -3
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/mount/mount_spec.rb +10 -1
- data/spec/unit/provider/mount/solaris_spec.rb +185 -11
- data/spec/unit/provider/package/aix_spec.rb +5 -17
- data/spec/unit/provider/package/ips_spec.rb +8 -21
- data/spec/unit/provider/package/macports_spec.rb +12 -12
- data/spec/unit/provider/package/pacman_spec.rb +4 -12
- data/spec/unit/provider/package/portage_spec.rb +5 -15
- data/spec/unit/provider/package/rpm_spec.rb +7 -22
- data/spec/unit/provider/package/solaris_spec.rb +5 -16
- data/spec/unit/provider/service/arch_service_spec.rb +8 -14
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +457 -225
- data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
- data/spec/unit/provider/service/init_service_spec.rb +10 -10
- data/spec/unit/provider/service/insserv_service_spec.rb +3 -4
- data/spec/unit/provider/service/invokercd_service_spec.rb +8 -9
- data/spec/unit/provider/service/macosx_spec.rb +5 -5
- data/spec/unit/provider/service/simple_service_spec.rb +4 -6
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +1 -3
- data/spec/unit/provider/service/systemd_service_spec.rb +20 -20
- data/spec/unit/provider/service/upstart_service_spec.rb +15 -17
- data/spec/unit/provider/subversion_spec.rb +5 -6
- data/spec/unit/provider/user/dscl_spec.rb +2 -1
- data/spec/unit/provider/user/windows_spec.rb +7 -0
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/resource/mount_spec.rb +9 -0
- data/spec/unit/resource_spec.rb +0 -4
- data/spec/unit/rest_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +15 -0
- data/spec/unit/search/query_spec.rb +196 -40
- data/spec/unit/util/path_helper_spec.rb +111 -28
- data/spec/unit/workstation_config_loader_spec.rb +283 -0
- metadata +36 -20
- data/lib/chef/knife/bootstrap/centos5-gems.erb +0 -62
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +0 -44
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +0 -53
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +0 -48
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +0 -46
- data/spec/support/shared/integration/chef_zero_support.rb +0 -130
- data/spec/unit/knife/config_file_selection_spec.rb +0 -135
@@ -161,7 +161,6 @@ describe Chef::Provider::Service::Upstart do
|
|
161
161
|
@provider.load_current_resource
|
162
162
|
end
|
163
163
|
|
164
|
-
|
165
164
|
it "should track state when the upstart configuration file fails to load" do
|
166
165
|
File.should_receive(:exists?).and_return false
|
167
166
|
@provider.load_current_resource
|
@@ -174,19 +173,19 @@ describe Chef::Provider::Service::Upstart do
|
|
174
173
|
end
|
175
174
|
|
176
175
|
it "should run the services status command if one has been specified" do
|
177
|
-
@provider.stub(:
|
176
|
+
@provider.stub(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(0)
|
178
177
|
@current_resource.should_receive(:running).with(true)
|
179
178
|
@provider.load_current_resource
|
180
179
|
end
|
181
180
|
|
182
181
|
it "should track state when the user-provided status command fails" do
|
183
|
-
@provider.stub(:
|
182
|
+
@provider.stub(:shell_out!).and_raise(Errno::ENOENT)
|
184
183
|
@provider.load_current_resource
|
185
184
|
@provider.instance_variable_get("@command_success").should == false
|
186
185
|
end
|
187
186
|
|
188
187
|
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
|
189
|
-
@provider.stub(:
|
188
|
+
@provider.stub(:shell_out!).and_raise(Errno::ENOENT)
|
190
189
|
@current_resource.should_receive(:running).with(false)
|
191
190
|
@provider.load_current_resource
|
192
191
|
end
|
@@ -202,7 +201,6 @@ describe Chef::Provider::Service::Upstart do
|
|
202
201
|
@provider.load_current_resource.should eql(@current_resource)
|
203
202
|
end
|
204
203
|
|
205
|
-
|
206
204
|
end
|
207
205
|
|
208
206
|
describe "enable and disable service" do
|
@@ -243,18 +241,18 @@ describe Chef::Provider::Service::Upstart do
|
|
243
241
|
|
244
242
|
it "should call the start command if one is specified" do
|
245
243
|
@new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally")
|
246
|
-
@provider.should_receive(:
|
244
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
|
247
245
|
@provider.start_service()
|
248
246
|
end
|
249
247
|
|
250
248
|
it "should call '/sbin/start service_name' if no start command is specified" do
|
251
|
-
@provider.should_receive(:
|
249
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0)
|
252
250
|
@provider.start_service()
|
253
251
|
end
|
254
252
|
|
255
253
|
it "should not call '/sbin/start service_name' if it is already running" do
|
256
254
|
@current_resource.stub(:running).and_return(true)
|
257
|
-
@provider.should_not_receive(:
|
255
|
+
@provider.should_not_receive(:shell_out_with_systems_locale!)
|
258
256
|
@provider.start_service()
|
259
257
|
end
|
260
258
|
|
@@ -263,58 +261,58 @@ describe Chef::Provider::Service::Upstart do
|
|
263
261
|
@new_resource.parameters({ "OSD_ID" => "2" })
|
264
262
|
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
|
265
263
|
@provider.current_resource = @current_resource
|
266
|
-
@provider.should_receive(:
|
264
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(0)
|
267
265
|
@provider.start_service()
|
268
266
|
end
|
269
267
|
|
270
268
|
it "should call the restart command if one is specified" do
|
271
269
|
@current_resource.stub(:running).and_return(true)
|
272
270
|
@new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
|
273
|
-
@provider.should_receive(:
|
271
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
|
274
272
|
@provider.restart_service()
|
275
273
|
end
|
276
274
|
|
277
275
|
it "should call '/sbin/restart service_name' if no restart command is specified" do
|
278
276
|
@current_resource.stub(:running).and_return(true)
|
279
|
-
@provider.should_receive(:
|
277
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(0)
|
280
278
|
@provider.restart_service()
|
281
279
|
end
|
282
280
|
|
283
281
|
it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
|
284
282
|
@current_resource.stub(:running).and_return(false)
|
285
|
-
@provider.should_receive(:
|
283
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0)
|
286
284
|
@provider.restart_service()
|
287
285
|
end
|
288
286
|
|
289
287
|
it "should call the reload command if one is specified" do
|
290
288
|
@current_resource.stub(:running).and_return(true)
|
291
289
|
@new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
|
292
|
-
@provider.should_receive(:
|
290
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
|
293
291
|
@provider.reload_service()
|
294
292
|
end
|
295
293
|
|
296
294
|
it "should call '/sbin/reload service_name' if no reload command is specified" do
|
297
295
|
@current_resource.stub(:running).and_return(true)
|
298
|
-
@provider.should_receive(:
|
296
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(0)
|
299
297
|
@provider.reload_service()
|
300
298
|
end
|
301
299
|
|
302
300
|
it "should call the stop command if one is specified" do
|
303
301
|
@current_resource.stub(:running).and_return(true)
|
304
302
|
@new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
|
305
|
-
@provider.should_receive(:
|
303
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
|
306
304
|
@provider.stop_service()
|
307
305
|
end
|
308
306
|
|
309
307
|
it "should call '/sbin/stop service_name' if no stop command is specified" do
|
310
308
|
@current_resource.stub(:running).and_return(true)
|
311
|
-
@provider.should_receive(:
|
309
|
+
@provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(0)
|
312
310
|
@provider.stop_service()
|
313
311
|
end
|
314
312
|
|
315
313
|
it "should not call '/sbin/stop service_name' if it is already stopped" do
|
316
314
|
@current_resource.stub(:running).and_return(false)
|
317
|
-
@provider.should_not_receive(:
|
315
|
+
@provider.should_not_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}")
|
318
316
|
@provider.stop_service()
|
319
317
|
end
|
320
318
|
end
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
19
|
require 'spec_helper'
|
21
20
|
|
22
21
|
describe Chef::Provider::Subversion do
|
@@ -199,7 +198,7 @@ describe Chef::Provider::Subversion do
|
|
199
198
|
it "runs an export with the --force option" do
|
200
199
|
::File.stub(:directory?).with("/my/deploy").and_return(true)
|
201
200
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
202
|
-
@provider.should_receive(:
|
201
|
+
@provider.should_receive(:shell_out!).with(command: expected_cmd)
|
203
202
|
@provider.run_action(:force_export)
|
204
203
|
@resource.should be_updated
|
205
204
|
end
|
@@ -207,7 +206,7 @@ describe Chef::Provider::Subversion do
|
|
207
206
|
it "runs the checkout command for action_checkout" do
|
208
207
|
::File.stub(:directory?).with("/my/deploy").and_return(true)
|
209
208
|
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
210
|
-
@provider.should_receive(:
|
209
|
+
@provider.should_receive(:shell_out!).with(command: expected_cmd)
|
211
210
|
@provider.run_action(:checkout)
|
212
211
|
@resource.should be_updated
|
213
212
|
end
|
@@ -231,7 +230,7 @@ describe Chef::Provider::Subversion do
|
|
231
230
|
@resource.user "whois"
|
232
231
|
@resource.group "thisis"
|
233
232
|
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
234
|
-
@provider.should_receive(:
|
233
|
+
@provider.should_receive(:shell_out!).with(command: expected_cmd, user: "whois", group: "thisis")
|
235
234
|
@provider.run_action(:checkout)
|
236
235
|
@resource.should be_updated
|
237
236
|
end
|
@@ -256,7 +255,7 @@ describe Chef::Provider::Subversion do
|
|
256
255
|
@provider.stub(:find_current_revision).and_return("11410")
|
257
256
|
@provider.stub(:current_revision_matches_target_revision?).and_return(false)
|
258
257
|
expected_cmd = "svn update -q -r12345 /my/deploy/dir"
|
259
|
-
@provider.should_receive(:
|
258
|
+
@provider.should_receive(:shell_out!).with(command: expected_cmd)
|
260
259
|
@provider.run_action(:sync)
|
261
260
|
@resource.should be_updated
|
262
261
|
end
|
@@ -273,7 +272,7 @@ describe Chef::Provider::Subversion do
|
|
273
272
|
it "runs the export_command on action_export" do
|
274
273
|
::File.stub(:directory?).with("/my/deploy").and_return(true)
|
275
274
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
276
|
-
@provider.should_receive(:
|
275
|
+
@provider.should_receive(:shell_out!).with(command: expected_cmd)
|
277
276
|
@provider.run_action(:export)
|
278
277
|
@resource.should be_updated
|
279
278
|
end
|
@@ -376,6 +376,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
376
376
|
let(:user_plist_file) { nil }
|
377
377
|
|
378
378
|
before do
|
379
|
+
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
379
380
|
provider.should_receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
380
381
|
if user_plist_file.nil?
|
381
382
|
ShellCmdResult.new('Can not find the file', 'Sorry!!', 1)
|
@@ -715,7 +716,6 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
715
716
|
provider.should_receive(:read_user_info)
|
716
717
|
provider.should_receive(:dscl_set)
|
717
718
|
provider.should_receive(:sleep).with(3)
|
718
|
-
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
719
719
|
provider.should_receive(:save_user_info)
|
720
720
|
provider.set_password
|
721
721
|
end
|
@@ -822,6 +822,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
822
822
|
|
823
823
|
describe "when the user exists" do
|
824
824
|
before do
|
825
|
+
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
825
826
|
provider.should_receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
826
827
|
ShellCmdResult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/10.9.plist.xml")), "", 0)
|
827
828
|
end
|
@@ -42,6 +42,12 @@ describe Chef::Provider::User::Windows do
|
|
42
42
|
@provider.current_resource = @current_resource
|
43
43
|
end
|
44
44
|
|
45
|
+
it "creates a net_user object with the provided username" do
|
46
|
+
@new_resource.username "not-monkey"
|
47
|
+
expect(Chef::Util::Windows::NetUser).to receive(:new).with("not-monkey")
|
48
|
+
@provider = Chef::Provider::User::Windows.new(@new_resource, @run_context)
|
49
|
+
end
|
50
|
+
|
45
51
|
describe "when comparing the user's current attributes to the desired attributes" do
|
46
52
|
before do
|
47
53
|
@new_resource.comment "Adam Jacob"
|
@@ -53,6 +59,7 @@ describe Chef::Provider::User::Windows do
|
|
53
59
|
|
54
60
|
@provider.current_resource = @new_resource.clone
|
55
61
|
end
|
62
|
+
|
56
63
|
describe "and the attributes match" do
|
57
64
|
it "doesn't set the comment field to be updated" do
|
58
65
|
@provider.set_options.should_not have_key(:full_name)
|
@@ -30,14 +30,14 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "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(:
|
33
|
+
@provider.run_action(:run)
|
34
34
|
$evil_global_evil_laugh.should == :mwahahaha
|
35
35
|
@new_resource.should be_updated
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should call the block and flat the resource as updated - even in whyrun" do
|
39
39
|
Chef::Config[:why_run] = true
|
40
|
-
@provider.run_action(:
|
40
|
+
@provider.run_action(:run)
|
41
41
|
$evil_global_evil_laugh.should == :mwahahaha
|
42
42
|
@new_resource.should be_updated
|
43
43
|
Chef::Config[:why_run] = false
|
@@ -53,6 +53,15 @@ describe Chef::Resource::Mount do
|
|
53
53
|
@resource.device.should eql("/dev/sdb3")
|
54
54
|
end
|
55
55
|
|
56
|
+
it "should set fsck_device to '-' by default" do
|
57
|
+
@resource.fsck_device.should eql('-')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should allow you to set the fsck_device attribute" do
|
61
|
+
@resource.fsck_device "/dev/rdsk/sdb3"
|
62
|
+
@resource.fsck_device.should eql("/dev/rdsk/sdb3")
|
63
|
+
end
|
64
|
+
|
56
65
|
it "should allow you to set the fstype attribute" do
|
57
66
|
@resource.fstype "nfs"
|
58
67
|
@resource.fstype.should eql("nfs")
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -421,10 +421,6 @@ describe Chef::Resource do
|
|
421
421
|
|
422
422
|
end
|
423
423
|
|
424
|
-
it "supports accessing the node via the @node instance variable [DEPRECATED]" do
|
425
|
-
@resource.instance_variable_get(:@node).inspect.should == @node.inspect
|
426
|
-
end
|
427
|
-
|
428
424
|
it "runs an action by finding its provider, loading the current resource and then running the action" do
|
429
425
|
pending
|
430
426
|
end
|
data/spec/unit/rest_spec.rb
CHANGED
@@ -540,7 +540,7 @@ describe Chef::REST do
|
|
540
540
|
let(:request_mock) { {} }
|
541
541
|
|
542
542
|
let(:http_response) do
|
543
|
-
http_response = Net::HTTPSuccess.new("1.1",200, "it-works")
|
543
|
+
http_response = Net::HTTPSuccess.new("1.1",'200', "it-works")
|
544
544
|
|
545
545
|
http_response.stub(:read_body)
|
546
546
|
http_response.should_not_receive(:body)
|
@@ -134,4 +134,19 @@ describe Chef::RunContext do
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
+
describe "handling reboot requests" do
|
138
|
+
let(:expected) do
|
139
|
+
{ :reason => "spec tests require a reboot" }
|
140
|
+
end
|
141
|
+
|
142
|
+
it "stores and deletes the reboot request" do
|
143
|
+
@run_context.request_reboot(expected)
|
144
|
+
expect(@run_context.reboot_info).to eq(expected)
|
145
|
+
expect(@run_context.reboot_requested?).to be_true
|
146
|
+
|
147
|
+
@run_context.cancel_reboot
|
148
|
+
expect(@run_context.reboot_info).to eq({})
|
149
|
+
expect(@run_context.reboot_requested?).to be_false
|
150
|
+
end
|
151
|
+
end
|
137
152
|
end
|
@@ -20,80 +20,236 @@ require 'spec_helper'
|
|
20
20
|
require 'chef/search/query'
|
21
21
|
|
22
22
|
describe Chef::Search::Query do
|
23
|
-
|
24
|
-
|
25
|
-
Chef::REST.stub(:new).and_return(@rest)
|
26
|
-
@query = Chef::Search::Query.new
|
27
|
-
end
|
23
|
+
let(:rest) { double("Chef::REST") }
|
24
|
+
let(:query) { Chef::Search::Query.new }
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
shared_context "filtered search" do
|
27
|
+
let(:query_string) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000" }
|
28
|
+
let(:server_url) { "https://api.opscode.com/organizations/opscode/nodes" }
|
29
|
+
let(:args) { { filter_key => filter_hash } }
|
30
|
+
let(:filter_hash) {
|
31
|
+
{
|
32
|
+
'env' => [ 'chef_environment' ],
|
33
|
+
'ruby_plat' => [ 'languages', 'ruby', 'platform' ]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
let(:response) {
|
37
|
+
{
|
32
38
|
"rows" => [
|
33
|
-
{ "
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
{ "url" => "#{server_url}/my-name-is-node",
|
40
|
+
"data" => {
|
41
|
+
"env" => "elysium",
|
42
|
+
"ruby_plat" => "nudibranch"
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{ "url" => "#{server_url}/my-name-is-jonas",
|
46
|
+
"data" => {
|
47
|
+
"env" => "hades",
|
48
|
+
"ruby_plat" => "i386-mingw32"
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{ "url" => "#{server_url}/my-name-is-flipper",
|
52
|
+
"data" => {
|
53
|
+
"env" => "elysium",
|
54
|
+
"ruby_plat" => "centos"
|
55
|
+
}
|
56
|
+
},
|
57
|
+
{ "url" => "#{server_url}/my-name-is-butters",
|
58
|
+
"data" => {
|
59
|
+
"env" => "moon",
|
60
|
+
"ruby_plat" => "solaris2",
|
61
|
+
}
|
62
|
+
}
|
37
63
|
],
|
38
64
|
"start" => 0,
|
39
65
|
"total" => 4
|
40
66
|
}
|
41
|
-
|
42
|
-
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
before(:each) do
|
71
|
+
Chef::REST.stub(:new).and_return(rest)
|
72
|
+
rest.stub(:get_rest).and_return(response)
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "search" do
|
76
|
+
let(:response) { {
|
77
|
+
"rows" => [
|
78
|
+
{ "name" => "my-name-is-node",
|
79
|
+
"chef_environment" => "elysium",
|
80
|
+
"platform" => "rhel",
|
81
|
+
"automatic" => {
|
82
|
+
"languages" => {
|
83
|
+
"ruby" => {
|
84
|
+
"platform" => "nudibranch",
|
85
|
+
"version" => "1.9.3",
|
86
|
+
"target" => "ming-the-merciless"
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
},
|
91
|
+
{ "name" => "my-name-is-jonas",
|
92
|
+
"chef_environment" => "hades",
|
93
|
+
"platform" => "rhel",
|
94
|
+
"automatic" => {
|
95
|
+
"languages" => {
|
96
|
+
"ruby" => {
|
97
|
+
"platform" => "i386-mingw32",
|
98
|
+
"version" => "1.9.3",
|
99
|
+
"target" => "bilbo"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
},
|
104
|
+
{ "name" => "my-name-is-flipper",
|
105
|
+
"chef_environment" => "elysium",
|
106
|
+
"platform" => "rhel",
|
107
|
+
"automatic" => {
|
108
|
+
"languages" => {
|
109
|
+
"ruby" => {
|
110
|
+
"platform" => "centos",
|
111
|
+
"version" => "2.0.0",
|
112
|
+
"target" => "uno"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
},
|
117
|
+
{ "name" => "my-name-is-butters",
|
118
|
+
"chef_environment" => "moon",
|
119
|
+
"platform" => "rhel",
|
120
|
+
"automatic" => {
|
121
|
+
"languages" => {
|
122
|
+
"ruby" => {
|
123
|
+
"platform" => "solaris2",
|
124
|
+
"version" => "2.1.2",
|
125
|
+
"target" => "random"
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
},
|
130
|
+
],
|
131
|
+
"start" => 0,
|
132
|
+
"total" => 4
|
133
|
+
} }
|
43
134
|
|
44
135
|
it "should accept a type as the first argument" do
|
45
|
-
lambda {
|
46
|
-
lambda {
|
47
|
-
lambda {
|
136
|
+
lambda { query.search("node") }.should_not raise_error
|
137
|
+
lambda { query.search(:node) }.should_not raise_error
|
138
|
+
lambda { query.search(Hash.new) }.should raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/)
|
48
139
|
end
|
49
140
|
|
50
141
|
it "should query for every object of a type by default" do
|
51
|
-
|
52
|
-
|
53
|
-
@query.search(:foo)
|
142
|
+
rest.should_receive(:get_rest).with("search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000").and_return(response)
|
143
|
+
query.search(:node)
|
54
144
|
end
|
55
145
|
|
56
146
|
it "should allow a custom query" do
|
57
|
-
|
58
|
-
|
59
|
-
@query.search(:foo, "gorilla:dundee")
|
147
|
+
rest.should_receive(:get_rest).with("search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000").and_return(response)
|
148
|
+
query.search(:node, "platform:rhel")
|
60
149
|
end
|
61
150
|
|
62
151
|
it "should let you set a sort order" do
|
63
|
-
|
64
|
-
|
65
|
-
@query.search(:foo, "gorilla:dundee", "id desc")
|
152
|
+
rest.should_receive(:get_rest).with("search/node?q=platform:rhel&sort=id%20desc&start=0&rows=1000").and_return(response)
|
153
|
+
query.search(:node, "platform:rhel", "id desc")
|
66
154
|
end
|
67
155
|
|
68
156
|
it "should let you set a starting object" do
|
69
|
-
|
70
|
-
|
71
|
-
@query.search(:foo, "gorilla:dundee", "id desc", 2)
|
157
|
+
rest.should_receive(:get_rest).with("search/node?q=platform:rhel&sort=id%20desc&start=2&rows=1000").and_return(response)
|
158
|
+
query.search(:node, "platform:rhel", "id desc", 2)
|
72
159
|
end
|
73
160
|
|
74
161
|
it "should let you set how many rows to return" do
|
75
|
-
|
76
|
-
|
77
|
-
|
162
|
+
rest.should_receive(:get_rest).with("search/node?q=platform:rhel&sort=id%20desc&start=2&rows=40").and_return(response)
|
163
|
+
query.search(:node, "platform:rhel", "id desc", 2, 40)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should throw an exception if you pass to many options" do
|
167
|
+
lambda { query.search(:node, "platform:rhel", "id desc", 2, 40, "wrong") }
|
168
|
+
.should raise_error(Chef::Exceptions::InvalidSearchQuery, "Too many arguments! (4 for <= 3)")
|
78
169
|
end
|
79
170
|
|
80
171
|
it "should return the raw rows, start, and total if no block is passed" do
|
81
|
-
rows, start, total =
|
82
|
-
rows.should equal(
|
83
|
-
start.should equal(
|
84
|
-
total.should equal(
|
172
|
+
rows, start, total = query.search(:node)
|
173
|
+
rows.should equal(response["rows"])
|
174
|
+
start.should equal(response["start"])
|
175
|
+
total.should equal(response["total"])
|
85
176
|
end
|
86
177
|
|
87
178
|
it "should call a block for each object in the response" do
|
88
179
|
@call_me = double("blocky")
|
89
|
-
|
90
|
-
|
180
|
+
response["rows"].each { |r| @call_me.should_receive(:do).with(r) }
|
181
|
+
query.search(:node) { |r| @call_me.do(r) }
|
91
182
|
end
|
92
183
|
|
93
184
|
it "should page through the responses" do
|
94
185
|
@call_me = double("blocky")
|
95
|
-
|
96
|
-
|
186
|
+
response["rows"].each { |r| @call_me.should_receive(:do).with(r) }
|
187
|
+
query.search(:node, "*:*", nil, 0, 1) { |r| @call_me.do(r) }
|
188
|
+
end
|
189
|
+
|
190
|
+
context "when :filter_result is provided as a result" do
|
191
|
+
include_context "filtered search" do
|
192
|
+
let(:filter_key) { :filter_result }
|
193
|
+
|
194
|
+
before(:each) do
|
195
|
+
rest.should_receive(:post_rest).with(query_string, args[filter_key]).and_return(response)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should return start" do
|
199
|
+
start = query.search(:node, "platform:rhel", args)[1]
|
200
|
+
start.should == response['start']
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should return total" do
|
204
|
+
total = query.search(:node, "platform:rhel", args)[2]
|
205
|
+
total.should == response['total']
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should return rows with the filter applied" do
|
209
|
+
results = query.search(:node, "platform:rhel", args)[0]
|
210
|
+
|
211
|
+
results.each_with_index do |result, idx|
|
212
|
+
expected = response["rows"][idx]
|
213
|
+
|
214
|
+
result.should have_key("url")
|
215
|
+
result["url"].should == expected["url"]
|
216
|
+
|
217
|
+
result.should have_key("data")
|
218
|
+
filter_hash.keys.each do |filter_key|
|
219
|
+
result["data"].should have_key(filter_key)
|
220
|
+
result["data"][filter_key].should == expected["data"][filter_key]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe "#partial_search" do
|
230
|
+
include_context "filtered search" do
|
231
|
+
let(:filter_key) { :keys }
|
232
|
+
|
233
|
+
it "should emit a deprecation warning" do
|
234
|
+
# partial_search calls search, so we'll stub search to return empty
|
235
|
+
query.stub(:search).and_return( [ [], 0, 0 ] )
|
236
|
+
Chef::Log.should_receive(:warn).with("DEPRECATED: The 'partial_search' api is deprecated, please use the search api with 'filter_result'")
|
237
|
+
query.partial_search(:node, "platform:rhel", args)
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should return an array of filtered hashes" do
|
241
|
+
rest.should_receive(:post_rest).with(query_string, args[filter_key]).and_return(response)
|
242
|
+
results = query.partial_search(:node, "platform:rhel", args)
|
243
|
+
|
244
|
+
results.each_with_index do |result, idx|
|
245
|
+
expected = response["rows"][idx]
|
246
|
+
|
247
|
+
filter_hash.keys.each do |filter_key|
|
248
|
+
result.should have_key(filter_key)
|
249
|
+
result[filter_key].should == expected["data"][filter_key]
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
97
253
|
end
|
98
254
|
end
|
99
255
|
end
|