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
@@ -19,27 +19,31 @@ require 'support/shared/integration/integration_helper'
|
|
19
19
|
require 'chef/knife/diff'
|
20
20
|
|
21
21
|
describe 'knife diff' do
|
22
|
-
|
22
|
+
include IntegrationSupport
|
23
23
|
include KnifeSupport
|
24
24
|
|
25
25
|
context 'without versioned cookbooks' do
|
26
26
|
when_the_chef_server "has one of each thing" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
before do
|
28
|
+
client 'x', '{}'
|
29
|
+
cookbook 'x', '1.0.0'
|
30
|
+
data_bag 'x', { 'y' => '{}' }
|
31
|
+
environment 'x', '{}'
|
32
|
+
node 'x', '{}'
|
33
|
+
role 'x', '{}'
|
34
|
+
user 'x', '{}'
|
35
|
+
end
|
34
36
|
|
35
37
|
when_the_repository 'has only top-level directories' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
before do
|
39
|
+
directory 'clients'
|
40
|
+
directory 'cookbooks'
|
41
|
+
directory 'data_bags'
|
42
|
+
directory 'environments'
|
43
|
+
directory 'nodes'
|
44
|
+
directory 'roles'
|
45
|
+
directory 'users'
|
46
|
+
end
|
43
47
|
|
44
48
|
it 'knife diff reports everything as deleted' do
|
45
49
|
knife('diff --name-status /').should_succeed <<EOM
|
@@ -60,17 +64,19 @@ EOM
|
|
60
64
|
|
61
65
|
when_the_repository 'has an identical copy of each thing' do
|
62
66
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
before do
|
68
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
69
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
70
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
71
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
72
|
+
file 'data_bags/x/y.json', {}
|
73
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
74
|
+
file 'environments/x.json', {}
|
75
|
+
file 'nodes/x.json', {}
|
76
|
+
file 'roles/x.json', {}
|
77
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
78
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
79
|
+
end
|
74
80
|
|
75
81
|
it 'knife diff reports no differences' do
|
76
82
|
knife('diff /').should_succeed ''
|
@@ -85,11 +91,14 @@ EOM
|
|
85
91
|
end
|
86
92
|
|
87
93
|
context 'except the role file' do
|
88
|
-
|
94
|
+
before do
|
95
|
+
file 'roles/x.json', <<EOM
|
89
96
|
{
|
90
97
|
"foo": "bar"
|
91
98
|
}
|
92
99
|
EOM
|
100
|
+
end
|
101
|
+
|
93
102
|
it 'knife diff reports the role as different' do
|
94
103
|
knife('diff --name-status /').should_succeed <<EOM
|
95
104
|
M\t/roles/x.json
|
@@ -98,15 +107,17 @@ EOM
|
|
98
107
|
end
|
99
108
|
|
100
109
|
context 'as well as one extra copy of each thing' do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
+
before do
|
111
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
112
|
+
file 'cookbooks/x/blah.rb', ''
|
113
|
+
file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0")
|
114
|
+
file 'data_bags/x/z.json', {}
|
115
|
+
file 'data_bags/y/zz.json', {}
|
116
|
+
file 'environments/y.json', {}
|
117
|
+
file 'nodes/y.json', {}
|
118
|
+
file 'roles/y.json', {}
|
119
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
120
|
+
end
|
110
121
|
|
111
122
|
it 'knife diff reports the new files as added' do
|
112
123
|
knife('diff --name-status /').should_succeed <<EOM
|
@@ -123,7 +134,7 @@ EOM
|
|
123
134
|
end
|
124
135
|
|
125
136
|
context 'when cwd is the data_bags directory' do
|
126
|
-
cwd 'data_bags'
|
137
|
+
before { cwd 'data_bags' }
|
127
138
|
it 'knife diff reports different data bags' do
|
128
139
|
knife('diff --name-status').should_succeed <<EOM
|
129
140
|
A\tx/z.json
|
@@ -156,12 +167,16 @@ EOM
|
|
156
167
|
end
|
157
168
|
|
158
169
|
when_the_repository 'has a cookbook' do
|
159
|
-
|
160
|
-
|
170
|
+
before do
|
171
|
+
file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0")
|
172
|
+
file 'cookbooks/x/onlyin1.0.0.rb', ''
|
173
|
+
end
|
161
174
|
|
162
175
|
when_the_chef_server 'has a later version for the cookbook' do
|
163
|
-
|
164
|
-
|
176
|
+
before do
|
177
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
178
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' }
|
179
|
+
end
|
165
180
|
|
166
181
|
it 'knife diff /cookbooks/x shows differences' do
|
167
182
|
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
@@ -180,15 +195,19 @@ EOM
|
|
180
195
|
end
|
181
196
|
|
182
197
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
183
|
-
|
184
|
-
|
198
|
+
before do
|
199
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
200
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' }
|
201
|
+
end
|
185
202
|
it 'knife diff /cookbooks/x shows no differences' do
|
186
203
|
knife('diff --name-status /cookbooks/x').should_succeed ''
|
187
204
|
end
|
188
205
|
end
|
189
206
|
|
190
207
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
191
|
-
|
208
|
+
before do
|
209
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' }
|
210
|
+
end
|
192
211
|
|
193
212
|
it 'knife diff /cookbooks/x shows the differences' do
|
194
213
|
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
@@ -200,7 +219,9 @@ EOM
|
|
200
219
|
end
|
201
220
|
|
202
221
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
203
|
-
|
222
|
+
before do
|
223
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' }
|
224
|
+
end
|
204
225
|
|
205
226
|
it 'knife diff /cookbooks/x shows the differences' do
|
206
227
|
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
@@ -214,15 +235,18 @@ EOM
|
|
214
235
|
|
215
236
|
context 'json diff tests' do
|
216
237
|
when_the_repository 'has an empty environment file' do
|
217
|
-
|
238
|
+
before do
|
239
|
+
file 'environments/x.json', {}
|
240
|
+
end
|
241
|
+
|
218
242
|
when_the_chef_server 'has an empty environment' do
|
219
|
-
environment 'x', {}
|
243
|
+
before { environment 'x', {} }
|
220
244
|
it 'knife diff returns no differences' do
|
221
245
|
knife('diff /environments/x.json').should_succeed ''
|
222
246
|
end
|
223
247
|
end
|
224
248
|
when_the_chef_server 'has an environment with a different value' do
|
225
|
-
environment 'x', { 'description' => 'hi' }
|
249
|
+
before { environment 'x', { 'description' => 'hi' } }
|
226
250
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
227
251
|
knife('diff /environments/x.json').should_succeed(/
|
228
252
|
{
|
@@ -236,15 +260,23 @@ EOM
|
|
236
260
|
end
|
237
261
|
|
238
262
|
when_the_repository 'has an environment file with a value in it' do
|
239
|
-
|
263
|
+
before do
|
264
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
265
|
+
end
|
266
|
+
|
240
267
|
when_the_chef_server 'has an environment with the same value' do
|
241
|
-
|
268
|
+
before do
|
269
|
+
environment 'x', { 'description' => 'hi' }
|
270
|
+
end
|
242
271
|
it 'knife diff returns no differences' do
|
243
272
|
knife('diff /environments/x.json').should_succeed ''
|
244
273
|
end
|
245
274
|
end
|
246
275
|
when_the_chef_server 'has an environment with no value' do
|
247
|
-
|
276
|
+
before do
|
277
|
+
environment 'x', {}
|
278
|
+
end
|
279
|
+
|
248
280
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
249
281
|
knife('diff /environments/x.json').should_succeed(/
|
250
282
|
{
|
@@ -256,7 +288,9 @@ EOM
|
|
256
288
|
end
|
257
289
|
end
|
258
290
|
when_the_chef_server 'has an environment with a different value' do
|
259
|
-
|
291
|
+
before do
|
292
|
+
environment 'x', { 'description' => 'lo' }
|
293
|
+
end
|
260
294
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
261
295
|
knife('diff /environments/x.json').should_succeed(/
|
262
296
|
{
|
@@ -271,11 +305,13 @@ EOM
|
|
271
305
|
end
|
272
306
|
|
273
307
|
when_the_chef_server 'has an environment' do
|
274
|
-
environment 'x', {}
|
308
|
+
before { environment 'x', {} }
|
275
309
|
when_the_repository 'has an environment with bad JSON' do
|
276
|
-
file 'environments/x.json', '{'
|
310
|
+
before { file 'environments/x.json', '{' }
|
277
311
|
it 'knife diff reports an error and does a textual diff' do
|
278
|
-
|
312
|
+
error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
|
313
|
+
error_match = Regexp.new(Regexp.escape(error_text))
|
314
|
+
knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match)
|
279
315
|
end
|
280
316
|
end
|
281
317
|
end
|
@@ -283,22 +319,26 @@ EOM
|
|
283
319
|
|
284
320
|
with_versioned_cookbooks do
|
285
321
|
when_the_chef_server "has one of each thing" do
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
322
|
+
before do
|
323
|
+
client 'x', '{}'
|
324
|
+
cookbook 'x', '1.0.0'
|
325
|
+
data_bag 'x', { 'y' => '{}' }
|
326
|
+
environment 'x', '{}'
|
327
|
+
node 'x', '{}'
|
328
|
+
role 'x', '{}'
|
329
|
+
user 'x', '{}'
|
330
|
+
end
|
293
331
|
|
294
332
|
when_the_repository 'has only top-level directories' do
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
333
|
+
before do
|
334
|
+
directory 'clients'
|
335
|
+
directory 'cookbooks'
|
336
|
+
directory 'data_bags'
|
337
|
+
directory 'environments'
|
338
|
+
directory 'nodes'
|
339
|
+
directory 'roles'
|
340
|
+
directory 'users'
|
341
|
+
end
|
302
342
|
|
303
343
|
it 'knife diff reports everything as deleted' do
|
304
344
|
knife('diff --name-status /').should_succeed <<EOM
|
@@ -318,17 +358,19 @@ EOM
|
|
318
358
|
end
|
319
359
|
|
320
360
|
when_the_repository 'has an identical copy of each thing' do
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
361
|
+
before do
|
362
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
363
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
364
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
365
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0")
|
366
|
+
file 'data_bags/x/y.json', {}
|
367
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
368
|
+
file 'environments/x.json', {}
|
369
|
+
file 'nodes/x.json', {}
|
370
|
+
file 'roles/x.json', {}
|
371
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
372
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
373
|
+
end
|
332
374
|
|
333
375
|
it 'knife diff reports no differences' do
|
334
376
|
knife('diff /').should_succeed ''
|
@@ -343,11 +385,14 @@ EOM
|
|
343
385
|
end
|
344
386
|
|
345
387
|
context 'except the role file' do
|
346
|
-
|
388
|
+
before do
|
389
|
+
file 'roles/x.json', <<EOM
|
347
390
|
{
|
348
391
|
"foo": "bar"
|
349
392
|
}
|
350
393
|
EOM
|
394
|
+
end
|
395
|
+
|
351
396
|
it 'knife diff reports the role as different' do
|
352
397
|
knife('diff --name-status /').should_succeed <<EOM
|
353
398
|
M\t/roles/x.json
|
@@ -356,16 +401,18 @@ EOM
|
|
356
401
|
end
|
357
402
|
|
358
403
|
context 'as well as one extra copy of each thing' do
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
404
|
+
before do
|
405
|
+
file 'clients/y.json', {}
|
406
|
+
file 'cookbooks/x-1.0.0/blah.rb', ''
|
407
|
+
file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata("x", "2.0.0")
|
408
|
+
file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata("y", "1.0.0")
|
409
|
+
file 'data_bags/x/z.json', {}
|
410
|
+
file 'data_bags/y/zz.json', {}
|
411
|
+
file 'environments/y.json', {}
|
412
|
+
file 'nodes/y.json', {}
|
413
|
+
file 'roles/y.json', {}
|
414
|
+
file 'users/y.json', {}
|
415
|
+
end
|
369
416
|
|
370
417
|
it 'knife diff reports the new files as added' do
|
371
418
|
knife('diff --name-status /').should_succeed <<EOM
|
@@ -383,7 +430,7 @@ EOM
|
|
383
430
|
end
|
384
431
|
|
385
432
|
context 'when cwd is the data_bags directory' do
|
386
|
-
cwd 'data_bags'
|
433
|
+
before { cwd 'data_bags' }
|
387
434
|
it 'knife diff reports different data bags' do
|
388
435
|
knife('diff --name-status').should_succeed <<EOM
|
389
436
|
A\tx/z.json
|
@@ -416,12 +463,16 @@ EOM
|
|
416
463
|
end
|
417
464
|
|
418
465
|
when_the_repository 'has a cookbook' do
|
419
|
-
|
420
|
-
|
466
|
+
before do
|
467
|
+
file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0")
|
468
|
+
file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', ''
|
469
|
+
end
|
421
470
|
|
422
471
|
when_the_chef_server 'has a later version for the cookbook' do
|
423
|
-
|
424
|
-
|
472
|
+
before do
|
473
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''}
|
474
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' }
|
475
|
+
end
|
425
476
|
|
426
477
|
it 'knife diff /cookbooks shows differences' do
|
427
478
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -435,15 +486,19 @@ EOM
|
|
435
486
|
end
|
436
487
|
|
437
488
|
when_the_chef_server 'has an earlier version for the cookbook' do
|
438
|
-
|
439
|
-
|
489
|
+
before do
|
490
|
+
cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' }
|
491
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' }
|
492
|
+
end
|
440
493
|
it 'knife diff /cookbooks shows the differences' do
|
441
494
|
knife('diff --name-status /cookbooks').should_succeed "D\t/cookbooks/x-0.9.9\n"
|
442
495
|
end
|
443
496
|
end
|
444
497
|
|
445
498
|
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
446
|
-
|
499
|
+
before do
|
500
|
+
cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' }
|
501
|
+
end
|
447
502
|
|
448
503
|
it 'knife diff /cookbooks shows the differences' do
|
449
504
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -454,7 +509,9 @@ EOM
|
|
454
509
|
end
|
455
510
|
|
456
511
|
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
457
|
-
|
512
|
+
before do
|
513
|
+
cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' }
|
514
|
+
end
|
458
515
|
|
459
516
|
it 'knife diff /cookbooks shows the differences' do
|
460
517
|
knife('diff --name-status /cookbooks').should_succeed <<EOM
|
@@ -467,15 +524,15 @@ EOM
|
|
467
524
|
|
468
525
|
context 'json diff tests' do
|
469
526
|
when_the_repository 'has an empty environment file' do
|
470
|
-
file 'environments/x.json', {}
|
527
|
+
before { file 'environments/x.json', {} }
|
471
528
|
when_the_chef_server 'has an empty environment' do
|
472
|
-
environment 'x', {}
|
529
|
+
before { environment 'x', {} }
|
473
530
|
it 'knife diff returns no differences' do
|
474
531
|
knife('diff /environments/x.json').should_succeed ''
|
475
532
|
end
|
476
533
|
end
|
477
534
|
when_the_chef_server 'has an environment with a different value' do
|
478
|
-
environment 'x', { 'description' => 'hi' }
|
535
|
+
before { environment 'x', { 'description' => 'hi' } }
|
479
536
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
480
537
|
knife('diff /environments/x.json').should_succeed(/
|
481
538
|
{
|
@@ -489,15 +546,20 @@ EOM
|
|
489
546
|
end
|
490
547
|
|
491
548
|
when_the_repository 'has an environment file with a value in it' do
|
492
|
-
|
549
|
+
before do
|
550
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
551
|
+
end
|
552
|
+
|
493
553
|
when_the_chef_server 'has an environment with the same value' do
|
494
|
-
|
554
|
+
before do
|
555
|
+
environment 'x', { 'description' => 'hi' }
|
556
|
+
end
|
495
557
|
it 'knife diff returns no differences' do
|
496
558
|
knife('diff /environments/x.json').should_succeed ''
|
497
559
|
end
|
498
560
|
end
|
499
561
|
when_the_chef_server 'has an environment with no value' do
|
500
|
-
environment 'x', {}
|
562
|
+
before { environment 'x', {} }
|
501
563
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
502
564
|
knife('diff /environments/x.json').should_succeed(/
|
503
565
|
{
|
@@ -509,7 +571,9 @@ EOM
|
|
509
571
|
end
|
510
572
|
end
|
511
573
|
when_the_chef_server 'has an environment with a different value' do
|
512
|
-
|
574
|
+
before do
|
575
|
+
environment 'x', { 'description' => 'lo' }
|
576
|
+
end
|
513
577
|
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
514
578
|
knife('diff /environments/x.json').should_succeed(/
|
515
579
|
{
|
@@ -524,11 +588,13 @@ EOM
|
|
524
588
|
end
|
525
589
|
|
526
590
|
when_the_chef_server 'has an environment' do
|
527
|
-
environment 'x', {}
|
591
|
+
before { environment 'x', {} }
|
528
592
|
when_the_repository 'has an environment with bad JSON' do
|
529
|
-
file 'environments/x.json', '{'
|
593
|
+
before { file 'environments/x.json', '{' }
|
530
594
|
it 'knife diff reports an error and does a textual diff' do
|
531
|
-
|
595
|
+
error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
|
596
|
+
error_match = Regexp.new(Regexp.escape(error_text))
|
597
|
+
knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match)
|
532
598
|
end
|
533
599
|
end
|
534
600
|
end
|