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
@@ -59,7 +59,6 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
|
|
59
59
|
let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new }
|
60
60
|
let(:run_context) { Chef::RunContext.new(node, {}, event_dispatch) }
|
61
61
|
|
62
|
-
|
63
62
|
# These tests use git's bundle feature, which is a way to export an entire
|
64
63
|
# git repo (or subset of commits) as a single file.
|
65
64
|
#
|
@@ -799,7 +798,6 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
|
|
799
798
|
deploy_to_latest_with_callback_tracking.run_action(:deploy)
|
800
799
|
end
|
801
800
|
|
802
|
-
|
803
801
|
let(:deploy_that_fails) do
|
804
802
|
resource = deploy_to_latest_rev.dup
|
805
803
|
errant_callback = lambda {|x| raise Exception, "I am a failed deploy" }
|
@@ -882,5 +880,3 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
|
|
882
880
|
|
883
881
|
end
|
884
882
|
end
|
885
|
-
|
886
|
-
|
@@ -24,12 +24,18 @@ describe Chef::Resource::File do
|
|
24
24
|
let(:file_base) { "file_spec" }
|
25
25
|
let(:expected_content) { "Don't fear the ruby." }
|
26
26
|
|
27
|
-
def create_resource
|
27
|
+
def create_resource(opts={})
|
28
28
|
events = Chef::EventDispatch::Dispatcher.new
|
29
29
|
node = Chef::Node.new
|
30
30
|
run_context = Chef::RunContext.new(node, {}, events)
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
use_path = if opts[:use_relative_path]
|
33
|
+
File.basename(path)
|
34
|
+
else
|
35
|
+
path
|
36
|
+
end
|
37
|
+
|
38
|
+
Chef::Resource::File.new(use_path, run_context)
|
33
39
|
end
|
34
40
|
|
35
41
|
let(:resource) do
|
@@ -42,6 +48,10 @@ describe Chef::Resource::File do
|
|
42
48
|
create_resource
|
43
49
|
end
|
44
50
|
|
51
|
+
let(:resource_with_relative_path) do
|
52
|
+
create_resource(:use_relative_path => true)
|
53
|
+
end
|
54
|
+
|
45
55
|
let(:unmanaged_content) do
|
46
56
|
"This is file content that is not managed by chef"
|
47
57
|
end
|
@@ -74,6 +84,19 @@ describe Chef::Resource::File do
|
|
74
84
|
end
|
75
85
|
end
|
76
86
|
|
87
|
+
# github issue 1842.
|
88
|
+
describe "when running action :create on a relative path" do
|
89
|
+
before do
|
90
|
+
resource_with_relative_path.run_action(:create)
|
91
|
+
end
|
92
|
+
|
93
|
+
context "and the file exists" do
|
94
|
+
it "should run without an exception" do
|
95
|
+
resource_with_relative_path.run_action(:create)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
77
100
|
describe "when running action :touch" do
|
78
101
|
context "and the target file does not exist" do
|
79
102
|
before do
|
@@ -40,6 +40,11 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
|
|
40
40
|
when "windows"
|
41
41
|
user_sid = sid_string_from_user(user)
|
42
42
|
user_sid.nil? ? false : Chef::Util::Windows::NetGroup.new(group_name).local_get_members.include?(user_sid)
|
43
|
+
when "mac_os_x"
|
44
|
+
membership_info = shell_out("dscl . -read /Groups/#{group_name}").stdout
|
45
|
+
members = membership_info.split(" ")
|
46
|
+
members.shift # Get rid of GroupMembership: string
|
47
|
+
members.include?(user)
|
43
48
|
else
|
44
49
|
Etc::getgrnam(group_name).mem.include?(user)
|
45
50
|
end
|
@@ -420,6 +425,3 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
|
|
420
425
|
end
|
421
426
|
end
|
422
427
|
end
|
423
|
-
|
424
|
-
|
425
|
-
|
@@ -72,8 +72,8 @@ describe Chef::Resource::Link do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
76
|
-
|
75
|
+
def paths_eql?(path1, path2)
|
76
|
+
Chef::Util::PathHelper.paths_eql?(path1, path2)
|
77
77
|
end
|
78
78
|
|
79
79
|
def symlink(a, b)
|
@@ -180,7 +180,7 @@ describe Chef::Resource::Link do
|
|
180
180
|
|
181
181
|
it 'links to the target file' do
|
182
182
|
symlink?(target_file).should be_true
|
183
|
-
readlink(target_file).should
|
183
|
+
paths_eql?(readlink(target_file), to).should be_true
|
184
184
|
end
|
185
185
|
it 'marks the resource updated' do
|
186
186
|
resource.should be_updated
|
@@ -201,7 +201,7 @@ describe Chef::Resource::Link do
|
|
201
201
|
|
202
202
|
it 'leaves the file linked' do
|
203
203
|
symlink?(target_file).should be_true
|
204
|
-
readlink(target_file).should
|
204
|
+
paths_eql?(readlink(target_file), to).should be_true
|
205
205
|
end
|
206
206
|
it 'does not mark the resource updated' do
|
207
207
|
resource.should_not be_updated
|
@@ -279,7 +279,7 @@ describe Chef::Resource::Link do
|
|
279
279
|
before(:each) do
|
280
280
|
symlink(to, target_file)
|
281
281
|
symlink?(target_file).should be_true
|
282
|
-
readlink(target_file).should
|
282
|
+
paths_eql?(readlink(target_file), to).should be_true
|
283
283
|
end
|
284
284
|
include_context 'create symbolic link is noop'
|
285
285
|
include_context 'delete succeeds'
|
@@ -294,7 +294,7 @@ describe Chef::Resource::Link do
|
|
294
294
|
File.open(@other_target, 'w') { |file| file.write('eek') }
|
295
295
|
symlink(@other_target, target_file)
|
296
296
|
symlink?(target_file).should be_true
|
297
|
-
readlink(target_file)
|
297
|
+
paths_eql?(readlink(target_file), @other_target).should be_true
|
298
298
|
end
|
299
299
|
after(:each) do
|
300
300
|
File.delete(@other_target)
|
@@ -311,7 +311,7 @@ describe Chef::Resource::Link do
|
|
311
311
|
nonexistent = File.join(test_file_dir, make_tmpname('nonexistent_spec'))
|
312
312
|
symlink(nonexistent, target_file)
|
313
313
|
symlink?(target_file).should be_true
|
314
|
-
readlink(target_file).should
|
314
|
+
paths_eql?(readlink(target_file), nonexistent).should be_true
|
315
315
|
end
|
316
316
|
include_context 'create symbolic link succeeds'
|
317
317
|
include_context 'delete succeeds'
|
@@ -393,7 +393,7 @@ describe Chef::Resource::Link do
|
|
393
393
|
File.open(@other_target, "w") { |file| file.write("eek") }
|
394
394
|
symlink(@other_target, to)
|
395
395
|
symlink?(to).should be_true
|
396
|
-
readlink(to)
|
396
|
+
paths_eql?(readlink(to), @other_target).should be_true
|
397
397
|
end
|
398
398
|
after(:each) do
|
399
399
|
File.delete(@other_target)
|
@@ -408,7 +408,7 @@ describe Chef::Resource::Link do
|
|
408
408
|
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
|
409
409
|
symlink(@other_target, to)
|
410
410
|
symlink?(to).should be_true
|
411
|
-
readlink(to)
|
411
|
+
paths_eql?(readlink(to), @other_target).should be_true
|
412
412
|
end
|
413
413
|
context 'and the link does not yet exist' do
|
414
414
|
include_context 'create symbolic link succeeds'
|
@@ -441,7 +441,7 @@ describe Chef::Resource::Link do
|
|
441
441
|
before(:each) do
|
442
442
|
symlink(to, target_file)
|
443
443
|
symlink?(target_file).should be_true
|
444
|
-
readlink(target_file).should
|
444
|
+
paths_eql?(readlink(target_file), to).should be_true
|
445
445
|
end
|
446
446
|
include_context 'create symbolic link is noop'
|
447
447
|
include_context 'delete succeeds'
|
@@ -450,7 +450,7 @@ describe Chef::Resource::Link do
|
|
450
450
|
before(:each) do
|
451
451
|
symlink(absolute_to, target_file)
|
452
452
|
symlink?(target_file).should be_true
|
453
|
-
readlink(target_file).should
|
453
|
+
paths_eql?(readlink(target_file), absolute_to).should be_true
|
454
454
|
end
|
455
455
|
include_context 'create symbolic link succeeds'
|
456
456
|
include_context 'delete succeeds'
|
@@ -478,7 +478,7 @@ describe Chef::Resource::Link do
|
|
478
478
|
before(:each) do
|
479
479
|
symlink(to, target_file)
|
480
480
|
symlink?(target_file).should be_true
|
481
|
-
readlink(target_file).should
|
481
|
+
paths_eql?(readlink(target_file), to).should be_true
|
482
482
|
end
|
483
483
|
include_context 'create hard link succeeds'
|
484
484
|
it_behaves_like 'delete errors out'
|
@@ -552,7 +552,7 @@ describe Chef::Resource::Link do
|
|
552
552
|
File.open(@other_target, "w") { |file| file.write("eek") }
|
553
553
|
symlink(@other_target, to)
|
554
554
|
symlink?(to).should be_true
|
555
|
-
readlink(to)
|
555
|
+
paths_eql?(readlink(to), @other_target).should be_true
|
556
556
|
end
|
557
557
|
after(:each) do
|
558
558
|
File.delete(@other_target)
|
@@ -564,7 +564,7 @@ describe Chef::Resource::Link do
|
|
564
564
|
# OS X gets angry about this sort of link. Bug in OS X, IMO.
|
565
565
|
pending('OS X/FreeBSD/AIX symlink? and readlink working on hard links to symlinks', :if => (os_x? or freebsd? or aix?)) do
|
566
566
|
symlink?(target_file).should be_true
|
567
|
-
readlink(target_file)
|
567
|
+
paths_eql?(readlink(target_file), @other_target).should be_true
|
568
568
|
end
|
569
569
|
end
|
570
570
|
include_context 'delete is noop'
|
@@ -575,7 +575,7 @@ describe Chef::Resource::Link do
|
|
575
575
|
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
|
576
576
|
symlink(@other_target, to)
|
577
577
|
symlink?(to).should be_true
|
578
|
-
readlink(to)
|
578
|
+
paths_eql?(readlink(to), @other_target).should be_true
|
579
579
|
end
|
580
580
|
context 'and the link does not yet exist' do
|
581
581
|
it 'links to the target file' do
|
@@ -588,7 +588,7 @@ describe Chef::Resource::Link do
|
|
588
588
|
File.exists?(target_file).should be_false
|
589
589
|
end
|
590
590
|
symlink?(target_file).should be_true
|
591
|
-
readlink(target_file)
|
591
|
+
paths_eql?(readlink(target_file), @other_target).should be_true
|
592
592
|
end
|
593
593
|
end
|
594
594
|
include_context 'delete is noop'
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Chris Doherty <cdoherty@getchef.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef, 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::Resource::Reboot do
|
22
|
+
|
23
|
+
let(:expected) do
|
24
|
+
{
|
25
|
+
:delay_mins => 5,
|
26
|
+
:requested_by => "reboot resource functional test",
|
27
|
+
:reason => "reboot resource spec test"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_resource
|
32
|
+
node = Chef::Node.new
|
33
|
+
events = Chef::EventDispatch::Dispatcher.new
|
34
|
+
run_context = Chef::RunContext.new(node, {}, events)
|
35
|
+
resource = Chef::Resource::Reboot.new(expected[:requested_by], run_context)
|
36
|
+
resource.delay_mins(expected[:delay_mins])
|
37
|
+
resource.reason(expected[:reason])
|
38
|
+
resource
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:resource) do
|
42
|
+
create_resource
|
43
|
+
end
|
44
|
+
|
45
|
+
shared_context 'testing run context modification' do
|
46
|
+
def test_reboot_action(resource)
|
47
|
+
reboot_info = resource.run_context.reboot_info
|
48
|
+
expect(reboot_info.keys.sort).to eq([:delay_mins, :reason, :requested_by, :timestamp])
|
49
|
+
expect(reboot_info[:delay_mins]).to eq(expected[:delay_mins])
|
50
|
+
expect(reboot_info[:reason]).to eq(expected[:reason])
|
51
|
+
expect(reboot_info[:requested_by]).to eq(expected[:requested_by])
|
52
|
+
|
53
|
+
expect(resource.run_context.reboot_requested?).to be_true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# the currently defined behavior for multiple calls to this resource is "last one wins."
|
58
|
+
describe 'the request_reboot_on_successful_run action' do
|
59
|
+
include_context 'testing run context modification'
|
60
|
+
|
61
|
+
before do
|
62
|
+
resource.run_action(:request_reboot)
|
63
|
+
end
|
64
|
+
|
65
|
+
after do
|
66
|
+
resource.run_context.cancel_reboot
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have modified the run context correctly' do
|
70
|
+
test_reboot_action(resource)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'the reboot_interrupt_run action' do
|
75
|
+
include_context 'testing run context modification'
|
76
|
+
|
77
|
+
after do
|
78
|
+
resource.run_context.cancel_reboot
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should have modified the run context correctly' do
|
82
|
+
# this doesn't actually test the flow of Chef::Client#do_run, unfortunately.
|
83
|
+
expect {
|
84
|
+
resource.run_action(:reboot_now)
|
85
|
+
}.to throw_symbol(:end_client_run_early)
|
86
|
+
|
87
|
+
test_reboot_action(resource)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "the cancel action" do
|
92
|
+
before do
|
93
|
+
resource.run_context.request_reboot(expected)
|
94
|
+
resource.run_action(:cancel)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should have cleared the reboot request' do
|
98
|
+
# arguably we shouldn't be querying RunContext's internal data directly.
|
99
|
+
expect(resource.run_context.reboot_info).to eq({})
|
100
|
+
expect(resource.run_context.reboot_requested?).to be_false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -33,17 +33,17 @@ EOM
|
|
33
33
|
|
34
34
|
context 'and no config file' do
|
35
35
|
it 'should complete with success when cwd is just above cookbooks and paths are not specified' do
|
36
|
-
result = shell_out("#{chef_client} -z -o 'x::default' --config
|
36
|
+
result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to(''))
|
37
37
|
result.error!
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should complete with success when cwd is below cookbooks and paths are not specified' do
|
41
|
-
result = shell_out("#{chef_client} -z -o 'x::default' --config
|
41
|
+
result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to('cookbooks/x'))
|
42
42
|
result.error!
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should fail when cwd is below high above and paths are not specified' do
|
46
|
-
result = shell_out("#{chef_client} -z -o 'x::default' --config
|
46
|
+
result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => File.expand_path('..', path_to('')))
|
47
47
|
result.exitstatus.should == 1
|
48
48
|
end
|
49
49
|
end
|
@@ -52,15 +52,11 @@ EOM
|
|
52
52
|
before { file '.chef/knife.rb', 'xxx.xxx' }
|
53
53
|
|
54
54
|
it 'should load .chef/knife.rb when -z is specified' do
|
55
|
-
result = shell_out("#{chef_client} -z -o 'x::default'
|
55
|
+
result = shell_out("#{chef_client} -z -o 'x::default'", :cwd => path_to(''))
|
56
56
|
# FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass
|
57
57
|
result.stdout.should include("xxx")
|
58
58
|
end
|
59
59
|
|
60
|
-
it 'fails to load .chef/knife.rb when -z is specified and --config-file-jail does not include the .chef/knife.rb' do
|
61
|
-
result = shell_out("#{chef_client} -z -o 'x::default' --config-file-jail \"#{path_to('roles')}\"", :cwd => path_to(''))
|
62
|
-
result.error!
|
63
|
-
end
|
64
60
|
end
|
65
61
|
|
66
62
|
it "should complete with success" do
|
@@ -76,7 +76,7 @@ END_CLIENT_RB
|
|
76
76
|
|
77
77
|
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
|
78
78
|
|
79
|
-
let(:chef_client_cmd) { %Q[chef-client -c "#{path_to('config/client.rb')}" -lwarn] }
|
79
|
+
let(:chef_client_cmd) { %Q[ruby #{chef_dir}/chef-client -c "#{path_to('config/client.rb')}" -lwarn] }
|
80
80
|
|
81
81
|
after do
|
82
82
|
FileUtils.rm_rf(cache_path)
|
@@ -62,6 +62,7 @@ END_VALIDATION_PEM
|
|
62
62
|
end
|
63
63
|
|
64
64
|
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
|
65
|
+
let(:knife) { "ruby #{chef_dir}/knife" }
|
65
66
|
|
66
67
|
let(:knife_config_flag) { "-c '#{path_to("config/knife.rb")}'" }
|
67
68
|
|
@@ -88,7 +89,7 @@ END_CLIENT_RB
|
|
88
89
|
end
|
89
90
|
|
90
91
|
it "successfully uploads a cookbook" do
|
91
|
-
shell_out!("knife cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
|
92
|
+
shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
|
92
93
|
versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8900").get("/cookbooks/apache2", "accept" => "application/json")
|
93
94
|
versions_list = Chef::JSONCompat.from_json(versions_list_json)
|
94
95
|
versions_list["apache2"]["versions"].should_not be_empty
|
@@ -96,7 +97,7 @@ END_CLIENT_RB
|
|
96
97
|
|
97
98
|
context "and the cookbook has been uploaded to the server" do
|
98
99
|
before do
|
99
|
-
shell_out!("knife cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
|
100
|
+
shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
|
100
101
|
end
|
101
102
|
|
102
103
|
it "downloads the cookbook" do
|
@@ -961,4 +961,43 @@ EOM
|
|
961
961
|
end
|
962
962
|
end
|
963
963
|
end
|
964
|
+
|
965
|
+
when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do
|
966
|
+
before do
|
967
|
+
organization 'foo' do
|
968
|
+
container 'x', {}
|
969
|
+
group 'x', {}
|
970
|
+
end
|
971
|
+
end
|
972
|
+
|
973
|
+
before :each do
|
974
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo')
|
975
|
+
end
|
976
|
+
|
977
|
+
it 'knife delete /acls/containers/environments.json fails with a reasonable error' do
|
978
|
+
knife('delete /acls/containers/environments.json').should_fail "ERROR: /acls/containers/environments.json (remote) cannot be deleted.\n"
|
979
|
+
end
|
980
|
+
|
981
|
+
it 'knife delete /containers/x.json succeeds' do
|
982
|
+
knife('delete /containers/x.json').should_succeed "Deleted /containers/x.json\n"
|
983
|
+
knife('raw /containers/x.json').should_fail(/404/)
|
984
|
+
end
|
985
|
+
|
986
|
+
it 'knife delete /groups/x.json succeeds' do
|
987
|
+
knife('delete /groups/x.json').should_succeed "Deleted /groups/x.json\n"
|
988
|
+
knife('raw /groups/x.json').should_fail(/404/)
|
989
|
+
end
|
990
|
+
|
991
|
+
it 'knife delete /org.json fails with a reasonable error' do
|
992
|
+
knife('delete /org.json').should_fail "ERROR: /org.json (remote) cannot be deleted.\n"
|
993
|
+
end
|
994
|
+
|
995
|
+
it 'knife delete /invitations.json fails with a reasonable error' do
|
996
|
+
knife('delete /invitations.json').should_fail "ERROR: /invitations.json (remote) cannot be deleted.\n"
|
997
|
+
end
|
998
|
+
|
999
|
+
it 'knife delete /members.json fails with a reasonable error' do
|
1000
|
+
knife('delete /members.json').should_fail "ERROR: /members.json (remote) cannot be deleted.\n"
|
1001
|
+
end
|
1002
|
+
end
|
964
1003
|
end
|