chef 12.0.0.alpha.0 → 12.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +3 -5
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +16 -8
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +3 -3
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -4
- data/lib/chef/config.rb +6 -5
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +126 -43
- data/lib/chef/cookbook/metadata.rb +102 -53
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_loader.rb +62 -14
- data/lib/chef/cookbook_site_streaming_uploader.rb +12 -1
- data/lib/chef/cookbook_version.rb +13 -4
- data/lib/chef/data_bag.rb +28 -15
- data/lib/chef/data_bag_item.rb +5 -7
- data/lib/chef/digester.rb +5 -9
- data/lib/chef/dsl/recipe.rb +14 -0
- data/lib/chef/encrypted_data_bag_item.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +57 -0
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -28
- data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +37 -0
- data/lib/chef/encrypted_data_bag_item/encryption_failure.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +79 -8
- data/lib/chef/environment.rb +1 -3
- data/lib/chef/exceptions.rb +18 -3
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/handler/json_file.rb +0 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/json_compat.rb +24 -6
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/client_delete.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/node_editor.rb +2 -3
- data/lib/chef/knife/core/ui.rb +2 -2
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +1 -0
- data/lib/chef/node.rb +1 -2
- data/lib/chef/platform/provider_mapping.rb +33 -6
- data/lib/chef/provider.rb +0 -2
- data/lib/chef/provider/cookbook_file/content.rb +1 -1
- data/lib/chef/provider/cron.rb +11 -0
- data/lib/chef/provider/deploy.rb +3 -2
- data/lib/chef/provider/deploy/revision.rb +2 -2
- data/lib/chef/provider/env.rb +1 -1
- data/lib/chef/provider/env/windows.rb +5 -9
- data/lib/chef/provider/file.rb +84 -33
- data/lib/chef/provider/git.rb +2 -1
- data/lib/chef/provider/group/aix.rb +17 -2
- data/lib/chef/provider/group/dscl.rb +27 -9
- data/lib/chef/provider/group/pw.rb +8 -1
- data/lib/chef/provider/http_request.rb +4 -4
- data/lib/chef/provider/log.rb +4 -14
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package/ips.rb +17 -23
- data/lib/chef/provider/package/paludis.rb +2 -2
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +2 -0
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +2 -2
- data/lib/chef/provider/service/windows.rb +87 -21
- data/lib/chef/provider/user/aix.rb +95 -0
- data/lib/chef/provider/user/dscl.rb +544 -156
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +4 -3
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/paludis_package.rb +1 -0
- data/lib/chef/resource/scm.rb +10 -0
- data/lib/chef/resource/user.rb +27 -0
- data/lib/chef/resource/windows_service.rb +53 -0
- data/lib/chef/resource_collection.rb +23 -12
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +6 -3
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/diff.rb +1 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +4 -4
- data/spec/data/cookbooks/angrybash/metadata.rb +2 -0
- data/spec/data/cookbooks/apache2/metadata.rb +2 -0
- data/spec/data/cookbooks/borken/metadata.rb +2 -0
- data/spec/data/cookbooks/ignorken/metadata.rb +2 -0
- data/spec/data/cookbooks/java/metadata.rb +2 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/recipes/default.rb +8 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -0
- data/spec/data/cookbooks/preseed/metadata.rb +2 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/recipes/default.rb +8 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/metadata.rb +10 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/recipes/default.rb +8 -0
- data/spec/data/mac_users/10.7-8.plist.xml +559 -0
- data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
- data/spec/data/mac_users/10.7.plist.xml +559 -0
- data/spec/data/mac_users/10.7.shadow.xml +11 -0
- data/spec/data/mac_users/10.8.plist.xml +559 -0
- data/spec/data/mac_users/10.8.shadow.xml +21 -0
- data/spec/data/mac_users/10.9.plist.xml +560 -0
- data/spec/data/mac_users/10.9.shadow.xml +21 -0
- data/spec/data/object_loader/environments/test.json +2 -0
- data/spec/data/object_loader/environments/test_json_class.json +2 -0
- data/spec/data/object_loader/nodes/test.json +2 -0
- data/spec/data/object_loader/nodes/test_json_class.json +2 -0
- data/spec/data/object_loader/roles/test.json +2 -0
- data/spec/data/object_loader/roles/test_json_class.json +2 -0
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +20 -1
- data/spec/functional/resource/env_spec.rb +137 -0
- data/spec/functional/resource/group_spec.rb +7 -5
- data/spec/functional/resource/remote_file_spec.rb +12 -1
- data/spec/functional/resource/user/dscl_spec.rb +198 -0
- data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +175 -37
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/client/ipv6_spec.rb +16 -14
- data/spec/integration/knife/chef_fs_data_store_spec.rb +57 -46
- data/spec/integration/knife/chef_repo_path_spec.rb +105 -78
- data/spec/integration/knife/chef_repository_file_system_spec.rb +100 -84
- data/spec/integration/knife/chefignore_spec.rb +76 -46
- data/spec/integration/knife/common_options_spec.rb +16 -21
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -3
- data/spec/integration/knife/delete_spec.rb +66 -46
- data/spec/integration/knife/deps_spec.rb +145 -94
- data/spec/integration/knife/diff_spec.rb +176 -110
- data/spec/integration/knife/download_spec.rb +229 -133
- data/spec/integration/knife/list_spec.rb +62 -54
- data/spec/integration/knife/raw_spec.rb +24 -9
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -26
- data/spec/integration/knife/upload_spec.rb +308 -165
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +10 -8
- data/spec/integration/solo/solo_spec.rb +22 -11
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
- data/spec/support/platform_helpers.rb +12 -0
- data/spec/support/shared/functional/file_resource.rb +10 -0
- data/spec/support/shared/integration/chef_zero_support.rb +130 -0
- data/spec/support/shared/integration/integration_helper.rb +100 -98
- data/spec/support/shared/integration/knife_support.rb +0 -1
- data/spec/support/shared/unit/provider/file.rb +6 -4
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +10 -1
- data/spec/unit/api_client/registration_spec.rb +83 -74
- data/spec/unit/application_spec.rb +32 -9
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +179 -0
- data/spec/unit/cookbook/metadata_spec.rb +190 -150
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -2
- data/spec/unit/cookbook_loader_spec.rb +114 -53
- data/spec/unit/{cookbook_site_streaming_uploader.rb → cookbook_site_streaming_uploader_spec.rb} +21 -1
- data/spec/unit/data_bag_spec.rb +88 -13
- data/spec/unit/deprecation_spec.rb +1 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +145 -9
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/formatters/base_spec.rb +48 -0
- data/spec/unit/json_compat_spec.rb +48 -17
- data/spec/unit/knife/client_delete_spec.rb +4 -4
- data/spec/unit/knife/client_show_spec.rb +15 -5
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/data_bag_from_file_spec.rb +0 -2
- data/spec/unit/knife/data_bag_show_spec.rb +23 -14
- data/spec/unit/knife/node_show_spec.rb +32 -15
- data/spec/unit/knife/role_show_spec.rb +59 -0
- data/spec/unit/platform_spec.rb +10 -0
- data/spec/unit/provider/deploy_spec.rb +4 -0
- data/spec/unit/provider/env_spec.rb +19 -0
- data/spec/unit/provider/git_spec.rb +22 -2
- data/spec/unit/provider/group/dscl_spec.rb +38 -1
- data/spec/unit/provider/group/pw_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +8 -8
- data/spec/unit/provider/log_spec.rb +33 -53
- data/spec/unit/provider/mount/mount_spec.rb +12 -3
- data/spec/unit/provider/package/ips_spec.rb +96 -63
- data/spec/unit/provider/package/paludis_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +12 -0
- data/spec/unit/provider/package/zypper_spec.rb +28 -16
- data/spec/unit/provider/service/windows_spec.rb +77 -17
- data/spec/unit/provider/user/dscl_spec.rb +659 -264
- data/spec/unit/provider/user/useradd_spec.rb +1 -0
- data/spec/unit/recipe_spec.rb +41 -0
- data/spec/unit/resource/scm_spec.rb +11 -0
- data/spec/unit/resource/user_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +46 -0
- data/spec/unit/resource_collection_spec.rb +33 -0
- data/spec/unit/resource_reporter_spec.rb +48 -0
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/role_spec.rb +6 -0
- data/spec/unit/version_constraint_spec.rb +28 -0
- metadata +61 -4
@@ -20,7 +20,7 @@ require 'support/shared/context/config'
|
|
20
20
|
require 'chef/knife/list'
|
21
21
|
|
22
22
|
describe 'knife list' do
|
23
|
-
|
23
|
+
include IntegrationSupport
|
24
24
|
include KnifeSupport
|
25
25
|
|
26
26
|
include_context "default config options"
|
@@ -71,20 +71,22 @@ EOM
|
|
71
71
|
end
|
72
72
|
|
73
73
|
when_the_chef_server "has plenty of stuff in it" do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
before do
|
75
|
+
client 'client1', {}
|
76
|
+
client 'client2', {}
|
77
|
+
cookbook 'cookbook1', '1.0.0'
|
78
|
+
cookbook 'cookbook2', '1.0.1', { 'recipes' => { 'default.rb' => '' } }
|
79
|
+
data_bag 'bag1', { 'item1' => {}, 'item2' => {} }
|
80
|
+
data_bag 'bag2', { 'item1' => {}, 'item2' => {} }
|
81
|
+
environment 'environment1', {}
|
82
|
+
environment 'environment2', {}
|
83
|
+
node 'node1', {}
|
84
|
+
node 'node2', {}
|
85
|
+
role 'role1', {}
|
86
|
+
role 'role2', {}
|
87
|
+
user 'user1', {}
|
88
|
+
user 'user2', {}
|
89
|
+
end
|
88
90
|
|
89
91
|
it "knife list / returns all top level directories" do
|
90
92
|
knife('list /').should_succeed <<EOM
|
@@ -317,7 +319,7 @@ EOM
|
|
317
319
|
context 'symlink tests' do
|
318
320
|
when_the_repository 'is empty' do
|
319
321
|
context 'when cwd is at the top of the repository' do
|
320
|
-
cwd '.'
|
322
|
+
before { cwd '.' }
|
321
323
|
|
322
324
|
it "knife list -Rfp returns everything" do
|
323
325
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -360,9 +362,9 @@ EOM
|
|
360
362
|
end
|
361
363
|
|
362
364
|
when_the_repository 'has a cookbooks directory' do
|
363
|
-
directory 'cookbooks'
|
365
|
+
before { directory 'cookbooks' }
|
364
366
|
context 'when cwd is in cookbooks/' do
|
365
|
-
cwd 'cookbooks'
|
367
|
+
before { cwd 'cookbooks' }
|
366
368
|
|
367
369
|
it "knife list -Rfp / returns everything" do
|
368
370
|
knife('list -Rfp /').should_succeed <<EOM
|
@@ -454,10 +456,10 @@ EOM
|
|
454
456
|
end
|
455
457
|
|
456
458
|
when_the_repository 'has a cookbooks/cookbook2 directory' do
|
457
|
-
directory 'cookbooks/cookbook2'
|
459
|
+
before { directory 'cookbooks/cookbook2' }
|
458
460
|
|
459
461
|
context 'when cwd is in cookbooks/cookbook2' do
|
460
|
-
cwd 'cookbooks/cookbook2'
|
462
|
+
before { cwd 'cookbooks/cookbook2' }
|
461
463
|
|
462
464
|
it "knife list -Rfp returns cookbooks" do
|
463
465
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -470,11 +472,13 @@ EOM
|
|
470
472
|
end
|
471
473
|
|
472
474
|
when_the_repository 'has a cookbooks directory and a symlinked cookbooks directory', :pending => (Chef::Platform.windows?) do
|
473
|
-
|
474
|
-
|
475
|
+
before do
|
476
|
+
directory 'cookbooks'
|
477
|
+
symlink 'symlinked', 'cookbooks'
|
478
|
+
end
|
475
479
|
|
476
480
|
context 'when cwd is in cookbooks/' do
|
477
|
-
cwd 'cookbooks'
|
481
|
+
before { cwd 'cookbooks' }
|
478
482
|
|
479
483
|
it "knife list -Rfp returns cookbooks" do
|
480
484
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -489,7 +493,7 @@ EOM
|
|
489
493
|
end
|
490
494
|
|
491
495
|
context 'when cwd is in symlinked/' do
|
492
|
-
cwd 'symlinked'
|
496
|
+
before { cwd 'symlinked' }
|
493
497
|
|
494
498
|
it "knife list -Rfp returns cookbooks" do
|
495
499
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -505,11 +509,13 @@ EOM
|
|
505
509
|
end
|
506
510
|
|
507
511
|
when_the_repository 'has a real_cookbooks directory and a cookbooks symlink to it', :pending => (Chef::Platform.windows?) do
|
508
|
-
|
509
|
-
|
512
|
+
before do
|
513
|
+
directory 'real_cookbooks'
|
514
|
+
symlink 'cookbooks', 'real_cookbooks'
|
515
|
+
end
|
510
516
|
|
511
517
|
context 'when cwd is in real_cookbooks/' do
|
512
|
-
cwd 'real_cookbooks'
|
518
|
+
before { cwd 'real_cookbooks' }
|
513
519
|
|
514
520
|
it "knife list -Rfp returns cookbooks" do
|
515
521
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -524,7 +530,7 @@ EOM
|
|
524
530
|
end
|
525
531
|
|
526
532
|
context 'when cwd is in cookbooks/' do
|
527
|
-
cwd 'cookbooks'
|
533
|
+
before { cwd 'cookbooks' }
|
528
534
|
|
529
535
|
it "knife list -Rfp returns cookbooks" do
|
530
536
|
knife('list -Rfp').should_succeed <<EOM
|
@@ -553,36 +559,38 @@ EOM
|
|
553
559
|
end
|
554
560
|
|
555
561
|
when_the_repository "has a bunch of stuff" do
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
directory 'cookbooks/cookbook1' do
|
560
|
-
file 'metadata.rb', ''
|
561
|
-
end
|
562
|
-
directory 'cookbooks/cookbook2' do
|
563
|
-
file 'metadata.rb', ''
|
564
|
-
file 'recipes/default.rb', ''
|
565
|
-
end
|
562
|
+
before do
|
563
|
+
file 'clients/client1.json', {}
|
564
|
+
file 'clients/client2.json', {}
|
566
565
|
|
567
|
-
|
568
|
-
|
569
|
-
file 'item1.json', {}
|
570
|
-
file 'item2.json', {}
|
566
|
+
directory 'cookbooks/cookbook1' do
|
567
|
+
file 'metadata.rb', cb_metadata("cookbook1", "1.0.0")
|
571
568
|
end
|
572
|
-
directory '
|
573
|
-
file '
|
574
|
-
file '
|
569
|
+
directory 'cookbooks/cookbook2' do
|
570
|
+
file 'metadata.rb', cb_metadata("cookbook2", "2.0.0")
|
571
|
+
file 'recipes/default.rb', ''
|
572
|
+
end
|
573
|
+
|
574
|
+
directory 'data_bags' do
|
575
|
+
directory 'bag1' do
|
576
|
+
file 'item1.json', {}
|
577
|
+
file 'item2.json', {}
|
578
|
+
end
|
579
|
+
directory 'bag2' do
|
580
|
+
file 'item1.json', {}
|
581
|
+
file 'item2.json', {}
|
582
|
+
end
|
575
583
|
end
|
576
|
-
end
|
577
584
|
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
585
|
+
file 'environments/environment1.json', {}
|
586
|
+
file 'environments/environment2.json', {}
|
587
|
+
file 'nodes/node1.json', {}
|
588
|
+
file 'nodes/node2.json', {}
|
589
|
+
file 'roles/role1.json', {}
|
590
|
+
file 'roles/role2.json', {}
|
591
|
+
file 'users/user1.json', {}
|
592
|
+
file 'users/user2.json', {}
|
593
|
+
end
|
586
594
|
|
587
595
|
it "knife list -Rfp / returns everything" do
|
588
596
|
knife('list -Rp --local --flat /').should_succeed <<EOM
|
@@ -21,20 +21,22 @@ require 'chef/knife/raw'
|
|
21
21
|
require 'chef/knife/show'
|
22
22
|
|
23
23
|
describe 'knife raw' do
|
24
|
-
|
24
|
+
include IntegrationSupport
|
25
25
|
include KnifeSupport
|
26
26
|
include AppServerSupport
|
27
27
|
|
28
28
|
include_context "default config options"
|
29
29
|
|
30
30
|
when_the_chef_server "has one of each thing" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
before do
|
32
|
+
client 'x', '{}'
|
33
|
+
cookbook 'x', '1.0.0'
|
34
|
+
data_bag 'x', { 'y' => '{}' }
|
35
|
+
environment 'x', '{}'
|
36
|
+
node 'x', '{}'
|
37
|
+
role 'x', '{}'
|
38
|
+
user 'x', '{}'
|
39
|
+
end
|
38
40
|
|
39
41
|
it 'knife raw /nodes/x returns the node', :pending => (RUBY_VERSION < "1.9") do
|
40
42
|
knife('raw /nodes/x').should_succeed <<EOM
|
@@ -44,12 +46,16 @@ describe 'knife raw' do
|
|
44
46
|
"chef_type": "node",
|
45
47
|
"chef_environment": "_default",
|
46
48
|
"override": {
|
49
|
+
|
47
50
|
},
|
48
51
|
"normal": {
|
52
|
+
|
49
53
|
},
|
50
54
|
"default": {
|
55
|
+
|
51
56
|
},
|
52
57
|
"automatic": {
|
58
|
+
|
53
59
|
},
|
54
60
|
"run_list": [
|
55
61
|
|
@@ -70,13 +76,16 @@ EOM
|
|
70
76
|
"json_class": "Chef::Role",
|
71
77
|
"chef_type": "role",
|
72
78
|
"default_attributes": {
|
79
|
+
|
73
80
|
},
|
74
81
|
"override_attributes": {
|
82
|
+
|
75
83
|
},
|
76
84
|
"run_list": [
|
77
85
|
|
78
86
|
],
|
79
87
|
"env_run_lists": {
|
88
|
+
|
80
89
|
}
|
81
90
|
}
|
82
91
|
EOM
|
@@ -92,13 +101,16 @@ EOM
|
|
92
101
|
"json_class": "Chef::Role",
|
93
102
|
"chef_type": "role",
|
94
103
|
"default_attributes": {
|
104
|
+
|
95
105
|
},
|
96
106
|
"override_attributes": {
|
107
|
+
|
97
108
|
},
|
98
109
|
"run_list": [
|
99
110
|
|
100
111
|
],
|
101
112
|
"env_run_lists": {
|
113
|
+
|
102
114
|
}
|
103
115
|
}
|
104
116
|
EOM
|
@@ -111,13 +123,16 @@ EOM
|
|
111
123
|
"json_class": "Chef::Role",
|
112
124
|
"chef_type": "role",
|
113
125
|
"default_attributes": {
|
126
|
+
|
114
127
|
},
|
115
128
|
"override_attributes": {
|
129
|
+
|
116
130
|
},
|
117
131
|
"run_list": [
|
118
132
|
|
119
133
|
],
|
120
134
|
"env_run_lists": {
|
135
|
+
|
121
136
|
}
|
122
137
|
}
|
123
138
|
EOM
|
@@ -154,7 +169,7 @@ EOM
|
|
154
169
|
|
155
170
|
knife("raw -m POST -i #{file.path} /roles").should_succeed <<EOM
|
156
171
|
{
|
157
|
-
"uri": "#{
|
172
|
+
"uri": "#{ChefZeroSupport::Server.server.url}/roles/y"
|
158
173
|
}
|
159
174
|
EOM
|
160
175
|
knife('show /roles/y.json').should_succeed <<EOM
|
@@ -20,14 +20,14 @@ require 'support/shared/context/config'
|
|
20
20
|
require 'chef/knife/list'
|
21
21
|
|
22
22
|
describe 'redirection' do
|
23
|
-
|
23
|
+
include IntegrationSupport
|
24
24
|
include KnifeSupport
|
25
25
|
include AppServerSupport
|
26
26
|
|
27
27
|
include_context "default config options"
|
28
28
|
|
29
29
|
when_the_chef_server 'has a role' do
|
30
|
-
role 'x', {}
|
30
|
+
before { role 'x', {} }
|
31
31
|
|
32
32
|
context 'and another server redirects to it with 302' do
|
33
33
|
before :each do
|
@@ -20,12 +20,12 @@ require 'chef/knife/serve'
|
|
20
20
|
require 'chef/server_api'
|
21
21
|
|
22
22
|
describe 'knife serve' do
|
23
|
-
|
23
|
+
include IntegrationSupport
|
24
24
|
include KnifeSupport
|
25
25
|
include AppServerSupport
|
26
26
|
|
27
27
|
when_the_repository 'also has one of each thing' do
|
28
|
-
file 'nodes/x.json', { 'foo' => 'bar' }
|
28
|
+
before { file 'nodes/x.json', { 'foo' => 'bar' } }
|
29
29
|
|
30
30
|
it 'knife serve serves up /nodes/x' do
|
31
31
|
exception = nil
|
@@ -20,40 +20,44 @@ require 'support/shared/context/config'
|
|
20
20
|
require 'chef/knife/show'
|
21
21
|
|
22
22
|
describe 'knife show' do
|
23
|
-
|
23
|
+
include IntegrationSupport
|
24
24
|
include KnifeSupport
|
25
25
|
|
26
26
|
include_context "default config options"
|
27
27
|
|
28
28
|
when_the_chef_server "has one of each thing" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
before do
|
30
|
+
client 'x', '{}'
|
31
|
+
cookbook 'x', '1.0.0'
|
32
|
+
data_bag 'x', { 'y' => '{}' }
|
33
|
+
environment 'x', '{}'
|
34
|
+
node 'x', '{}'
|
35
|
+
role 'x', '{}'
|
36
|
+
user 'x', '{}'
|
37
|
+
end
|
36
38
|
|
37
39
|
when_the_repository 'also has one of each thing' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
before do
|
41
|
+
file 'clients/x.json', { 'foo' => 'bar' }
|
42
|
+
file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0')
|
43
|
+
file 'data_bags/x/y.json', { 'foo' => 'bar' }
|
44
|
+
file 'environments/_default.json', { 'foo' => 'bar' }
|
45
|
+
file 'environments/x.json', { 'foo' => 'bar' }
|
46
|
+
file 'nodes/x.json', { 'foo' => 'bar' }
|
47
|
+
file 'roles/x.json', { 'foo' => 'bar' }
|
48
|
+
file 'users/x.json', { 'foo' => 'bar' }
|
49
|
+
end
|
46
50
|
|
47
51
|
it 'knife show /cookbooks/x/metadata.rb shows the remote version' do
|
48
52
|
knife('show /cookbooks/x/metadata.rb').should_succeed <<EOM
|
49
53
|
/cookbooks/x/metadata.rb:
|
50
|
-
version
|
54
|
+
name 'x'; version '1.0.0'
|
51
55
|
EOM
|
52
56
|
end
|
53
57
|
it 'knife show --local /cookbooks/x/metadata.rb shows the local version' do
|
54
58
|
knife('show --local /cookbooks/x/metadata.rb').should_succeed <<EOM
|
55
59
|
/cookbooks/x/metadata.rb:
|
56
|
-
version
|
60
|
+
name 'x'; version '1.0.0'
|
57
61
|
EOM
|
58
62
|
end
|
59
63
|
it 'knife show /data_bags/x/y.json shows the remote version' do
|
@@ -122,13 +126,15 @@ EOM
|
|
122
126
|
end
|
123
127
|
|
124
128
|
when_the_chef_server 'has a hash with multiple keys' do
|
125
|
-
|
126
|
-
'
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
before do
|
130
|
+
environment 'x', {
|
131
|
+
'default_attributes' => { 'foo' => 'bar' },
|
132
|
+
'cookbook_versions' => { 'blah' => '= 1.0.0'},
|
133
|
+
'override_attributes' => { 'x' => 'y' },
|
134
|
+
'description' => 'woo',
|
135
|
+
'name' => 'x'
|
136
|
+
}
|
137
|
+
end
|
132
138
|
it 'knife show shows the attributes in a predetermined order', :pending => (RUBY_VERSION < "1.9") do
|
133
139
|
knife('show /environments/x.json').should_succeed <<EOM
|
134
140
|
/environments/x.json:
|
@@ -150,7 +156,7 @@ EOM
|
|
150
156
|
end
|
151
157
|
|
152
158
|
when_the_repository 'has an environment with bad JSON' do
|
153
|
-
file 'environments/x.json', '{'
|
159
|
+
before { file 'environments/x.json', '{' }
|
154
160
|
it 'knife show succeeds' do
|
155
161
|
knife('show --local /environments/x.json').should_succeed <<EOM
|
156
162
|
/environments/x.json:
|
@@ -21,27 +21,33 @@ require 'chef/knife/diff'
|
|
21
21
|
require 'chef/knife/raw'
|
22
22
|
|
23
23
|
describe 'knife upload' do
|
24
|
-
|
24
|
+
include IntegrationSupport
|
25
25
|
include KnifeSupport
|
26
26
|
|
27
27
|
context 'without versioned cookbooks' do
|
28
|
+
|
28
29
|
when_the_chef_server "has one of each thing" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
|
31
|
+
before do
|
32
|
+
client 'x', {}
|
33
|
+
cookbook 'x', '1.0.0'
|
34
|
+
data_bag 'x', { 'y' => {} }
|
35
|
+
environment 'x', {}
|
36
|
+
node 'x', {}
|
37
|
+
role 'x', {}
|
38
|
+
user 'x', {}
|
39
|
+
end
|
36
40
|
|
37
41
|
when_the_repository 'has only top-level directories' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
before do
|
43
|
+
directory 'clients'
|
44
|
+
directory 'cookbooks'
|
45
|
+
directory 'data_bags'
|
46
|
+
directory 'environments'
|
47
|
+
directory 'nodes'
|
48
|
+
directory 'roles'
|
49
|
+
directory 'users'
|
50
|
+
end
|
45
51
|
|
46
52
|
it 'knife upload does nothing' do
|
47
53
|
knife('upload /').should_succeed ''
|
@@ -80,17 +86,20 @@ EOM
|
|
80
86
|
end
|
81
87
|
|
82
88
|
when_the_repository 'has an identical copy of each thing' do
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
|
90
|
+
before do
|
91
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
92
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
93
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
94
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
95
|
+
file 'data_bags/x/y.json', {}
|
96
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
97
|
+
file 'environments/x.json', {}
|
98
|
+
file 'nodes/x.json', {}
|
99
|
+
file 'roles/x.json', {}
|
100
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
101
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
102
|
+
end
|
94
103
|
|
95
104
|
it 'knife upload makes no changes' do
|
96
105
|
knife('upload /cookbooks/x').should_succeed ''
|
@@ -103,7 +112,10 @@ EOM
|
|
103
112
|
end
|
104
113
|
|
105
114
|
context 'except the role file' do
|
106
|
-
|
115
|
+
before do
|
116
|
+
file 'roles/x.json', { 'description' => 'blarghle' }
|
117
|
+
end
|
118
|
+
|
107
119
|
it 'knife upload changes the role' do
|
108
120
|
knife('upload /').should_succeed "Updated /roles/x.json\n"
|
109
121
|
knife('diff --name-status /').should_succeed ''
|
@@ -115,7 +127,8 @@ EOM
|
|
115
127
|
end
|
116
128
|
|
117
129
|
context 'except the role file is textually different, but not ACTUALLY different' do
|
118
|
-
|
130
|
+
before do
|
131
|
+
file 'roles/x.json', <<EOM
|
119
132
|
{
|
120
133
|
"chef_type": "role",
|
121
134
|
"default_attributes": {
|
@@ -132,6 +145,8 @@ EOM
|
|
132
145
|
]
|
133
146
|
}
|
134
147
|
EOM
|
148
|
+
end
|
149
|
+
|
135
150
|
it 'knife upload / does not change anything' do
|
136
151
|
knife('upload /').should_succeed ''
|
137
152
|
knife('diff --name-status /').should_succeed ''
|
@@ -139,15 +154,17 @@ EOM
|
|
139
154
|
end
|
140
155
|
|
141
156
|
context 'as well as one extra copy of each thing' do
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
157
|
+
before do
|
158
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
159
|
+
file 'cookbooks/x/blah.rb', ''
|
160
|
+
file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0")
|
161
|
+
file 'data_bags/x/z.json', {}
|
162
|
+
file 'data_bags/y/zz.json', {}
|
163
|
+
file 'environments/y.json', {}
|
164
|
+
file 'nodes/y.json', {}
|
165
|
+
file 'roles/y.json', {}
|
166
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
167
|
+
end
|
151
168
|
|
152
169
|
it 'knife upload adds the new files' do
|
153
170
|
knife('upload /').should_succeed <<EOM
|
@@ -219,7 +236,10 @@ EOM
|
|
219
236
|
end
|
220
237
|
|
221
238
|
context 'when current directory is top level' do
|
222
|
-
|
239
|
+
before do
|
240
|
+
cwd '.'
|
241
|
+
end
|
242
|
+
|
223
243
|
it 'knife upload with no parameters reports an error' do
|
224
244
|
knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/
|
225
245
|
end
|
@@ -229,7 +249,11 @@ EOM
|
|
229
249
|
|
230
250
|
when_the_chef_server 'is empty' do
|
231
251
|
when_the_repository 'has a data bag item' do
|
232
|
-
|
252
|
+
|
253
|
+
before do
|
254
|
+
file 'data_bags/x/y.json', { 'foo' => 'bar' }
|
255
|
+
end
|
256
|
+
|
233
257
|
it 'knife upload of the data bag uploads only the values in the data bag item and no other' do
|
234
258
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
235
259
|
Created /data_bags/x
|
@@ -249,7 +273,11 @@ EOM
|
|
249
273
|
end
|
250
274
|
|
251
275
|
when_the_repository 'has a data bag item with keys chef_type and data_bag' do
|
252
|
-
|
276
|
+
|
277
|
+
before do
|
278
|
+
file 'data_bags/x/y.json', { 'chef_type' => 'aaa', 'data_bag' => 'bbb' }
|
279
|
+
end
|
280
|
+
|
253
281
|
it 'upload preserves chef_type and data_bag' do
|
254
282
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
255
283
|
Created /data_bags/x
|
@@ -265,8 +293,10 @@ EOM
|
|
265
293
|
|
266
294
|
# Test upload of an item when the other end doesn't even have the container
|
267
295
|
when_the_repository 'has two data bag items' do
|
268
|
-
|
269
|
-
|
296
|
+
before do
|
297
|
+
file 'data_bags/x/y.json', {}
|
298
|
+
file 'data_bags/x/z.json', {}
|
299
|
+
end
|
270
300
|
it 'knife upload of one data bag item itself succeeds' do
|
271
301
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
272
302
|
Created /data_bags/x
|
@@ -280,12 +310,17 @@ EOM
|
|
280
310
|
end
|
281
311
|
|
282
312
|
when_the_chef_server 'has three data bag items' do
|
283
|
-
|
313
|
+
|
314
|
+
before do
|
315
|
+
data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} }
|
316
|
+
end
|
284
317
|
|
285
318
|
when_the_repository 'has a modified, unmodified, added and deleted data bag item' do
|
286
|
-
|
287
|
-
|
288
|
-
|
319
|
+
before do
|
320
|
+
file 'data_bags/x/added.json', {}
|
321
|
+
file 'data_bags/x/modified.json', { 'foo' => 'bar' }
|
322
|
+
file 'data_bags/x/unmodified.json', {}
|
323
|
+
end
|
289
324
|
|
290
325
|
it 'knife upload of the modified file succeeds' do
|
291
326
|
knife('upload /data_bags/x/modified.json').should_succeed <<EOM
|
@@ -348,10 +383,15 @@ EOM
|
|
348
383
|
knife('diff --name-status /data_bags').should_succeed ''
|
349
384
|
end
|
350
385
|
context 'when cwd is the /data_bags directory' do
|
351
|
-
|
386
|
+
|
387
|
+
before do
|
388
|
+
cwd 'data_bags'
|
389
|
+
end
|
390
|
+
|
352
391
|
it 'knife upload fails' do
|
353
392
|
knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/
|
354
393
|
end
|
394
|
+
|
355
395
|
it 'knife upload --purge . uploads everything' do
|
356
396
|
knife('upload --purge .').should_succeed <<EOM
|
357
397
|
Created x/added.json
|
@@ -376,10 +416,17 @@ EOM
|
|
376
416
|
# upload of a file is designed not to work at present. Make sure that is the
|
377
417
|
# case.
|
378
418
|
when_the_chef_server 'has a cookbook' do
|
379
|
-
|
419
|
+
|
420
|
+
before do
|
421
|
+
cookbook 'x', '1.0.0', { 'z.rb' => '' }
|
422
|
+
end
|
423
|
+
|
380
424
|
when_the_repository 'has a modified, extra and missing file for the cookbook' do
|
381
|
-
|
382
|
-
|
425
|
+
before do
|
426
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0", "#modified")
|
427
|
+
file 'cookbooks/x/y.rb', 'hi'
|
428
|
+
end
|
429
|
+
|
383
430
|
it 'knife upload of any individual file fails' do
|
384
431
|
knife('upload /cookbooks/x/metadata.rb').should_fail "ERROR: /cookbooks/x/metadata.rb cannot be updated.\n"
|
385
432
|
knife('upload /cookbooks/x/y.rb').should_fail "ERROR: /cookbooks/x cannot have a child created under it.\n"
|
@@ -402,7 +449,11 @@ EOM
|
|
402
449
|
end
|
403
450
|
end
|
404
451
|
when_the_repository 'has a missing file for the cookbook' do
|
405
|
-
|
452
|
+
|
453
|
+
before do
|
454
|
+
file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0')
|
455
|
+
end
|
456
|
+
|
406
457
|
it 'knife upload of the cookbook succeeds' do
|
407
458
|
knife('upload /cookbooks/x').should_succeed <<EOM
|
408
459
|
Updated /cookbooks/x
|
@@ -411,9 +462,13 @@ EOM
|
|
411
462
|
end
|
412
463
|
end
|
413
464
|
when_the_repository 'has an extra file for the cookbook' do
|
414
|
-
|
415
|
-
|
416
|
-
|
465
|
+
|
466
|
+
before do
|
467
|
+
file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0')
|
468
|
+
file 'cookbooks/x/z.rb', ''
|
469
|
+
file 'cookbooks/x/blah.rb', ''
|
470
|
+
end
|
471
|
+
|
417
472
|
it 'knife upload of the cookbook succeeds' do
|
418
473
|
knife('upload /cookbooks/x').should_succeed <<EOM
|
419
474
|
Updated /cookbooks/x
|
@@ -423,26 +478,31 @@ EOM
|
|
423
478
|
end
|
424
479
|
|
425
480
|
when_the_repository 'has a different file in the cookbook' do
|
426
|
-
|
481
|
+
before do
|
482
|
+
file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0')
|
483
|
+
end
|
427
484
|
|
428
485
|
it 'knife upload --freeze freezes the cookbook' do
|
429
486
|
knife('upload --freeze /cookbooks/x').should_succeed <<EOM
|
430
487
|
Updated /cookbooks/x
|
431
488
|
EOM
|
432
489
|
# Modify a file and attempt to upload
|
433
|
-
file 'cookbooks/x/metadata.rb', 'version
|
490
|
+
file 'cookbooks/x/metadata.rb', "name 'x'; version '1.0.0'#different"
|
434
491
|
knife('upload /cookbooks/x').should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n"
|
435
492
|
end
|
436
493
|
end
|
437
494
|
end
|
438
495
|
|
439
496
|
when_the_chef_server 'has a frozen cookbook' do
|
440
|
-
|
441
|
-
'
|
442
|
-
|
497
|
+
before do
|
498
|
+
cookbook 'frozencook', '1.0.0', {}, :frozen => true
|
499
|
+
end
|
443
500
|
|
444
501
|
when_the_repository 'has an update to said cookbook' do
|
445
|
-
|
502
|
+
|
503
|
+
before do
|
504
|
+
file 'cookbooks/frozencook/metadata.rb', cb_metadata("frozencook", "1.0.0", "# This is different")
|
505
|
+
end
|
446
506
|
|
447
507
|
it 'knife upload fails to upload the frozen cookbook' do
|
448
508
|
knife('upload /cookbooks/frozencook').should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n"
|
@@ -456,12 +516,16 @@ EOM
|
|
456
516
|
end
|
457
517
|
|
458
518
|
when_the_repository 'has a cookbook' do
|
459
|
-
|
460
|
-
|
519
|
+
before do
|
520
|
+
file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0')
|
521
|
+
file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
|
522
|
+
end
|
461
523
|
|
462
524
|
when_the_chef_server 'has a later version for the cookbook' do
|
463
|
-
|
464
|
-
|
525
|
+
before do
|
526
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
527
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
528
|
+
end
|
465
529
|
|
466
530
|
it 'knife upload /cookbooks/x uploads the local version' do
|
467
531
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -481,8 +545,11 @@ EOM
|
|
481
545
|
end
|
482
546
|
|
483
547
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
484
|
-
|
485
|
-
|
548
|
+
before do
|
549
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
550
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
551
|
+
end
|
552
|
+
|
486
553
|
it 'knife upload /cookbooks/x uploads the local version' do
|
487
554
|
knife('upload --purge /cookbooks/x').should_succeed <<EOM
|
488
555
|
Updated /cookbooks/x
|
@@ -492,7 +559,9 @@ EOM
|
|
492
559
|
end
|
493
560
|
|
494
561
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
495
|
-
|
562
|
+
before do
|
563
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
564
|
+
end
|
496
565
|
|
497
566
|
it 'knife upload /cookbooks/x uploads the local version' do
|
498
567
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -512,7 +581,9 @@ EOM
|
|
512
581
|
end
|
513
582
|
|
514
583
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
515
|
-
|
584
|
+
before do
|
585
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
586
|
+
end
|
516
587
|
|
517
588
|
it 'knife upload /cookbooks/x uploads the new version' do
|
518
589
|
knife('upload --purge /cookbooks/x').should_succeed <<EOM
|
@@ -524,17 +595,41 @@ EOM
|
|
524
595
|
end
|
525
596
|
|
526
597
|
when_the_chef_server 'has an environment' do
|
527
|
-
|
598
|
+
before do
|
599
|
+
environment 'x', {}
|
600
|
+
end
|
601
|
+
|
528
602
|
when_the_repository 'has an environment with bad JSON' do
|
529
|
-
|
603
|
+
before do
|
604
|
+
file 'environments/x.json', '{'
|
605
|
+
end
|
606
|
+
|
530
607
|
it 'knife upload tries and fails' do
|
531
|
-
|
532
|
-
|
608
|
+
error1 = <<-EOH
|
609
|
+
WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
|
610
|
+
{
|
611
|
+
(right here) ------^
|
612
|
+
|
613
|
+
ERROR: /environments/x.json failed to write: Parse error reading JSON: parse error: premature EOF
|
614
|
+
{
|
615
|
+
(right here) ------^
|
616
|
+
EOH
|
617
|
+
|
618
|
+
warn = <<-EOH
|
619
|
+
WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
|
620
|
+
{
|
621
|
+
(right here) ------^
|
622
|
+
|
623
|
+
EOH
|
624
|
+
knife('upload /environments/x.json').should_fail(error1)
|
625
|
+
knife('diff --name-status /environments/x.json').should_succeed("M\t/environments/x.json\n", :stderr => warn)
|
533
626
|
end
|
534
627
|
end
|
535
628
|
|
536
629
|
when_the_repository 'has the same environment with the wrong name in the file' do
|
537
|
-
|
630
|
+
before do
|
631
|
+
file 'environments/x.json', { 'name' => 'y' }
|
632
|
+
end
|
538
633
|
it 'knife upload fails' do
|
539
634
|
knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n"
|
540
635
|
knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n"
|
@@ -542,7 +637,9 @@ EOM
|
|
542
637
|
end
|
543
638
|
|
544
639
|
when_the_repository 'has the same environment with no name in the file' do
|
545
|
-
|
640
|
+
before do
|
641
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
642
|
+
end
|
546
643
|
it 'knife upload succeeds' do
|
547
644
|
knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
548
645
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -551,16 +648,11 @@ EOM
|
|
551
648
|
end
|
552
649
|
|
553
650
|
when_the_chef_server 'is empty' do
|
554
|
-
when_the_repository 'has an environment with bad JSON' do
|
555
|
-
file 'environments/x.json', '{'
|
556
|
-
it 'knife upload tries and fails' do
|
557
|
-
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n"
|
558
|
-
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
559
|
-
end
|
560
|
-
end
|
561
651
|
|
562
652
|
when_the_repository 'has an environment with the wrong name in the file' do
|
563
|
-
|
653
|
+
before do
|
654
|
+
file 'environments/x.json', { 'name' => 'y' }
|
655
|
+
end
|
564
656
|
it 'knife upload fails' do
|
565
657
|
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n"
|
566
658
|
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
@@ -568,7 +660,10 @@ EOM
|
|
568
660
|
end
|
569
661
|
|
570
662
|
when_the_repository 'has an environment with no name in the file' do
|
571
|
-
|
663
|
+
|
664
|
+
before do
|
665
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
666
|
+
end
|
572
667
|
it 'knife upload succeeds' do
|
573
668
|
knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n"
|
574
669
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -576,7 +671,9 @@ EOM
|
|
576
671
|
end
|
577
672
|
|
578
673
|
when_the_repository 'has a data bag with no id in the file' do
|
579
|
-
|
674
|
+
before do
|
675
|
+
file 'data_bags/bag/x.json', { 'foo' => 'bar' }
|
676
|
+
end
|
580
677
|
it 'knife upload succeeds' do
|
581
678
|
knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n"
|
582
679
|
knife('diff --name-status /data_bags/bag/x.json').should_succeed ''
|
@@ -587,22 +684,27 @@ EOM
|
|
587
684
|
|
588
685
|
with_versioned_cookbooks do
|
589
686
|
when_the_chef_server "has one of each thing" do
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
687
|
+
|
688
|
+
before do
|
689
|
+
client 'x', {}
|
690
|
+
cookbook 'x', '1.0.0'
|
691
|
+
data_bag 'x', { 'y' => {} }
|
692
|
+
environment 'x', {}
|
693
|
+
node 'x', {}
|
694
|
+
role 'x', {}
|
695
|
+
user 'x', {}
|
696
|
+
end
|
597
697
|
|
598
698
|
when_the_repository 'has only top-level directories' do
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
699
|
+
before do
|
700
|
+
directory 'clients'
|
701
|
+
directory 'cookbooks'
|
702
|
+
directory 'data_bags'
|
703
|
+
directory 'environments'
|
704
|
+
directory 'nodes'
|
705
|
+
directory 'roles'
|
706
|
+
directory 'users'
|
707
|
+
end
|
606
708
|
|
607
709
|
it 'knife upload does nothing' do
|
608
710
|
knife('upload /').should_succeed ''
|
@@ -641,17 +743,19 @@ EOM
|
|
641
743
|
end
|
642
744
|
|
643
745
|
when_the_repository 'has an identical copy of each thing' do
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
746
|
+
before do
|
747
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
748
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
749
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
750
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0')
|
751
|
+
file 'data_bags/x/y.json', {}
|
752
|
+
file 'environments/_default.json', { 'description' => 'The default Chef environment' }
|
753
|
+
file 'environments/x.json', {}
|
754
|
+
file 'nodes/x.json', {}
|
755
|
+
file 'roles/x.json', {}
|
756
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
757
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
758
|
+
end
|
655
759
|
|
656
760
|
it 'knife upload makes no changes' do
|
657
761
|
knife('upload /cookbooks/x-1.0.0').should_succeed ''
|
@@ -664,7 +768,9 @@ EOM
|
|
664
768
|
end
|
665
769
|
|
666
770
|
context 'except the role file' do
|
667
|
-
|
771
|
+
before do
|
772
|
+
file 'roles/x.json', { 'description' => 'blarghle' }
|
773
|
+
end
|
668
774
|
|
669
775
|
it 'knife upload changes the role' do
|
670
776
|
knife('upload /').should_succeed "Updated /roles/x.json\n"
|
@@ -673,7 +779,9 @@ EOM
|
|
673
779
|
end
|
674
780
|
|
675
781
|
context 'except the role file is textually different, but not ACTUALLY different' do
|
676
|
-
|
782
|
+
|
783
|
+
before do
|
784
|
+
file 'roles/x.json', <<EOM
|
677
785
|
{
|
678
786
|
"chef_type": "role",
|
679
787
|
"default_attributes": {
|
@@ -690,6 +798,8 @@ EOM
|
|
690
798
|
]
|
691
799
|
}
|
692
800
|
EOM
|
801
|
+
end
|
802
|
+
|
693
803
|
it 'knife upload / does not change anything' do
|
694
804
|
knife('upload /').should_succeed ''
|
695
805
|
knife('diff --name-status /').should_succeed ''
|
@@ -697,16 +807,18 @@ EOM
|
|
697
807
|
end
|
698
808
|
|
699
809
|
context 'as well as one extra copy of each thing' do
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
810
|
+
before do
|
811
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
812
|
+
file 'cookbooks/x-1.0.0/blah.rb', ''
|
813
|
+
file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata('x', '2.0.0')
|
814
|
+
file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata('y', '1.0.0')
|
815
|
+
file 'data_bags/x/z.json', {}
|
816
|
+
file 'data_bags/y/zz.json', {}
|
817
|
+
file 'environments/y.json', {}
|
818
|
+
file 'nodes/y.json', {}
|
819
|
+
file 'roles/y.json', {}
|
820
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
821
|
+
end
|
710
822
|
|
711
823
|
it 'knife upload adds the new files' do
|
712
824
|
knife('upload /').should_succeed <<EOM
|
@@ -763,7 +875,9 @@ EOM
|
|
763
875
|
end
|
764
876
|
|
765
877
|
context 'when current directory is top level' do
|
766
|
-
|
878
|
+
before do
|
879
|
+
cwd '.'
|
880
|
+
end
|
767
881
|
it 'knife upload with no parameters reports an error' do
|
768
882
|
knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/
|
769
883
|
end
|
@@ -774,8 +888,10 @@ EOM
|
|
774
888
|
# Test upload of an item when the other end doesn't even have the container
|
775
889
|
when_the_chef_server 'is empty' do
|
776
890
|
when_the_repository 'has two data bag items' do
|
777
|
-
|
778
|
-
|
891
|
+
before do
|
892
|
+
file 'data_bags/x/y.json', {}
|
893
|
+
file 'data_bags/x/z.json', {}
|
894
|
+
end
|
779
895
|
|
780
896
|
it 'knife upload of one data bag item itself succeeds' do
|
781
897
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
@@ -790,11 +906,15 @@ EOM
|
|
790
906
|
end
|
791
907
|
|
792
908
|
when_the_chef_server 'has three data bag items' do
|
793
|
-
|
909
|
+
before do
|
910
|
+
data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} }
|
911
|
+
end
|
794
912
|
when_the_repository 'has a modified, unmodified, added and deleted data bag item' do
|
795
|
-
|
796
|
-
|
797
|
-
|
913
|
+
before do
|
914
|
+
file 'data_bags/x/added.json', {}
|
915
|
+
file 'data_bags/x/modified.json', { 'foo' => 'bar' }
|
916
|
+
file 'data_bags/x/unmodified.json', {}
|
917
|
+
end
|
798
918
|
|
799
919
|
it 'knife upload of the modified file succeeds' do
|
800
920
|
knife('upload /data_bags/x/modified.json').should_succeed <<EOM
|
@@ -857,7 +977,9 @@ EOM
|
|
857
977
|
knife('diff --name-status /data_bags').should_succeed ''
|
858
978
|
end
|
859
979
|
context 'when cwd is the /data_bags directory' do
|
860
|
-
|
980
|
+
before do
|
981
|
+
cwd 'data_bags'
|
982
|
+
end
|
861
983
|
it 'knife upload fails' do
|
862
984
|
knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/
|
863
985
|
end
|
@@ -885,11 +1007,15 @@ EOM
|
|
885
1007
|
# upload of a file is designed not to work at present. Make sure that is the
|
886
1008
|
# case.
|
887
1009
|
when_the_chef_server 'has a cookbook' do
|
888
|
-
|
1010
|
+
before do
|
1011
|
+
cookbook 'x', '1.0.0', { 'z.rb' => '' }
|
1012
|
+
end
|
889
1013
|
|
890
1014
|
when_the_repository 'has a modified, extra and missing file for the cookbook' do
|
891
|
-
|
892
|
-
|
1015
|
+
before do
|
1016
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', '#modified')
|
1017
|
+
file 'cookbooks/x-1.0.0/y.rb', 'hi'
|
1018
|
+
end
|
893
1019
|
|
894
1020
|
it 'knife upload of any individual file fails' do
|
895
1021
|
knife('upload /cookbooks/x-1.0.0/metadata.rb').should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n"
|
@@ -916,7 +1042,9 @@ EOM
|
|
916
1042
|
end
|
917
1043
|
|
918
1044
|
when_the_repository 'has a missing file for the cookbook' do
|
919
|
-
|
1045
|
+
before do
|
1046
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', "1.0.0")
|
1047
|
+
end
|
920
1048
|
|
921
1049
|
it 'knife upload of the cookbook succeeds' do
|
922
1050
|
knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
|
@@ -927,9 +1055,11 @@ EOM
|
|
927
1055
|
end
|
928
1056
|
|
929
1057
|
when_the_repository 'has an extra file for the cookbook' do
|
930
|
-
|
931
|
-
|
932
|
-
|
1058
|
+
before do
|
1059
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0')
|
1060
|
+
file 'cookbooks/x-1.0.0/z.rb', ''
|
1061
|
+
file 'cookbooks/x-1.0.0/blah.rb', ''
|
1062
|
+
end
|
933
1063
|
|
934
1064
|
it 'knife upload of the cookbook succeeds' do
|
935
1065
|
knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
|
@@ -941,12 +1071,16 @@ EOM
|
|
941
1071
|
end
|
942
1072
|
|
943
1073
|
when_the_repository 'has a cookbook' do
|
944
|
-
|
945
|
-
|
1074
|
+
before do
|
1075
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0')
|
1076
|
+
file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text'
|
1077
|
+
end
|
946
1078
|
|
947
1079
|
when_the_chef_server 'has a later version for the cookbook' do
|
948
|
-
|
949
|
-
|
1080
|
+
before do
|
1081
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
1082
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
1083
|
+
end
|
950
1084
|
|
951
1085
|
it 'knife upload /cookbooks uploads the local version' do
|
952
1086
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -962,8 +1096,10 @@ EOM
|
|
962
1096
|
end
|
963
1097
|
|
964
1098
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
965
|
-
|
966
|
-
|
1099
|
+
before do
|
1100
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
1101
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
1102
|
+
end
|
967
1103
|
it 'knife upload /cookbooks uploads the local version' do
|
968
1104
|
knife('upload --purge /cookbooks').should_succeed <<EOM
|
969
1105
|
Updated /cookbooks/x-1.0.0
|
@@ -974,7 +1110,9 @@ EOM
|
|
974
1110
|
end
|
975
1111
|
|
976
1112
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
977
|
-
|
1113
|
+
before do
|
1114
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
1115
|
+
end
|
978
1116
|
|
979
1117
|
it 'knife upload /cookbooks/x uploads the local version' do
|
980
1118
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -990,7 +1128,9 @@ EOM
|
|
990
1128
|
end
|
991
1129
|
|
992
1130
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
993
|
-
|
1131
|
+
before do
|
1132
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
1133
|
+
end
|
994
1134
|
|
995
1135
|
it 'knife upload /cookbooks/x uploads the new version' do
|
996
1136
|
knife('upload --purge /cookbooks').should_succeed <<EOM
|
@@ -1003,17 +1143,14 @@ EOM
|
|
1003
1143
|
end
|
1004
1144
|
|
1005
1145
|
when_the_chef_server 'has an environment' do
|
1006
|
-
|
1007
|
-
|
1008
|
-
file 'environments/x.json', '{'
|
1009
|
-
it 'knife upload tries and fails' do
|
1010
|
-
knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n"
|
1011
|
-
knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
|
1012
|
-
end
|
1146
|
+
before do
|
1147
|
+
environment 'x', {}
|
1013
1148
|
end
|
1014
1149
|
|
1015
1150
|
when_the_repository 'has the same environment with the wrong name in the file' do
|
1016
|
-
|
1151
|
+
before do
|
1152
|
+
file 'environments/x.json', { 'name' => 'y' }
|
1153
|
+
end
|
1017
1154
|
it 'knife upload fails' do
|
1018
1155
|
knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n"
|
1019
1156
|
knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n"
|
@@ -1021,7 +1158,9 @@ EOM
|
|
1021
1158
|
end
|
1022
1159
|
|
1023
1160
|
when_the_repository 'has the same environment with no name in the file' do
|
1024
|
-
|
1161
|
+
before do
|
1162
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
1163
|
+
end
|
1025
1164
|
it 'knife upload succeeds' do
|
1026
1165
|
knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
1027
1166
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -1030,16 +1169,11 @@ EOM
|
|
1030
1169
|
end
|
1031
1170
|
|
1032
1171
|
when_the_chef_server 'is empty' do
|
1033
|
-
when_the_repository 'has an environment with bad JSON' do
|
1034
|
-
file 'environments/x.json', '{'
|
1035
|
-
it 'knife upload tries and fails' do
|
1036
|
-
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n"
|
1037
|
-
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
1038
|
-
end
|
1039
|
-
end
|
1040
1172
|
|
1041
1173
|
when_the_repository 'has an environment with the wrong name in the file' do
|
1042
|
-
|
1174
|
+
before do
|
1175
|
+
file 'environments/x.json', { 'name' => 'y' }
|
1176
|
+
end
|
1043
1177
|
it 'knife upload fails' do
|
1044
1178
|
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n"
|
1045
1179
|
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
@@ -1047,7 +1181,9 @@ EOM
|
|
1047
1181
|
end
|
1048
1182
|
|
1049
1183
|
when_the_repository 'has an environment with no name in the file' do
|
1050
|
-
|
1184
|
+
before do
|
1185
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
1186
|
+
end
|
1051
1187
|
it 'knife upload succeeds' do
|
1052
1188
|
knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n"
|
1053
1189
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -1055,7 +1191,9 @@ EOM
|
|
1055
1191
|
end
|
1056
1192
|
|
1057
1193
|
when_the_repository 'has a data bag with no id in the file' do
|
1058
|
-
|
1194
|
+
before do
|
1195
|
+
file 'data_bags/bag/x.json', { 'foo' => 'bar' }
|
1196
|
+
end
|
1059
1197
|
it 'knife upload succeeds' do
|
1060
1198
|
knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n"
|
1061
1199
|
knife('diff --name-status /data_bags/bag/x.json').should_succeed ''
|
@@ -1065,9 +1203,14 @@ EOM
|
|
1065
1203
|
end # with versioned cookbooks
|
1066
1204
|
|
1067
1205
|
when_the_chef_server 'has a user' do
|
1068
|
-
|
1206
|
+
before do
|
1207
|
+
user 'x', {}
|
1208
|
+
end
|
1209
|
+
|
1069
1210
|
when_the_repository 'has the same user with json_class in it' do
|
1070
|
-
|
1211
|
+
before do
|
1212
|
+
file 'users/x.json', { 'admin' => true, 'json_class' => 'Chef::WebUIUser' }
|
1213
|
+
end
|
1071
1214
|
it 'knife upload /users/x.json succeeds' do
|
1072
1215
|
knife('upload /users/x.json').should_succeed "Updated /users/x.json\n"
|
1073
1216
|
end
|