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,27 +20,32 @@ require 'chef/knife/download'
|
|
20
20
|
require 'chef/knife/diff'
|
21
21
|
|
22
22
|
describe 'knife download' do
|
23
|
-
|
23
|
+
include IntegrationSupport
|
24
24
|
include KnifeSupport
|
25
25
|
|
26
26
|
context 'without versioned cookbooks' do
|
27
27
|
when_the_chef_server "has one of each thing" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
|
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
|
35
38
|
|
36
39
|
when_the_repository 'has only top-level directories' do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
before do
|
41
|
+
directory 'clients'
|
42
|
+
directory 'cookbooks'
|
43
|
+
directory 'data_bags'
|
44
|
+
directory 'environments'
|
45
|
+
directory 'nodes'
|
46
|
+
directory 'roles'
|
47
|
+
directory 'users'
|
48
|
+
end
|
44
49
|
|
45
50
|
it 'knife download downloads everything' do
|
46
51
|
knife('download /').should_succeed <<EOM
|
@@ -63,17 +68,19 @@ EOM
|
|
63
68
|
end
|
64
69
|
|
65
70
|
when_the_repository 'has an identical copy of each thing' do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
before do
|
72
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
73
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
74
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
75
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
76
|
+
file 'data_bags/x/y.json', {}
|
77
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
78
|
+
file 'environments/x.json', {}
|
79
|
+
file 'nodes/x.json', {}
|
80
|
+
file 'roles/x.json', {}
|
81
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
82
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
83
|
+
end
|
77
84
|
|
78
85
|
it 'knife download makes no changes' do
|
79
86
|
knife('download /').should_succeed ''
|
@@ -86,7 +93,8 @@ EOM
|
|
86
93
|
end
|
87
94
|
|
88
95
|
context 'except the role file' do
|
89
|
-
|
96
|
+
before do
|
97
|
+
file 'roles/x.json', <<EOM
|
90
98
|
{
|
91
99
|
"chef_type": "role",
|
92
100
|
"default_attributes": {
|
@@ -103,6 +111,8 @@ EOM
|
|
103
111
|
]
|
104
112
|
}
|
105
113
|
EOM
|
114
|
+
end
|
115
|
+
|
106
116
|
it 'knife download changes the role' do
|
107
117
|
knife('download /').should_succeed "Updated /roles/x.json\n"
|
108
118
|
knife('diff --name-status /').should_succeed ''
|
@@ -115,7 +125,8 @@ EOM
|
|
115
125
|
end
|
116
126
|
|
117
127
|
context 'except the role file is textually different, but not ACTUALLY different' do
|
118
|
-
|
128
|
+
before do
|
129
|
+
file 'roles/x.json', <<EOM
|
119
130
|
{
|
120
131
|
"chef_type": "role",
|
121
132
|
"default_attributes": {
|
@@ -132,6 +143,8 @@ EOM
|
|
132
143
|
]
|
133
144
|
}
|
134
145
|
EOM
|
146
|
+
end
|
147
|
+
|
135
148
|
it 'knife download / does not change anything' do
|
136
149
|
knife('download /').should_succeed ''
|
137
150
|
knife('diff --name-status /').should_succeed ''
|
@@ -139,15 +152,17 @@ EOM
|
|
139
152
|
end
|
140
153
|
|
141
154
|
context 'as well as one extra copy of each thing' do
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
155
|
+
before do
|
156
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
157
|
+
file 'cookbooks/x/blah.rb', ''
|
158
|
+
file 'cookbooks/y/metadata.rb', cb_metadata("x", "1.0.0")
|
159
|
+
file 'data_bags/x/z.json', {}
|
160
|
+
file 'data_bags/y/zz.json', {}
|
161
|
+
file 'environments/y.json', {}
|
162
|
+
file 'nodes/y.json', {}
|
163
|
+
file 'roles/y.json', {}
|
164
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
165
|
+
end
|
151
166
|
|
152
167
|
it 'knife download does nothing' do
|
153
168
|
knife('download /').should_succeed ''
|
@@ -235,7 +250,10 @@ EOM
|
|
235
250
|
end
|
236
251
|
|
237
252
|
context 'when current directory is top level' do
|
238
|
-
|
253
|
+
before do
|
254
|
+
cwd '.'
|
255
|
+
end
|
256
|
+
|
239
257
|
it 'knife download with no parameters reports an error' do
|
240
258
|
knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
|
241
259
|
end
|
@@ -246,7 +264,9 @@ EOM
|
|
246
264
|
# Test download of an item when the other end doesn't even have the container
|
247
265
|
when_the_repository 'is empty' do
|
248
266
|
when_the_chef_server 'has two data bag items' do
|
249
|
-
|
267
|
+
before do
|
268
|
+
data_bag 'x', { 'y' => {}, 'z' => {} }
|
269
|
+
end
|
250
270
|
|
251
271
|
it 'knife download of one data bag item itself succeeds' do
|
252
272
|
knife('download /data_bags/x/y.json').should_succeed <<EOM
|
@@ -271,28 +291,32 @@ EOM
|
|
271
291
|
end
|
272
292
|
|
273
293
|
when_the_repository 'has three data bag items' do
|
274
|
-
|
294
|
+
before do
|
295
|
+
file 'data_bags/x/deleted.json', <<EOM
|
275
296
|
{
|
276
297
|
"id": "deleted"
|
277
298
|
}
|
278
299
|
EOM
|
279
|
-
|
300
|
+
file 'data_bags/x/modified.json', <<EOM
|
280
301
|
{
|
281
302
|
"id": "modified"
|
282
303
|
}
|
283
304
|
EOM
|
284
|
-
|
305
|
+
file 'data_bags/x/unmodified.json', <<EOM
|
285
306
|
{
|
286
307
|
"id": "unmodified"
|
287
308
|
}
|
288
309
|
EOM
|
310
|
+
end
|
289
311
|
|
290
312
|
when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do
|
291
|
-
|
292
|
-
'
|
293
|
-
|
294
|
-
|
295
|
-
|
313
|
+
before do
|
314
|
+
data_bag 'x', {
|
315
|
+
'added' => {},
|
316
|
+
'modified' => { 'foo' => 'bar' },
|
317
|
+
'unmodified' => {}
|
318
|
+
}
|
319
|
+
end
|
296
320
|
|
297
321
|
it 'knife download of the modified file succeeds' do
|
298
322
|
knife('download /data_bags/x/modified.json').should_succeed <<EOM
|
@@ -355,7 +379,9 @@ EOM
|
|
355
379
|
knife('diff --name-status /data_bags').should_succeed ''
|
356
380
|
end
|
357
381
|
context 'when cwd is the /data_bags directory' do
|
358
|
-
|
382
|
+
before do
|
383
|
+
cwd 'data_bags'
|
384
|
+
end
|
359
385
|
it 'knife download fails' do
|
360
386
|
knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
|
361
387
|
end
|
@@ -380,11 +406,15 @@ EOM
|
|
380
406
|
end
|
381
407
|
|
382
408
|
when_the_repository 'has a cookbook' do
|
383
|
-
|
384
|
-
|
409
|
+
before do
|
410
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
411
|
+
file 'cookbooks/x/z.rb', ''
|
412
|
+
end
|
385
413
|
|
386
414
|
when_the_chef_server 'has a modified, added and deleted file for the cookbook' do
|
387
|
-
|
415
|
+
before do
|
416
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => cb_metadata("x", "1.0.0", "#extra content"), 'y.rb' => 'hi' }
|
417
|
+
end
|
388
418
|
|
389
419
|
it 'knife download of a modified file succeeds' do
|
390
420
|
knife('download /cookbooks/x/metadata.rb').should_succeed "Updated /cookbooks/x/metadata.rb\n"
|
@@ -436,12 +466,16 @@ EOM
|
|
436
466
|
end
|
437
467
|
|
438
468
|
when_the_repository 'has a cookbook' do
|
439
|
-
|
440
|
-
|
469
|
+
before do
|
470
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
471
|
+
file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
|
472
|
+
end
|
441
473
|
|
442
474
|
when_the_chef_server 'has a later version for the cookbook' do
|
443
|
-
|
444
|
-
|
475
|
+
before do
|
476
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
477
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
478
|
+
end
|
445
479
|
|
446
480
|
it 'knife download /cookbooks/x downloads the latest version' do
|
447
481
|
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
@@ -454,8 +488,11 @@ EOM
|
|
454
488
|
end
|
455
489
|
|
456
490
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
457
|
-
|
458
|
-
|
491
|
+
before do
|
492
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
493
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
494
|
+
end
|
495
|
+
|
459
496
|
it 'knife download /cookbooks/x downloads the updated file' do
|
460
497
|
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
461
498
|
Updated /cookbooks/x/onlyin1.0.0.rb
|
@@ -465,7 +502,9 @@ EOM
|
|
465
502
|
end
|
466
503
|
|
467
504
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
468
|
-
|
505
|
+
before do
|
506
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
507
|
+
end
|
469
508
|
|
470
509
|
it 'knife download /cookbooks/x downloads the latest version' do
|
471
510
|
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
@@ -478,7 +517,9 @@ EOM
|
|
478
517
|
end
|
479
518
|
|
480
519
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
481
|
-
|
520
|
+
before do
|
521
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
522
|
+
end
|
482
523
|
|
483
524
|
it 'knife download /cookbooks/x downloads the old version' do
|
484
525
|
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
@@ -492,17 +533,29 @@ EOM
|
|
492
533
|
end
|
493
534
|
|
494
535
|
when_the_chef_server 'has an environment' do
|
495
|
-
|
536
|
+
before do
|
537
|
+
environment 'x', {}
|
538
|
+
end
|
496
539
|
when_the_repository 'has an environment with bad JSON' do
|
497
|
-
|
540
|
+
before do
|
541
|
+
file 'environments/x.json', '{'
|
542
|
+
end
|
498
543
|
it 'knife download succeeds' do
|
499
|
-
|
544
|
+
warning = <<-EOH
|
545
|
+
WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
|
546
|
+
{
|
547
|
+
(right here) ------^
|
548
|
+
|
549
|
+
EOH
|
550
|
+
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => warning
|
500
551
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
501
552
|
end
|
502
553
|
end
|
503
554
|
|
504
555
|
when_the_repository 'has the same environment with the wrong name in the file' do
|
505
|
-
|
556
|
+
before do
|
557
|
+
file 'environments/x.json', { 'name' => 'y' }
|
558
|
+
end
|
506
559
|
it 'knife download succeeds' do
|
507
560
|
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
508
561
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -510,7 +563,9 @@ EOM
|
|
510
563
|
end
|
511
564
|
|
512
565
|
when_the_repository 'has the same environment with no name in the file' do
|
513
|
-
|
566
|
+
before do
|
567
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
568
|
+
end
|
514
569
|
it 'knife download succeeds' do
|
515
570
|
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
516
571
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -521,22 +576,26 @@ EOM
|
|
521
576
|
|
522
577
|
with_versioned_cookbooks do
|
523
578
|
when_the_chef_server "has one of each thing" do
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
579
|
+
before do
|
580
|
+
client 'x', {}
|
581
|
+
cookbook 'x', '1.0.0'
|
582
|
+
data_bag 'x', { 'y' => {} }
|
583
|
+
environment 'x', {}
|
584
|
+
node 'x', {}
|
585
|
+
role 'x', {}
|
586
|
+
user 'x', {}
|
587
|
+
end
|
531
588
|
|
532
589
|
when_the_repository 'has only top-level directories' do
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
590
|
+
before do
|
591
|
+
directory 'clients'
|
592
|
+
directory 'cookbooks'
|
593
|
+
directory 'data_bags'
|
594
|
+
directory 'environments'
|
595
|
+
directory 'nodes'
|
596
|
+
directory 'roles'
|
597
|
+
directory 'users'
|
598
|
+
end
|
540
599
|
|
541
600
|
it 'knife download downloads everything' do
|
542
601
|
knife('download /').should_succeed <<EOM
|
@@ -559,17 +618,19 @@ EOM
|
|
559
618
|
end
|
560
619
|
|
561
620
|
when_the_repository 'has an identical copy of each thing' do
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
621
|
+
before do
|
622
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
623
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
624
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
625
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0")
|
626
|
+
file 'data_bags/x/y.json', {}
|
627
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
628
|
+
file 'environments/x.json', {}
|
629
|
+
file 'nodes/x.json', {}
|
630
|
+
file 'roles/x.json', {}
|
631
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
632
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
633
|
+
end
|
573
634
|
|
574
635
|
it 'knife download makes no changes' do
|
575
636
|
knife('download /').should_succeed ''
|
@@ -582,7 +643,9 @@ EOM
|
|
582
643
|
end
|
583
644
|
|
584
645
|
context 'except the role file' do
|
585
|
-
|
646
|
+
before do
|
647
|
+
file 'roles/x.json', { "description" => "blarghle" }
|
648
|
+
end
|
586
649
|
|
587
650
|
it 'knife download changes the role' do
|
588
651
|
knife('download /').should_succeed "Updated /roles/x.json\n"
|
@@ -591,7 +654,8 @@ EOM
|
|
591
654
|
end
|
592
655
|
|
593
656
|
context 'except the role file is textually different, but not ACTUALLY different' do
|
594
|
-
|
657
|
+
before do
|
658
|
+
file 'roles/x.json', <<EOM
|
595
659
|
{
|
596
660
|
"chef_type": "role" ,
|
597
661
|
"default_attributes": {
|
@@ -608,6 +672,8 @@ EOM
|
|
608
672
|
]
|
609
673
|
}
|
610
674
|
EOM
|
675
|
+
end
|
676
|
+
|
611
677
|
it 'knife download / does not change anything' do
|
612
678
|
knife('download /').should_succeed ''
|
613
679
|
knife('diff --name-status /').should_succeed ''
|
@@ -615,16 +681,18 @@ EOM
|
|
615
681
|
end
|
616
682
|
|
617
683
|
context 'as well as one extra copy of each thing' do
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
684
|
+
before do
|
685
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
686
|
+
file 'cookbooks/x-1.0.0/blah.rb', ''
|
687
|
+
file 'cookbooks/x-2.0.0/metadata.rb', 'version "2.0.0"'
|
688
|
+
file 'cookbooks/y-1.0.0/metadata.rb', 'version "1.0.0"'
|
689
|
+
file 'data_bags/x/z.json', {}
|
690
|
+
file 'data_bags/y/zz.json', {}
|
691
|
+
file 'environments/y.json', {}
|
692
|
+
file 'nodes/y.json', {}
|
693
|
+
file 'roles/y.json', {}
|
694
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
695
|
+
end
|
628
696
|
|
629
697
|
it 'knife download does nothing' do
|
630
698
|
knife('download /').should_succeed ''
|
@@ -688,7 +756,9 @@ EOM
|
|
688
756
|
end
|
689
757
|
|
690
758
|
context 'when current directory is top level' do
|
691
|
-
|
759
|
+
before do
|
760
|
+
cwd '.'
|
761
|
+
end
|
692
762
|
it 'knife download with no parameters reports an error' do
|
693
763
|
knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
|
694
764
|
end
|
@@ -699,7 +769,9 @@ EOM
|
|
699
769
|
# Test download of an item when the other end doesn't even have the container
|
700
770
|
when_the_repository 'is empty' do
|
701
771
|
when_the_chef_server 'has two data bag items' do
|
702
|
-
|
772
|
+
before do
|
773
|
+
data_bag 'x', { 'y' => {}, 'z' => {} }
|
774
|
+
end
|
703
775
|
|
704
776
|
it 'knife download of one data bag item itself succeeds' do
|
705
777
|
knife('download /data_bags/x/y.json').should_succeed <<EOM
|
@@ -715,28 +787,32 @@ EOM
|
|
715
787
|
end
|
716
788
|
|
717
789
|
when_the_repository 'has three data bag items' do
|
718
|
-
|
790
|
+
before do
|
791
|
+
file 'data_bags/x/deleted.json', <<EOM
|
719
792
|
{
|
720
793
|
"id": "deleted"
|
721
794
|
}
|
722
795
|
EOM
|
723
|
-
|
796
|
+
file 'data_bags/x/modified.json', <<EOM
|
724
797
|
{
|
725
798
|
"id": "modified"
|
726
799
|
}
|
727
800
|
EOM
|
728
|
-
|
801
|
+
file 'data_bags/x/unmodified.json', <<EOM
|
729
802
|
{
|
730
803
|
"id": "unmodified"
|
731
804
|
}
|
732
805
|
EOM
|
806
|
+
end
|
733
807
|
|
734
808
|
when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do
|
735
|
-
|
736
|
-
'
|
737
|
-
|
738
|
-
|
739
|
-
|
809
|
+
before do
|
810
|
+
data_bag 'x', {
|
811
|
+
'added' => {},
|
812
|
+
'modified' => { 'foo' => 'bar' },
|
813
|
+
'unmodified' => {}
|
814
|
+
}
|
815
|
+
end
|
740
816
|
|
741
817
|
it 'knife download of the modified file succeeds' do
|
742
818
|
knife('download /data_bags/x/modified.json').should_succeed <<EOM
|
@@ -799,7 +875,9 @@ EOM
|
|
799
875
|
knife('diff --name-status /data_bags').should_succeed ''
|
800
876
|
end
|
801
877
|
context 'when cwd is the /data_bags directory' do
|
802
|
-
|
878
|
+
before do
|
879
|
+
cwd 'data_bags'
|
880
|
+
end
|
803
881
|
it 'knife download fails' do
|
804
882
|
knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
|
805
883
|
end
|
@@ -824,11 +902,15 @@ EOM
|
|
824
902
|
end
|
825
903
|
|
826
904
|
when_the_repository 'has a cookbook' do
|
827
|
-
|
828
|
-
|
905
|
+
before do
|
906
|
+
file 'cookbooks/x-1.0.0/metadata.rb', 'name "x"; version "1.0.0"'
|
907
|
+
file 'cookbooks/x-1.0.0/z.rb', ''
|
908
|
+
end
|
829
909
|
|
830
910
|
when_the_chef_server 'has a modified, added and deleted file for the cookbook' do
|
831
|
-
|
911
|
+
before do
|
912
|
+
cookbook 'x', '1.0.0', { 'y.rb' => 'hi' }
|
913
|
+
end
|
832
914
|
|
833
915
|
it 'knife download of a modified file succeeds' do
|
834
916
|
knife('download /cookbooks/x-1.0.0/metadata.rb').should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n"
|
@@ -880,12 +962,16 @@ EOM
|
|
880
962
|
end
|
881
963
|
|
882
964
|
when_the_repository 'has a cookbook' do
|
883
|
-
|
884
|
-
|
965
|
+
before do
|
966
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0")
|
967
|
+
file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text'
|
968
|
+
end
|
885
969
|
|
886
970
|
when_the_chef_server 'has a later version for the cookbook' do
|
887
|
-
|
888
|
-
|
971
|
+
before do
|
972
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
973
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
974
|
+
end
|
889
975
|
|
890
976
|
it 'knife download /cookbooks/x downloads the latest version' do
|
891
977
|
knife('download --purge /cookbooks').should_succeed <<EOM
|
@@ -899,8 +985,11 @@ EOM
|
|
899
985
|
end
|
900
986
|
|
901
987
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
902
|
-
|
903
|
-
|
988
|
+
before do
|
989
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
990
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
991
|
+
end
|
992
|
+
|
904
993
|
it 'knife download /cookbooks downloads the updated file' do
|
905
994
|
knife('download --purge /cookbooks').should_succeed <<EOM
|
906
995
|
Created /cookbooks/x-0.9.9
|
@@ -913,7 +1002,9 @@ EOM
|
|
913
1002
|
end
|
914
1003
|
|
915
1004
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
916
|
-
|
1005
|
+
before do
|
1006
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' }
|
1007
|
+
end
|
917
1008
|
|
918
1009
|
it 'knife download /cookbooks/x downloads the latest version' do
|
919
1010
|
knife('download --purge /cookbooks').should_succeed <<EOM
|
@@ -927,7 +1018,9 @@ EOM
|
|
927
1018
|
end
|
928
1019
|
|
929
1020
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
930
|
-
|
1021
|
+
before do
|
1022
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' }
|
1023
|
+
end
|
931
1024
|
|
932
1025
|
it 'knife download --purge /cookbooks downloads the old version and deletes the new version' do
|
933
1026
|
knife('download --purge /cookbooks').should_succeed <<EOM
|
@@ -942,17 +1035,15 @@ EOM
|
|
942
1035
|
end
|
943
1036
|
|
944
1037
|
when_the_chef_server 'has an environment' do
|
945
|
-
|
946
|
-
|
947
|
-
file 'environments/x.json', '{'
|
948
|
-
it 'knife download succeeds' do
|
949
|
-
knife('download /environments/x.json').should_succeed "Updated /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"
|
950
|
-
knife('diff --name-status /environments/x.json').should_succeed ''
|
951
|
-
end
|
1038
|
+
before do
|
1039
|
+
environment 'x', {}
|
952
1040
|
end
|
953
1041
|
|
954
1042
|
when_the_repository 'has the same environment with the wrong name in the file' do
|
955
|
-
|
1043
|
+
before do
|
1044
|
+
file 'environments/x.json', { 'name' => 'y' }
|
1045
|
+
end
|
1046
|
+
|
956
1047
|
it 'knife download succeeds' do
|
957
1048
|
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
958
1049
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -960,7 +1051,10 @@ EOM
|
|
960
1051
|
end
|
961
1052
|
|
962
1053
|
when_the_repository 'has the same environment with no name in the file' do
|
963
|
-
|
1054
|
+
before do
|
1055
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
1056
|
+
end
|
1057
|
+
|
964
1058
|
it 'knife download succeeds' do
|
965
1059
|
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
966
1060
|
knife('diff --name-status /environments/x.json').should_succeed ''
|
@@ -970,7 +1064,9 @@ EOM
|
|
970
1064
|
end # with versioned cookbooks
|
971
1065
|
|
972
1066
|
when_the_chef_server 'has a cookbook' do
|
973
|
-
|
1067
|
+
before do
|
1068
|
+
cookbook 'x', '1.0.0'
|
1069
|
+
end
|
974
1070
|
|
975
1071
|
when_the_repository 'is empty' do
|
976
1072
|
it 'knife download /cookbooks/x signs all requests', :ruby_gte_19_only do
|