microwave 1.0.4 → 11.400.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +155 -0
- data/README.md +89 -0
- data/Rakefile +2 -2
- data/bin/chef-apply +25 -0
- data/bin/chef-shell +34 -0
- data/bin/chef-solo +0 -2
- data/bin/shef +6 -5
- data/lib/chef.rb +2 -4
- data/spec/data/big_json.json +2 -1
- data/spec/data/big_json_plus_one.json +2 -1
- data/spec/data/cookbooks/chefignore +2 -0
- data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/git_bundles/sinatra-test-app-with-callback-files.gitbundle +0 -0
- data/spec/data/git_bundles/sinatra-test-app-with-symlinks.gitbundle +0 -0
- data/spec/data/git_bundles/sinatra-test-app.gitbundle +0 -0
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
- data/spec/data/nodes/default.rb +3 -3
- data/spec/data/nodes/test.example.com.rb +3 -3
- data/spec/data/nodes/test.rb +3 -3
- data/spec/data/partial_one.erb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
- data/spec/data/shef-config.rb +10 -0
- data/spec/functional/dsl/registry_helper_spec.rb +63 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +0 -2
- data/spec/functional/knife/exec_spec.rb +4 -6
- data/spec/functional/knife/smoke_test.rb +34 -0
- data/spec/functional/knife/ssh_spec.rb +64 -3
- data/spec/functional/resource/cookbook_file_spec.rb +33 -2
- data/spec/functional/resource/deploy_revision_spec.rb +515 -0
- data/spec/functional/resource/directory_spec.rb +4 -0
- data/spec/functional/resource/file_spec.rb +56 -22
- data/spec/functional/resource/link_spec.rb +12 -10
- data/spec/functional/resource/registry_spec.rb +572 -0
- data/spec/functional/resource/remote_directory_spec.rb +142 -36
- data/spec/functional/resource/remote_file_spec.rb +28 -3
- data/spec/functional/resource/template_spec.rb +23 -2
- data/spec/functional/run_lock_spec.rb +238 -0
- data/spec/functional/shell_spec.rb +101 -0
- data/spec/functional/tiny_server_spec.rb +5 -4
- data/spec/functional/win32/registry_helper_spec.rb +632 -0
- data/spec/functional/win32/security_spec.rb +37 -0
- data/spec/spec_helper.rb +15 -3
- data/spec/stress/win32/security_spec.rb +5 -5
- data/spec/support/chef_helpers.rb +14 -3
- data/spec/support/lib/chef/resource/cat.rb +3 -5
- data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
- data/spec/support/lib/chef/resource/zen_master.rb +8 -10
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/platform_helpers.rb +18 -0
- data/spec/support/shared/functional/directory_resource.rb +85 -23
- data/spec/support/shared/functional/file_resource.rb +198 -53
- data/spec/support/shared/functional/securable_resource.rb +140 -105
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
- data/spec/support/shared/unit/file_system_support.rb +110 -0
- data/spec/support/shared/unit/platform_introspector.rb +162 -0
- data/spec/tiny_server.rb +29 -10
- data/spec/unit/api_client/registration_spec.rb +172 -0
- data/spec/unit/api_client_spec.rb +156 -103
- data/spec/unit/application/apply.rb +84 -0
- data/spec/unit/application/knife_spec.rb +5 -0
- data/spec/unit/application_spec.rb +57 -2
- data/spec/unit/chef_fs/diff_spec.rb +329 -0
- data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
- data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
- data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
- data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
- data/spec/unit/chef_fs/file_system_spec.rb +136 -0
- data/spec/unit/client_spec.rb +188 -16
- data/spec/unit/config_spec.rb +54 -4
- data/spec/unit/cookbook/chefignore_spec.rb +2 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
- data/spec/unit/cookbook_loader_spec.rb +153 -91
- data/spec/unit/cookbook_manifest_spec.rb +81 -81
- data/spec/unit/cookbook_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +23 -122
- data/spec/unit/digester_spec.rb +50 -0
- data/spec/unit/dsl/data_query_spec.rb +66 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
- data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +126 -10
- data/spec/unit/environment_spec.rb +0 -130
- data/spec/unit/exceptions_spec.rb +2 -3
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +23 -3
- data/spec/unit/json_compat_spec.rb +69 -0
- data/spec/unit/knife/bootstrap_spec.rb +81 -28
- data/spec/unit/knife/client_reregister_spec.rb +23 -22
- data/spec/unit/knife/configure_spec.rb +29 -26
- data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
- data/spec/unit/knife/cookbook_test_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +41 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -1
- data/spec/unit/knife/core/ui_spec.rb +156 -7
- data/spec/unit/knife/data_bag_create_spec.rb +14 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +14 -4
- data/spec/unit/knife/data_bag_from_file_spec.rb +17 -5
- data/spec/unit/knife/data_bag_show_spec.rb +11 -4
- data/spec/unit/knife/index_rebuild_spec.rb +96 -33
- data/spec/unit/knife/knife_help.rb +7 -7
- data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
- data/spec/unit/knife/ssh_spec.rb +121 -15
- data/spec/unit/knife/status_spec.rb +2 -2
- data/spec/unit/knife/user_create_spec.rb +86 -0
- data/spec/unit/knife/user_delete_spec.rb +39 -0
- data/spec/unit/knife/user_edit_spec.rb +42 -0
- data/spec/unit/knife/user_list_spec.rb +32 -0
- data/spec/unit/knife/user_reregister_spec.rb +53 -0
- data/spec/unit/knife/user_show_spec.rb +41 -0
- data/spec/unit/knife_spec.rb +53 -0
- data/spec/unit/lwrp_spec.rb +59 -17
- data/spec/unit/mixin/checksum_spec.rb +2 -2
- data/spec/unit/mixin/deep_merge_spec.rb +56 -491
- data/spec/unit/mixin/deprecation_spec.rb +23 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/securable_spec.rb +5 -3
- data/spec/unit/mixin/template_spec.rb +119 -0
- data/spec/unit/node/attribute_spec.rb +272 -137
- data/spec/unit/node/immutable_collections_spec.rb +139 -0
- data/spec/unit/node_spec.rb +411 -339
- data/spec/unit/platform_spec.rb +8 -8
- data/spec/unit/provider/breakpoint_spec.rb +8 -8
- data/spec/unit/provider/cookbook_file_spec.rb +4 -8
- data/spec/unit/provider/deploy/revision_spec.rb +2 -8
- data/spec/unit/provider/deploy_spec.rb +6 -40
- data/spec/unit/provider/directory_spec.rb +103 -68
- data/spec/unit/provider/erl_call_spec.rb +0 -2
- data/spec/unit/provider/file_spec.rb +69 -59
- data/spec/unit/provider/git_spec.rb +0 -10
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/group/usermod_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +28 -69
- data/spec/unit/provider/ifconfig_spec.rb +2 -2
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/ohai_spec.rb +4 -4
- data/spec/unit/provider/package/apt_spec.rb +0 -1
- data/spec/unit/provider/package/ips_spec.rb +0 -1
- data/spec/unit/provider/package/rubygems_spec.rb +0 -18
- data/spec/unit/provider/package/yum_spec.rb +79 -15
- data/spec/unit/provider/package_spec.rb +7 -5
- data/spec/unit/provider/registry_key_spec.rb +269 -0
- data/spec/unit/provider/remote_directory_spec.rb +24 -7
- data/spec/unit/provider/remote_file_spec.rb +36 -0
- data/spec/unit/provider/route_spec.rb +3 -6
- data/spec/unit/provider/ruby_block_spec.rb +8 -0
- data/spec/unit/provider/service/arch_service_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +4 -4
- data/spec/unit/provider/service/init_service_spec.rb +26 -3
- data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
- data/spec/unit/provider/service/invokercd_service_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/simple_service_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_service_spec.rb +7 -7
- data/spec/unit/provider/service_spec.rb +2 -2
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/template_spec.rb +35 -11
- data/spec/unit/provider/user/dscl_spec.rb +57 -31
- data/spec/unit/provider/user_spec.rb +7 -16
- data/spec/unit/provider_spec.rb +4 -3
- data/spec/unit/recipe_spec.rb +10 -8
- data/spec/unit/registry_helper_spec.rb +376 -0
- data/spec/unit/resource/log_spec.rb +9 -0
- data/spec/unit/resource/registry_key_spec.rb +171 -0
- data/spec/unit/resource/remote_file_spec.rb +21 -23
- data/spec/unit/resource/ruby_block_spec.rb +7 -3
- data/spec/unit/resource/service_spec.rb +11 -0
- data/spec/unit/resource_spec.rb +27 -4
- data/spec/unit/rest/auth_credentials_spec.rb +2 -14
- data/spec/unit/rest_spec.rb +122 -187
- data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
- data/spec/unit/run_context_spec.rb +18 -4
- data/spec/unit/run_list_spec.rb +0 -209
- data/spec/unit/run_lock_spec.rb +37 -0
- data/spec/unit/runner_spec.rb +101 -2
- data/spec/unit/scan_access_control_spec.rb +4 -4
- data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
- data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
- data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +12 -12
- data/spec/unit/shell_out_spec.rb +18 -0
- data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
- data/spec/unit/user_spec.rb +255 -0
- metadata +162 -157
- data/README.rdoc +0 -177
- data/spec/unit/certificate_spec.rb +0 -76
- data/spec/unit/checksum_cache_spec.rb +0 -209
- data/spec/unit/checksum_spec.rb +0 -94
- data/spec/unit/couchdb_spec.rb +0 -274
- data/spec/unit/index_queue_spec.rb +0 -391
- data/spec/unit/json_compat_spect.rb +0 -53
- data/spec/unit/mixin/language_spec.rb +0 -305
- data/spec/unit/openid_registration_spec.rb +0 -153
- data/spec/unit/solr_query/query_transform_spec.rb +0 -454
- data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
- data/spec/unit/solr_query_spec.rb +0 -203
- data/spec/unit/webui_user_spec.rb +0 -238
@@ -235,107 +235,6 @@ describe Chef::Environment do
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
describe "when listing the available cookbooks filtered by policy" do
|
239
|
-
before(:each) do
|
240
|
-
@environment.name "prod"
|
241
|
-
@environment.cookbook_versions({
|
242
|
-
"apt" => "= 1.0.0",
|
243
|
-
"apache2" => "= 2.0.0"
|
244
|
-
})
|
245
|
-
Chef::Environment.stub!(:cdb_load).and_return @environment
|
246
|
-
|
247
|
-
@all_cookbooks = []
|
248
|
-
@all_cookbooks << begin
|
249
|
-
cv = Chef::CookbookVersion.new("apt")
|
250
|
-
cv.version = "1.0.0"
|
251
|
-
cv.recipe_filenames = ["default.rb", "only-in-1-0.rb"]
|
252
|
-
cv
|
253
|
-
end
|
254
|
-
@all_cookbooks << begin
|
255
|
-
cv = Chef::CookbookVersion.new("apt")
|
256
|
-
cv.version = "1.1.0"
|
257
|
-
cv.recipe_filenames = ["default.rb", "only-in-1-1.rb"]
|
258
|
-
cv
|
259
|
-
end
|
260
|
-
@all_cookbooks << begin
|
261
|
-
cv = Chef::CookbookVersion.new("apache2")
|
262
|
-
cv.version = "2.0.0"
|
263
|
-
cv.recipe_filenames = ["default.rb", "mod_ssl.rb"]
|
264
|
-
cv
|
265
|
-
end
|
266
|
-
@all_cookbooks << begin
|
267
|
-
cv = Chef::CookbookVersion.new("god")
|
268
|
-
cv.version = "4.2.0"
|
269
|
-
cv.recipe_filenames = ["default.rb"]
|
270
|
-
cv
|
271
|
-
end
|
272
|
-
Chef::CookbookVersion.stub!(:cdb_list).and_return @all_cookbooks
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should load the environment" do
|
276
|
-
Chef::Environment.should_receive(:cdb_load).with("prod", nil)
|
277
|
-
Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
278
|
-
end
|
279
|
-
|
280
|
-
it "should handle cookbooks with no available version" do
|
281
|
-
@environment.cookbook_versions({
|
282
|
-
"apt" => "> 999.0.0",
|
283
|
-
"apache2" => "= 2.0.0"
|
284
|
-
})
|
285
|
-
Chef::Environment.should_receive(:cdb_load).with("prod", nil)
|
286
|
-
recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod")
|
287
|
-
# order doesn't matter
|
288
|
-
recipes.should =~ ["god", "apache2", "apache2::mod_ssl"]
|
289
|
-
end
|
290
|
-
|
291
|
-
|
292
|
-
it "should load all the cookbook versions" do
|
293
|
-
Chef::CookbookVersion.should_receive(:cdb_list)
|
294
|
-
Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
295
|
-
recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod")
|
296
|
-
recipes.should =~ ["apache2", "apache2::mod_ssl", "apt",
|
297
|
-
"apt::only-in-1-0", "god"]
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should load all the cookbook versions with no policy" do
|
301
|
-
@environment.cookbook_versions({})
|
302
|
-
Chef::CookbookVersion.should_receive(:cdb_list)
|
303
|
-
Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
304
|
-
recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod")
|
305
|
-
recipes.should =~ ["apache2", "apache2::mod_ssl", "apt",
|
306
|
-
"apt::only-in-1-1", "god"]
|
307
|
-
end
|
308
|
-
|
309
|
-
it "should restrict the cookbook versions, as specified in the environment" do
|
310
|
-
res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
311
|
-
res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil
|
312
|
-
res["apache2"].detect {|cb| cb.version == "2.0.0"}.should_not == nil
|
313
|
-
res["god"].detect {|cb| cb.version == "4.2.0"}.should_not == nil
|
314
|
-
end
|
315
|
-
|
316
|
-
it "should produce correct results, regardless of the cookbook order in couch" do
|
317
|
-
# a bug present before the environments feature defaulted to the last CookbookVersion
|
318
|
-
# object for a cookbook as returned from couchdb when fetching cookbooks for a node
|
319
|
-
# this is a regression test
|
320
|
-
@all_cookbooks << begin
|
321
|
-
cv = Chef::CookbookVersion.new("god")
|
322
|
-
cv.version = "0.0.1"
|
323
|
-
cv
|
324
|
-
end
|
325
|
-
res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
326
|
-
res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil
|
327
|
-
res["apache2"].detect {|cb| cb.version == "2.0.0"}.should_not == nil
|
328
|
-
res["god"].detect {|cb| cb.version == "4.2.0"}.should_not == nil
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should return all versions of a cookbook that meet the version requirement" do
|
332
|
-
@environment.cookbook "apt", ">= 1.0.0"
|
333
|
-
res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod")
|
334
|
-
res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil
|
335
|
-
res["apt"].detect {|cb| cb.version == "1.1.0"}.should_not == nil
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
238
|
describe "self.validate_cookbook_versions" do
|
340
239
|
before(:each) do
|
341
240
|
@cookbook_versions = {
|
@@ -376,35 +275,6 @@ describe Chef::Environment do
|
|
376
275
|
end
|
377
276
|
end
|
378
277
|
|
379
|
-
describe "self.create_default_environment" do
|
380
|
-
it "should check if the '_default' environment exists" do
|
381
|
-
@couchdb = Chef::CouchDB.new
|
382
|
-
Chef::CouchDB.stub!(:new).and_return @couchdb
|
383
|
-
Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new)
|
384
|
-
Chef::Environment.create_default_environment
|
385
|
-
end
|
386
|
-
|
387
|
-
it "should not re-create the environment if it exists" do
|
388
|
-
@couchdb = Chef::CouchDB.new
|
389
|
-
Chef::CouchDB.stub!(:new).and_return @couchdb
|
390
|
-
Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_return true
|
391
|
-
Chef::Environment.should_not_receive(:new)
|
392
|
-
Chef::Environment.create_default_environment
|
393
|
-
end
|
394
|
-
|
395
|
-
it "should create the environment if it doesn't exist" do
|
396
|
-
@env = Chef::Environment.new
|
397
|
-
@env.stub!(:cdb_save).and_return true
|
398
|
-
@couchdb = Chef::CouchDB.new
|
399
|
-
Chef::Environment.stub!(:new).and_return @env
|
400
|
-
Chef::CouchDB.stub!(:new).and_return @couchdb
|
401
|
-
|
402
|
-
Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_raise(Chef::Exceptions::CouchDBNotFound)
|
403
|
-
Chef::Environment.should_receive(:new)
|
404
|
-
Chef::Environment.create_default_environment
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
278
|
describe "when updating from a parameter hash" do
|
409
279
|
before do
|
410
280
|
@environment = Chef::Environment.new
|
@@ -8,9 +8,9 @@
|
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
9
|
# you may not use this file except in compliance with the License.
|
10
10
|
# You may obtain a copy of the License at
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Unless required by applicable law or agreed to in writing, software
|
15
15
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
16
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -40,7 +40,6 @@ describe Chef::Exceptions do
|
|
40
40
|
Chef::Exceptions::Group => RuntimeError,
|
41
41
|
Chef::Exceptions::Link => RuntimeError,
|
42
42
|
Chef::Exceptions::Mount => RuntimeError,
|
43
|
-
Chef::Exceptions::CouchDBNotFound => RuntimeError,
|
44
43
|
Chef::Exceptions::PrivateKeyMissing => RuntimeError,
|
45
44
|
Chef::Exceptions::CannotWritePrivateKey => RuntimeError,
|
46
45
|
Chef::Exceptions::RoleNotFound => RuntimeError,
|
@@ -19,12 +19,12 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
21
|
describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
|
22
|
-
include Chef::
|
22
|
+
include Chef::DSL::Recipe
|
23
23
|
|
24
24
|
def run_context
|
25
25
|
node = Chef::Node.new
|
26
|
-
node[:platform] = "ubuntu"
|
27
|
-
node[:platform_version] = "10.04"
|
26
|
+
node.automatic_attrs[:platform] = "ubuntu"
|
27
|
+
node.automatic_attrs[:platform_version] = "10.04"
|
28
28
|
Chef::RunContext.new(node, {}, nil)
|
29
29
|
end
|
30
30
|
|
@@ -112,6 +112,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
|
|
112
112
|
# fake code to run through #recipe_snippet
|
113
113
|
source_file = [ "if true", "var = non_existant", "end" ]
|
114
114
|
IO.stub!(:readlines).and_return(source_file)
|
115
|
+
File.stub!(:exists?).and_return(true)
|
115
116
|
end
|
116
117
|
|
117
118
|
it "parses a Windows path" do
|
@@ -127,6 +128,25 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
|
|
127
128
|
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
|
128
129
|
@inspector.recipe_snippet.should match(/^# In \/home\/btm/)
|
129
130
|
end
|
131
|
+
|
132
|
+
context "when the recipe file does not exist" do
|
133
|
+
before do
|
134
|
+
File.stub!(:exists?).and_return(false)
|
135
|
+
IO.stub!(:readlines).and_raise(Errno::ENOENT)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "does not try to parse a recipe in chef-shell/irb (CHEF-3411)" do
|
139
|
+
@resource.source_line = "(irb#1):1:in `irb_binding'"
|
140
|
+
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
|
141
|
+
@inspector.recipe_snippet.should be_nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it "does not raise an exception trying to load a non-existant file (CHEF-3411)" do
|
145
|
+
@resource.source_line = "/somewhere/in/space"
|
146
|
+
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
|
147
|
+
lambda { @inspector.recipe_snippet }.should_not raise_error
|
148
|
+
end
|
149
|
+
end
|
130
150
|
end
|
131
151
|
|
132
152
|
describe "when examining a resource that confuses the parser" do
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Juanje Ojeda (<juanje.ojeda@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
20
|
+
require 'chef/json_compat'
|
21
|
+
|
22
|
+
describe Chef::JSONCompat do
|
23
|
+
|
24
|
+
describe "with JSON containing an existing class" do
|
25
|
+
let(:json){'{"json_class": "Chef::Role"}'}
|
26
|
+
it "returns an instance of the class instead of a Hash" do
|
27
|
+
Chef::JSONCompat.from_json(json).class.should eq Chef::Role
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
|
32
|
+
require 'chef/sandbox' # Only needed for this test
|
33
|
+
let(:json){'{"json_class": "Chef::Sandbox", "arbitrary": "data"}'}
|
34
|
+
it "returns a Hash, because Chef::Sandbox is a dummy class" do
|
35
|
+
Chef::JSONCompat.from_json(json).should eq({"json_class" => "Chef::Sandbox", "arbitrary" => "data"})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with a file with 300 or less nested entries" do
|
40
|
+
before(:all) do
|
41
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))
|
42
|
+
@hash = Chef::JSONCompat.from_json(@json)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when a big json file is loaded" do
|
46
|
+
it "should create a Hash from the file" do
|
47
|
+
@hash.should be_kind_of(Hash)
|
48
|
+
end
|
49
|
+
it "should has 'test' as a 300th nested value" do
|
50
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
describe "with a file with more than 300 nested entries" do
|
55
|
+
before(:all) do
|
56
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json_plus_one.json'))
|
57
|
+
@hash = Chef::JSONCompat.from_json(@json, {:max_nesting => 301})
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "when a big json file is loaded" do
|
61
|
+
it "should create a Hash from the file" do
|
62
|
+
@hash.should be_kind_of(Hash)
|
63
|
+
end
|
64
|
+
it "should has 'test' as a 301st nested value" do
|
65
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -22,9 +22,21 @@ Chef::Knife::Bootstrap.load_deps
|
|
22
22
|
require 'net/ssh'
|
23
23
|
|
24
24
|
describe Chef::Knife::Bootstrap do
|
25
|
+
before(:all) do
|
26
|
+
@original_config = Chef::Config.hash_dup
|
27
|
+
@original_knife_config = Chef::Config[:knife].dup
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:all) do
|
31
|
+
Chef::Config.configuration = @original_config
|
32
|
+
Chef::Config[:knife] = @original_knife_config
|
33
|
+
end
|
34
|
+
|
25
35
|
before(:each) do
|
26
36
|
Chef::Log.logger = Logger.new(StringIO.new)
|
27
37
|
@knife = Chef::Knife::Bootstrap.new
|
38
|
+
# Merge default settings in.
|
39
|
+
@knife.merge_configs
|
28
40
|
@knife.config[:template_file] = File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "test.erb"))
|
29
41
|
@stdout = StringIO.new
|
30
42
|
@knife.ui.stub!(:stdout).and_return(@stdout)
|
@@ -122,36 +134,77 @@ describe Chef::Knife::Bootstrap do
|
|
122
134
|
@knife.name_args.first.should == "barf"
|
123
135
|
end
|
124
136
|
|
125
|
-
describe "when configuring the underlying knife ssh command"
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
137
|
+
describe "when configuring the underlying knife ssh command"
|
138
|
+
context "from the command line" do
|
139
|
+
before do
|
140
|
+
@knife.name_args = ["foo.example.com"]
|
141
|
+
@knife.config[:ssh_user] = "rooty"
|
142
|
+
@knife.config[:ssh_port] = "4001"
|
143
|
+
@knife.config[:ssh_password] = "open_sesame"
|
144
|
+
Chef::Config[:knife][:ssh_user] = nil
|
145
|
+
Chef::Config[:knife][:ssh_port] = nil
|
146
|
+
@knife.config[:identity_file] = "~/.ssh/me.rsa"
|
147
|
+
@knife.stub!(:read_template).and_return("")
|
148
|
+
@knife_ssh = @knife.knife_ssh
|
149
|
+
end
|
150
|
+
|
151
|
+
it "configures the hostname" do
|
152
|
+
@knife_ssh.name_args.first.should == "foo.example.com"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "configures the ssh user" do
|
156
|
+
@knife_ssh.config[:ssh_user].should == 'rooty'
|
157
|
+
end
|
158
|
+
|
159
|
+
it "configures the ssh password" do
|
160
|
+
@knife_ssh.config[:ssh_password].should == 'open_sesame'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "configures the ssh port" do
|
164
|
+
@knife_ssh.config[:ssh_port].should == '4001'
|
165
|
+
end
|
166
|
+
|
167
|
+
it "configures the ssh identity file" do
|
168
|
+
@knife_ssh.config[:identity_file].should == '~/.ssh/me.rsa'
|
169
|
+
end
|
134
170
|
end
|
135
171
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
172
|
+
context "from the knife config file" do
|
173
|
+
before do
|
174
|
+
@knife.name_args = ["config.example.com"]
|
175
|
+
@knife.config[:ssh_user] = nil
|
176
|
+
@knife.config[:ssh_port] = nil
|
177
|
+
@knife.config[:ssh_gateway] = nil
|
178
|
+
@knife.config[:identity_file] = nil
|
179
|
+
@knife.config[:host_key_verify] = nil
|
180
|
+
Chef::Config[:knife][:ssh_user] = "curiosity"
|
181
|
+
Chef::Config[:knife][:ssh_port] = "2430"
|
182
|
+
Chef::Config[:knife][:identity_file] = "~/.ssh/you.rsa"
|
183
|
+
Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl"
|
184
|
+
Chef::Config[:knife][:host_key_verify] = true
|
185
|
+
@knife.stub!(:read_template).and_return("")
|
186
|
+
@knife_ssh = @knife.knife_ssh
|
187
|
+
end
|
188
|
+
|
189
|
+
it "configures the ssh user" do
|
190
|
+
@knife_ssh.config[:ssh_user].should == 'curiosity'
|
191
|
+
end
|
192
|
+
|
193
|
+
it "configures the ssh port" do
|
194
|
+
@knife_ssh.config[:ssh_port].should == '2430'
|
195
|
+
end
|
196
|
+
|
197
|
+
it "configures the ssh identity file" do
|
198
|
+
@knife_ssh.config[:identity_file].should == '~/.ssh/you.rsa'
|
199
|
+
end
|
200
|
+
|
201
|
+
it "configures the ssh gateway" do
|
202
|
+
@knife_ssh.config[:ssh_gateway].should == 'towel.blinkenlights.nl'
|
203
|
+
end
|
204
|
+
|
205
|
+
it "configures the host key verify mode" do
|
206
|
+
@knife_ssh.config[:host_key_verify].should == true
|
207
|
+
end
|
155
208
|
end
|
156
209
|
|
157
210
|
describe "when falling back to password auth when host key auth fails" do
|
@@ -22,40 +22,41 @@ describe Chef::Knife::ClientReregister do
|
|
22
22
|
before(:each) do
|
23
23
|
@knife = Chef::Knife::ClientReregister.new
|
24
24
|
@knife.name_args = [ 'adam' ]
|
25
|
-
@client_mock = mock('client_mock')
|
26
|
-
@client_mock.stub!(:save).and_return({ 'private_key' => 'foo_key' })
|
27
|
-
Chef::ApiClient.stub!(:load).and_return(@client_mock)
|
25
|
+
@client_mock = mock('client_mock', :private_key => "foo_key")
|
28
26
|
@stdout = StringIO.new
|
29
27
|
@knife.ui.stub!(:stdout).and_return(@stdout)
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@client_mock.should_receive(:save).with(true).and_return({'private_key' => 'foo_key'})
|
36
|
-
@knife.run
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should output the private key' do
|
40
|
-
@knife.run
|
41
|
-
@stdout.string.should match /foo_key/
|
30
|
+
context "when no client name is given on the command line" do
|
31
|
+
before do
|
32
|
+
@knife.name_args = []
|
42
33
|
end
|
43
34
|
|
44
35
|
it 'should print usage and exit when a client name is not provided' do
|
45
|
-
@knife.name_args = []
|
46
36
|
@knife.should_receive(:show_usage)
|
47
37
|
@knife.ui.should_receive(:fatal)
|
48
38
|
lambda { @knife.run }.should raise_error(SystemExit)
|
49
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when not configured for file output' do
|
43
|
+
it 'reregisters the client and prints the key' do
|
44
|
+
Chef::ApiClient.should_receive(:reregister).with('adam').and_return(@client_mock)
|
45
|
+
@knife.run
|
46
|
+
@stdout.string.should match( /foo_key/ )
|
47
|
+
end
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
context 'when configured for file output' do
|
51
|
+
it 'should write the private key to a file' do
|
52
|
+
Chef::ApiClient.should_receive(:reregister).with('adam').and_return(@client_mock)
|
53
|
+
|
54
|
+
@knife.config[:file] = '/tmp/monkeypants'
|
55
|
+
filehandle = StringIO.new
|
56
|
+
File.should_receive(:open).with('/tmp/monkeypants', 'w').and_yield(filehandle)
|
57
|
+
@knife.run
|
58
|
+
filehandle.string.should == "foo_key"
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
61
62
|
end
|