chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +10 -0
- data/README.md +1 -1
- data/distro/common/html/_sources/index.txt +5 -2
- data/distro/common/html/_sources/knife_serve.txt +19 -0
- data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
- data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
- data/distro/common/html/_static/basic.css +1 -1
- data/distro/common/html/_static/doctools.js +1 -1
- data/distro/common/html/_static/searchtools.js +1 -1
- data/distro/common/html/_static/websupport.js +1 -1
- data/distro/common/html/ctl_chef_client.html +19 -9
- data/distro/common/html/ctl_chef_server.html +7 -1
- data/distro/common/html/ctl_chef_shell.html +3 -4
- data/distro/common/html/ctl_chef_solo.html +12 -7
- data/distro/common/html/index.html +19 -12
- data/distro/common/html/knife.html +1 -2
- data/distro/common/html/knife_bootstrap.html +16 -5
- data/distro/common/html/knife_client.html +8 -5
- data/distro/common/html/knife_common_options.html +11 -12
- data/distro/common/html/knife_configure.html +2 -3
- data/distro/common/html/knife_cookbook.html +16 -17
- data/distro/common/html/knife_cookbook_site.html +19 -18
- data/distro/common/html/knife_data_bag.html +6 -7
- data/distro/common/html/knife_delete.html +2 -3
- data/distro/common/html/knife_deps.html +2 -3
- data/distro/common/html/knife_diff.html +3 -4
- data/distro/common/html/knife_download.html +6 -7
- data/distro/common/html/knife_edit.html +0 -1
- data/distro/common/html/knife_environment.html +3 -4
- data/distro/common/html/knife_exec.html +0 -1
- data/distro/common/html/knife_index_rebuild.html +0 -1
- data/distro/common/html/knife_list.html +5 -6
- data/distro/common/html/knife_node.html +13 -6
- data/distro/common/html/knife_raw.html +0 -1
- data/distro/common/html/knife_recipe_list.html +0 -1
- data/distro/common/html/knife_role.html +1 -2
- data/distro/common/html/knife_search.html +2 -3
- data/distro/common/html/knife_serve.html +79 -0
- data/distro/common/html/knife_show.html +1 -2
- data/distro/common/html/knife_ssh.html +2 -3
- data/distro/common/html/knife_ssl_check.html +12 -9
- data/distro/common/html/knife_ssl_fetch.html +9 -10
- data/distro/common/html/knife_status.html +2 -3
- data/distro/common/html/knife_tag.html +0 -1
- data/distro/common/html/knife_upload.html +3 -4
- data/distro/common/html/knife_user.html +2 -3
- data/distro/common/html/knife_using.html +0 -1
- data/distro/common/html/knife_xargs.html +3 -4
- data/distro/common/html/search.html +0 -1
- data/distro/common/html/searchindex.js +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +24 -67
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
- data/lib/chef/chef_fs/command_line.rb +2 -3
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
- data/lib/chef/config.rb +26 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +50 -8
- data/lib/chef/cookbook_uploader.rb +9 -23
- data/lib/chef/cookbook_version.rb +3 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -14
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +2 -24
- data/lib/chef/file_content_management/tempfile.rb +8 -1
- data/lib/chef/formatters/base.rb +0 -7
- data/lib/chef/http.rb +12 -19
- data/lib/chef/http/json_input.rb +12 -1
- data/lib/chef/json_compat.rb +45 -64
- data/lib/chef/knife.rb +2 -5
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +10 -34
- 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 +3 -3
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +0 -24
- data/lib/chef/knife/core/ui.rb +8 -7
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/knife/serve.rb +2 -1
- data/lib/chef/local_mode.rb +105 -0
- data/lib/chef/mixin/file_class.rb +1 -4
- data/lib/chef/mixin/shell_out.rb +15 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
- data/lib/chef/node.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +1 -5
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/cookbook_file.rb +0 -1
- data/lib/chef/provider/deploy.rb +0 -1
- data/lib/chef/provider/deploy/revision.rb +1 -1
- data/lib/chef/provider/env.rb +10 -25
- data/lib/chef/provider/env/windows.rb +23 -10
- data/lib/chef/provider/execute.rb +0 -3
- data/lib/chef/provider/file.rb +0 -3
- data/lib/chef/provider/git.rb +0 -6
- data/lib/chef/provider/group/dscl.rb +9 -27
- data/lib/chef/provider/group/gpasswd.rb +0 -3
- data/lib/chef/provider/group/groupmod.rb +0 -4
- data/lib/chef/provider/group/suse.rb +0 -3
- data/lib/chef/provider/group/usermod.rb +0 -3
- data/lib/chef/provider/link.rb +22 -5
- data/lib/chef/provider/log.rb +15 -4
- data/lib/chef/provider/mdadm.rb +0 -3
- data/lib/chef/provider/mount/mount.rb +0 -2
- data/lib/chef/provider/mount/solaris.rb +0 -2
- data/lib/chef/provider/package.rb +0 -1
- data/lib/chef/provider/package/apt.rb +0 -3
- data/lib/chef/provider/package/dpkg.rb +0 -1
- data/lib/chef/provider/package/easy_install.rb +0 -4
- data/lib/chef/provider/package/freebsd/base.rb +0 -3
- data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
- data/lib/chef/provider/package/freebsd/port.rb +0 -2
- data/lib/chef/provider/package/ips.rb +0 -3
- data/lib/chef/provider/package/paludis.rb +0 -5
- data/lib/chef/provider/package/portage.rb +0 -2
- data/lib/chef/provider/package/rpm.rb +2 -4
- data/lib/chef/provider/package/rubygems.rb +0 -4
- data/lib/chef/provider/package/smartos.rb +0 -3
- data/lib/chef/provider/package/windows/msi.rb +0 -2
- data/lib/chef/provider/package/yum.rb +0 -4
- data/lib/chef/provider/package/zypper.rb +0 -3
- data/lib/chef/provider/registry_key.rb +0 -2
- data/lib/chef/provider/remote_directory.rb +0 -1
- data/lib/chef/provider/remote_file.rb +0 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
- data/lib/chef/provider/remote_file/content.rb +0 -1
- data/lib/chef/provider/remote_file/fetcher.rb +0 -2
- data/lib/chef/provider/remote_file/ftp.rb +0 -1
- data/lib/chef/provider/resource_update.rb +0 -3
- data/lib/chef/provider/service/freebsd.rb +0 -3
- data/lib/chef/provider/service/init.rb +0 -3
- data/lib/chef/provider/service/macosx.rb +0 -1
- data/lib/chef/provider/service/redhat.rb +0 -2
- data/lib/chef/provider/service/simple.rb +0 -3
- data/lib/chef/provider/service/solaris.rb +0 -3
- data/lib/chef/provider/service/systemd.rb +15 -14
- data/lib/chef/provider/service/windows.rb +0 -3
- data/lib/chef/provider/subversion.rb +0 -2
- data/lib/chef/provider/template.rb +0 -2
- data/lib/chef/provider/template/content.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +156 -549
- data/lib/chef/provider/user/solaris.rb +0 -1
- data/lib/chef/provider/user/useradd.rb +0 -3
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource.rb +1 -4
- data/lib/chef/resource/freebsd_package.rb +2 -10
- data/lib/chef/resource/lwrp_base.rb +1 -12
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +0 -1
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/tasks/chef_repo.rake +131 -264
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/path_helper.rb +2 -2
- data/lib/chef/version.rb +9 -1
- data/lib/chef/win32/api/system.rb +0 -9
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/mixin/shell_out_spec.rb +48 -0
- data/spec/functional/resource/base.rb +0 -10
- data/spec/functional/resource/group_spec.rb +1 -5
- data/spec/functional/resource/link_spec.rb +8 -0
- data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
- data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +50 -3
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +3 -3
- data/spec/integration/knife/download_spec.rb +3 -3
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +1 -11
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -9
- data/spec/support/pedant/pedant_config.rb +2 -1
- data/spec/support/pedant/run_pedant.rb +2 -1
- data/spec/support/platform_helpers.rb +5 -24
- data/spec/support/shared/integration/integration_helper.rb +2 -1
- data/spec/support/shared/matchers.rb +17 -0
- data/spec/tiny_server.rb +1 -2
- data/spec/unit/api_client_spec.rb +3 -3
- data/spec/unit/application_spec.rb +9 -32
- data/spec/unit/config_fetcher_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -7
- data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_uploader_spec.rb +160 -0
- data/spec/unit/cookbook_version_spec.rb +0 -4
- data/spec/unit/data_bag_item_spec.rb +1 -5
- data/spec/unit/data_bag_spec.rb +1 -5
- data/spec/unit/deprecation_spec.rb +1 -1
- data/spec/unit/dsl/recipe_spec.rb +12 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
- data/spec/unit/environment_spec.rb +3 -7
- data/spec/unit/exceptions_spec.rb +0 -6
- data/spec/unit/http/json_input_spec.rb +128 -0
- data/spec/unit/json_compat_spec.rb +17 -58
- data/spec/unit/knife/client_create_spec.rb +3 -3
- data/spec/unit/knife/configure_client_spec.rb +6 -5
- data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
- data/spec/unit/knife/cookbook_download_spec.rb +5 -5
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
- data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
- data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
- data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
- data/spec/unit/knife/tag_create_spec.rb +3 -3
- data/spec/unit/knife/tag_delete_spec.rb +3 -3
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +14 -14
- data/spec/unit/lwrp_spec.rb +1 -21
- data/spec/unit/mixin/shell_out_spec.rb +92 -0
- data/spec/unit/node_spec.rb +0 -4
- data/spec/unit/platform/query_helpers_spec.rb +0 -23
- data/spec/unit/provider/env/windows_spec.rb +34 -70
- data/spec/unit/provider/env_spec.rb +11 -76
- data/spec/unit/provider/group/dscl_spec.rb +1 -38
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
- data/spec/unit/provider/user/dscl_spec.rb +264 -660
- data/spec/unit/provider/user/useradd_spec.rb +0 -1
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/provider_spec.rb +12 -0
- data/spec/unit/recipe_spec.rb +0 -41
- data/spec/unit/resource_collection_spec.rb +1 -5
- data/spec/unit/resource_reporter_spec.rb +3 -51
- data/spec/unit/resource_spec.rb +3 -14
- data/spec/unit/rest_spec.rb +1 -4
- data/spec/unit/role_spec.rb +0 -10
- data/spec/unit/run_list_spec.rb +1 -5
- data/spec/unit/user_spec.rb +1 -5
- metadata +20 -100
- data/lib/chef/mixin/windows_env_helper.rb +0 -56
- data/lib/chef/provider/dsc_script.rb +0 -175
- data/lib/chef/resource/dsc_script.rb +0 -126
- data/lib/chef/streaming_cookbook_uploader.rb +0 -205
- data/lib/chef/util/dsc/configuration_generator.rb +0 -115
- data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
- data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
- data/lib/chef/util/dsc/resource_info.rb +0 -26
- data/lib/chef/util/powershell/cmdlet.rb +0 -136
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
- data/spec/functional/resource/dsc_script_spec.rb +0 -382
- data/spec/functional/resource/env_spec.rb +0 -182
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
- data/spec/support/shared/shared_examples.rb +0 -10
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
- data/spec/unit/formatters/base_spec.rb +0 -48
- data/spec/unit/provider/dsc_script_spec.rb +0 -174
- data/spec/unit/resource/dsc_script_spec.rb +0 -98
- data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -34,7 +34,7 @@ describe Chef::Knife::CookbookSiteShare do
|
|
34
34
|
@cookbook_loader.stub(:[]).and_return(@cookbook)
|
35
35
|
Chef::CookbookLoader.stub(:new).and_return(@cookbook_loader)
|
36
36
|
|
37
|
-
@cookbook_uploader = Chef::CookbookUploader.new('herpderp',
|
37
|
+
@cookbook_uploader = Chef::CookbookUploader.new('herpderp', :rest => "norest")
|
38
38
|
Chef::CookbookUploader.stub(:new).and_return(@cookbook_uploader)
|
39
39
|
@cookbook_uploader.stub(:validate_cookbooks).and_return(true)
|
40
40
|
Chef::CookbookSiteStreamingUploader.stub(:create_build_dir).and_return(Dir.mktmpdir)
|
@@ -77,7 +77,7 @@ describe Chef::Knife::CookbookSiteShare do
|
|
77
77
|
|
78
78
|
it 'should make a tarball of the cookbook' do
|
79
79
|
@knife.should_receive(:shell_out!) do |args|
|
80
|
-
args.to_s.should match
|
80
|
+
args.to_s.should match(/tar -czf/)
|
81
81
|
end
|
82
82
|
@knife.run
|
83
83
|
end
|
@@ -108,16 +108,16 @@ describe Chef::Knife::CookbookSiteShare do
|
|
108
108
|
File.stub(:open).and_return(true)
|
109
109
|
end
|
110
110
|
|
111
|
-
it 'should post the cookbook to "
|
112
|
-
response_text = {:uri => '
|
111
|
+
it 'should post the cookbook to "http://cookbooks.opscode.com"' do
|
112
|
+
response_text = {:uri => 'http://cookbooks.opscode.com/cookbooks/cookbook_name'}.to_json
|
113
113
|
@upload_response.stub(:body).and_return(response_text)
|
114
114
|
@upload_response.stub(:code).and_return(201)
|
115
|
-
Chef::CookbookSiteStreamingUploader.should_receive(:post).with(/
|
115
|
+
Chef::CookbookSiteStreamingUploader.should_receive(:post).with(/cookbooks\.opscode\.com/, anything(), anything(), anything())
|
116
116
|
@knife.run
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'should alert the user when a version already exists' do
|
120
|
-
response_text =
|
120
|
+
response_text = {:error_messages => ['Version already exists']}.to_json
|
121
121
|
@upload_response.stub(:body).and_return(response_text)
|
122
122
|
@upload_response.stub(:code).and_return(409)
|
123
123
|
lambda { @knife.run }.should raise_error(SystemExit)
|
@@ -125,7 +125,7 @@ describe Chef::Knife::CookbookSiteShare do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should pass any errors on to the user' do
|
128
|
-
response_text =
|
128
|
+
response_text = {:error_messages => ["You're holding it wrong"]}.to_json
|
129
129
|
@upload_response.stub(:body).and_return(response_text)
|
130
130
|
@upload_response.stub(:code).and_return(403)
|
131
131
|
lambda { @knife.run }.should raise_error(SystemExit)
|
@@ -133,7 +133,7 @@ describe Chef::Knife::CookbookSiteShare do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should print the body if no errors are exposed on failure' do
|
136
|
-
response_text =
|
136
|
+
response_text = {:system_error => "Your call was dropped", :reason => "There's a map for that"}.to_json
|
137
137
|
@upload_response.stub(:body).and_return(response_text)
|
138
138
|
@upload_response.stub(:code).and_return(500)
|
139
139
|
@knife.ui.should_receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered
|
@@ -61,8 +61,9 @@ describe Chef::Knife::CookbookUpload do
|
|
61
61
|
test_cookbook = Chef::CookbookVersion.new('test_cookbook', '/tmp/blah')
|
62
62
|
cookbook_loader.stub(:each).and_yield("test_cookbook", test_cookbook)
|
63
63
|
cookbook_loader.stub(:cookbook_names).and_return(["test_cookbook"])
|
64
|
-
Chef::CookbookUploader.should_receive(:new).
|
65
|
-
{:force=>nil, :concurrency => 3}).
|
64
|
+
Chef::CookbookUploader.should_receive(:new).
|
65
|
+
with( kind_of(Array), { :force => nil, :concurrency => 3}).
|
66
|
+
and_return(double("Chef::CookbookUploader", :upload_cookbooks=> true))
|
66
67
|
knife.run
|
67
68
|
end
|
68
69
|
end
|
@@ -116,13 +116,13 @@ EXPECTED
|
|
116
116
|
describe "when JSON attributes are given" do
|
117
117
|
let(:config) { {:first_boot_attributes => {:baz => :quux}} }
|
118
118
|
it "adds the attributes to first_boot" do
|
119
|
-
|
119
|
+
bootstrap_context.first_boot.to_json.should eq({:baz => :quux, :run_list => run_list}.to_json)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
describe "when JSON attributes are NOT given" do
|
124
124
|
it "sets first_boot equal to run_list" do
|
125
|
-
|
125
|
+
bootstrap_context.first_boot.to_json.should eq({:run_list => run_list}.to_json)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -194,7 +194,7 @@ EXPECTED
|
|
194
194
|
describe "when a bootstrap_version is not specified" do
|
195
195
|
it "should send the latest current to the installer" do
|
196
196
|
# Intentionally hard coded in order not to replicate the logic.
|
197
|
-
bootstrap_context.latest_current_chef_version_string.should eq("-v
|
197
|
+
bootstrap_context.latest_current_chef_version_string.should eq("-v #{Chef::VERSION.to_i}")
|
198
198
|
end
|
199
199
|
end
|
200
200
|
end
|
@@ -73,72 +73,7 @@ describe Chef::Knife::SubcommandLoader do
|
|
73
73
|
@loader.site_subcommands.should include(expected_command)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
#
|
78
|
-
# `knife` in ChefDK isn't from a gem install, it's directly run from a clone
|
79
|
-
# of the source, but there can be one or more versions of chef also installed
|
80
|
-
# as a gem. If the gem install contains a command that doesn't exist in the
|
81
|
-
# source tree of the "primary" chef install, it can be loaded and cause an
|
82
|
-
# error. We also want to ensure that we only load builtin commands from the
|
83
|
-
# "primary" chef install.
|
84
|
-
context "when a different version of chef is also installed as a gem" do
|
85
|
-
|
86
|
-
let(:all_found_commands) do
|
87
|
-
[
|
88
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/bootstrap.rb",
|
89
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_bulk_delete.rb",
|
90
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_create.rb",
|
91
|
-
# We use the fake version 1.0.0 because that version doesn't exist,
|
92
|
-
# which ensures it won't ever equal "chef-#{Chef::VERSION}"
|
93
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/bootstrap.rb",
|
94
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/client_bulk_delete.rb",
|
95
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/client_create.rb",
|
96
|
-
# This command is "extra" compared to what's in the embedded/apps/chef install:
|
97
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-1.0.0/lib/chef/knife/data_bag_secret_options.rb",
|
98
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-vault-2.2.4/lib/chef/knife/decrypt.rb",
|
99
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-spork-1.4.1/lib/chef/knife/spork-bump.rb",
|
100
|
-
# These are fake commands that have names designed to test that the
|
101
|
-
# regex is strict enough
|
102
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-foo-#{Chef::VERSION}/lib/chef/knife/chef-foo.rb",
|
103
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/foo-chef-#{Chef::VERSION}/lib/chef/knife/foo-chef.rb",
|
104
|
-
# In a real scenario, we'd use rubygems APIs to only select the most
|
105
|
-
# recent gem, but for this test we want to check that we're doing the
|
106
|
-
# right thing both when the plugin version matches and does not match
|
107
|
-
# the current chef version. Looking at
|
108
|
-
# `SubcommandLoader::MATCHES_THIS_CHEF_GEM` and
|
109
|
-
# `SubcommandLoader::MATCHES_CHEF_GEM` should make it clear why we want
|
110
|
-
# to test these two cases.
|
111
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-bar-1.0.0/lib/chef/knife/chef-bar.rb",
|
112
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/bar-chef-1.0.0/lib/chef/knife/bar-chef.rb"
|
113
|
-
]
|
114
|
-
end
|
115
|
-
|
116
|
-
let(:expected_valid_commands) do
|
117
|
-
[
|
118
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/bootstrap.rb",
|
119
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_bulk_delete.rb",
|
120
|
-
"/opt/chefdk/embedded/apps/chef/lib/chef/knife/client_create.rb",
|
121
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-vault-2.2.4/lib/chef/knife/decrypt.rb",
|
122
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-spork-1.4.1/lib/chef/knife/spork-bump.rb",
|
123
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-foo-#{Chef::VERSION}/lib/chef/knife/chef-foo.rb",
|
124
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/foo-chef-#{Chef::VERSION}/lib/chef/knife/foo-chef.rb",
|
125
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-bar-1.0.0/lib/chef/knife/chef-bar.rb",
|
126
|
-
"/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/bar-chef-1.0.0/lib/chef/knife/bar-chef.rb"
|
127
|
-
]
|
128
|
-
end
|
129
|
-
|
130
|
-
before do
|
131
|
-
expect(@loader).to receive(:find_files_latest_gems).with("chef/knife/*.rb").and_return(all_found_commands)
|
132
|
-
expect(@loader).to receive(:find_subcommands_via_dirglob).and_return({})
|
133
|
-
end
|
134
|
-
|
135
|
-
it "ignores commands from the non-matching gem install" do
|
136
|
-
expect(@loader.find_subcommands_via_rubygems.values).to eq(expected_valid_commands)
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "finding 3rd party plugins" do
|
76
|
+
describe "finding 3rd party plugins" do
|
142
77
|
let(:env_home) { "/home/alice" }
|
143
78
|
let(:manifest_path) { env_home + "/.chef/plugin_manifest.json" }
|
144
79
|
|
@@ -21,6 +21,7 @@ require 'spec_helper'
|
|
21
21
|
require 'chef/data_bag_item'
|
22
22
|
require 'chef/encrypted_data_bag_item'
|
23
23
|
require 'tempfile'
|
24
|
+
require 'json'
|
24
25
|
|
25
26
|
Chef::Knife::DataBagFromFile.load_deps
|
26
27
|
|
@@ -45,7 +46,7 @@ describe Chef::Knife::DataBagFromFile do
|
|
45
46
|
"greeting" => "hello",
|
46
47
|
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true }}
|
47
48
|
}
|
48
|
-
@db_file.write(
|
49
|
+
@db_file.write(@plain_data.to_json)
|
49
50
|
@db_file.flush
|
50
51
|
@knife.instance_variable_set(:@name_args, ['bag_name', @db_file.path])
|
51
52
|
end
|
@@ -9,15 +9,15 @@ describe Chef::Knife::TagCreate do
|
|
9
9
|
@node = Chef::Node.new
|
10
10
|
@node.stub :save
|
11
11
|
Chef::Node.stub(:load).and_return @node
|
12
|
-
@
|
13
|
-
@knife.ui.stub(:
|
12
|
+
@stderr = StringIO.new
|
13
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "run" do
|
17
17
|
it "can create tags on a node" do
|
18
18
|
@knife.run
|
19
19
|
@node.tags.should == ["happytag"]
|
20
|
-
@
|
20
|
+
@stderr.string.should match /created tags happytag.+node webmonkey.example.com/i
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -10,8 +10,8 @@ describe Chef::Knife::TagDelete do
|
|
10
10
|
@node.stub :save
|
11
11
|
@node.tags << "sadtag" << "happytag"
|
12
12
|
Chef::Node.stub(:load).and_return @node
|
13
|
-
@
|
14
|
-
@knife.ui.stub(:
|
13
|
+
@stderr = StringIO.new
|
14
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "run" do
|
@@ -19,7 +19,7 @@ describe Chef::Knife::TagDelete do
|
|
19
19
|
@node.tags.should == ["sadtag", "happytag"]
|
20
20
|
@knife.run
|
21
21
|
@node.tags.should == ["happytag"]
|
22
|
-
@
|
22
|
+
@stderr.string.should match /deleted.+sadtag/i
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -46,7 +46,7 @@ describe Chef::Knife::UserCreate do
|
|
46
46
|
Chef::User.should_receive(:new).and_return(@user)
|
47
47
|
@user.should_receive(:create)
|
48
48
|
@knife.run
|
49
|
-
@
|
49
|
+
@stderr.string.should match /created user.+a_user/i
|
50
50
|
end
|
51
51
|
|
52
52
|
it "sets the password" do
|
data/spec/unit/knife_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe Chef::Knife do
|
|
41
41
|
Chef::Log.stub(level_sym)
|
42
42
|
end
|
43
43
|
Chef::Knife.stub(:puts)
|
44
|
-
@
|
44
|
+
@stderr = StringIO.new
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "selecting a config file" do
|
@@ -241,7 +241,7 @@ describe Chef::Knife do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it "exits if no subcommand matches the CLI args" do
|
244
|
-
Chef::Knife.ui.stub(:
|
244
|
+
Chef::Knife.ui.stub(:stderr).and_return(@stderr)
|
245
245
|
Chef::Knife.ui.should_receive(:fatal)
|
246
246
|
lambda {Chef::Knife.run(%w{fuuu uuuu fuuuu})}.should raise_error(SystemExit) { |e| e.status.should_not == 0 }
|
247
247
|
end
|
@@ -326,7 +326,7 @@ describe Chef::Knife do
|
|
326
326
|
@knife.stub(:run).and_raise(Net::HTTPServerException.new("401 Unauthorized", response))
|
327
327
|
@knife.run_with_pretty_exceptions
|
328
328
|
@stderr.string.should match(/ERROR: Failed to authenticate to/)
|
329
|
-
@
|
329
|
+
@stderr.string.should match(/Response: y u no syncronize your clock\?/)
|
330
330
|
end
|
331
331
|
|
332
332
|
it "formats 403s nicely" do
|
@@ -337,7 +337,7 @@ describe Chef::Knife do
|
|
337
337
|
@knife.stub(:username).and_return("sadpanda")
|
338
338
|
@knife.run_with_pretty_exceptions
|
339
339
|
@stderr.string.should match(%r[ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action])
|
340
|
-
@
|
340
|
+
@stderr.string.should match(%r[Response: y u no administrator])
|
341
341
|
end
|
342
342
|
|
343
343
|
it "formats 400s nicely" do
|
@@ -347,7 +347,7 @@ describe Chef::Knife do
|
|
347
347
|
@knife.stub(:run).and_raise(Net::HTTPServerException.new("400 Bad Request", response))
|
348
348
|
@knife.run_with_pretty_exceptions
|
349
349
|
@stderr.string.should match(%r[ERROR: The data in your request was invalid])
|
350
|
-
@
|
350
|
+
@stderr.string.should match(%r[Response: y u search wrong])
|
351
351
|
end
|
352
352
|
|
353
353
|
it "formats 404s nicely" do
|
@@ -357,7 +357,7 @@ describe Chef::Knife do
|
|
357
357
|
@knife.stub(:run).and_raise(Net::HTTPServerException.new("404 Not Found", response))
|
358
358
|
@knife.run_with_pretty_exceptions
|
359
359
|
@stderr.string.should match(%r[ERROR: The object you are looking for could not be found])
|
360
|
-
@
|
360
|
+
@stderr.string.should match(%r[Response: nothing to see here])
|
361
361
|
end
|
362
362
|
|
363
363
|
it "formats 500s nicely" do
|
@@ -367,7 +367,7 @@ describe Chef::Knife do
|
|
367
367
|
@knife.stub(:run).and_raise(Net::HTTPFatalError.new("500 Internal Server Error", response))
|
368
368
|
@knife.run_with_pretty_exceptions
|
369
369
|
@stderr.string.should match(%r[ERROR: internal server error])
|
370
|
-
@
|
370
|
+
@stderr.string.should match(%r[Response: sad trombone])
|
371
371
|
end
|
372
372
|
|
373
373
|
it "formats 502s nicely" do
|
@@ -377,7 +377,7 @@ describe Chef::Knife do
|
|
377
377
|
@knife.stub(:run).and_raise(Net::HTTPFatalError.new("502 Bad Gateway", response))
|
378
378
|
@knife.run_with_pretty_exceptions
|
379
379
|
@stderr.string.should match(%r[ERROR: bad gateway])
|
380
|
-
@
|
380
|
+
@stderr.string.should match(%r[Response: sadder trombone])
|
381
381
|
end
|
382
382
|
|
383
383
|
it "formats 503s nicely" do
|
@@ -387,7 +387,7 @@ describe Chef::Knife do
|
|
387
387
|
@knife.stub(:run).and_raise(Net::HTTPFatalError.new("503 Service Unavailable", response))
|
388
388
|
@knife.run_with_pretty_exceptions
|
389
389
|
@stderr.string.should match(%r[ERROR: Service temporarily unavailable])
|
390
|
-
@
|
390
|
+
@stderr.string.should match(%r[Response: saddest trombone])
|
391
391
|
end
|
392
392
|
|
393
393
|
it "formats other HTTP errors nicely" do
|
@@ -397,15 +397,15 @@ describe Chef::Knife do
|
|
397
397
|
@knife.stub(:run).and_raise(Net::HTTPServerException.new("402 Payment Required", response))
|
398
398
|
@knife.run_with_pretty_exceptions
|
399
399
|
@stderr.string.should match(%r[ERROR: Payment Required])
|
400
|
-
@
|
400
|
+
@stderr.string.should match(%r[Response: nobugfixtillyoubuy])
|
401
401
|
end
|
402
402
|
|
403
403
|
it "formats NameError and NoMethodError nicely" do
|
404
404
|
@knife.stub(:run).and_raise(NameError.new("Undefined constant FUUU"))
|
405
405
|
@knife.run_with_pretty_exceptions
|
406
406
|
@stderr.string.should match(%r[ERROR: knife encountered an unexpected error])
|
407
|
-
@
|
408
|
-
@
|
407
|
+
@stderr.string.should match(%r[This may be a bug in the 'knife' knife command or plugin])
|
408
|
+
@stderr.string.should match(%r[Exception: NameError: Undefined constant FUUU])
|
409
409
|
end
|
410
410
|
|
411
411
|
it "formats missing private key errors nicely" do
|
@@ -413,7 +413,7 @@ describe Chef::Knife do
|
|
413
413
|
@knife.stub(:api_key).and_return("/home/root/.chef/no-key-here.pem")
|
414
414
|
@knife.run_with_pretty_exceptions
|
415
415
|
@stderr.string.should match(%r[ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem])
|
416
|
-
@
|
416
|
+
@stderr.string.should match(%r[Check your configuration file and ensure that your private key is readable])
|
417
417
|
end
|
418
418
|
|
419
419
|
it "formats connection refused errors nicely" do
|
@@ -423,7 +423,7 @@ describe Chef::Knife do
|
|
423
423
|
# *nix = Errno::ECONNREFUSED: Connection refused
|
424
424
|
# win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it.
|
425
425
|
@stderr.string.should match(%r[ERROR: Network Error: .* - y u no shut up])
|
426
|
-
@
|
426
|
+
@stderr.string.should match(%r[Check your knife configuration and network settings])
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
data/spec/unit/lwrp_spec.rb
CHANGED
@@ -231,28 +231,8 @@ describe "LWRP" do
|
|
231
231
|
expect(child.default_action).to eq(:dont_eat)
|
232
232
|
end
|
233
233
|
end
|
234
|
-
|
235
|
-
context "when actions are already defined" do
|
236
|
-
let(:child) do
|
237
|
-
Class.new(parent) do
|
238
|
-
actions :eat
|
239
|
-
actions :sleep
|
240
|
-
actions :drink
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
def raise_if_deprecated!
|
245
|
-
if Chef::VERSION.split('.').first.to_i > 11
|
246
|
-
raise "This test should be removed and the associated code should be removed!"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
it "ammends actions when they are already defined" do
|
251
|
-
raise_if_deprecated!
|
252
|
-
expect(child.actions).to eq([:eat, :sleep, :drink])
|
253
|
-
end
|
254
|
-
end
|
255
234
|
end
|
235
|
+
|
256
236
|
end
|
257
237
|
|
258
238
|
describe "Lightweight Chef::Provider" do
|
@@ -104,6 +104,98 @@ describe Chef::Mixin::ShellOut do
|
|
104
104
|
|
105
105
|
should_emit_deprecation_warning_about :command_log_prepend, :log_tag
|
106
106
|
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#shell_out_with_systems_locale" do
|
110
|
+
before(:each) do
|
111
|
+
@original_env = ENV.to_hash
|
112
|
+
ENV.clear
|
113
|
+
end
|
114
|
+
|
115
|
+
after(:each) do
|
116
|
+
ENV.clear
|
117
|
+
ENV.update(@original_env)
|
118
|
+
end
|
119
|
+
|
120
|
+
let(:shell_out) { Chef::Mixin::ShellOut }
|
121
|
+
let(:cmd) { "echo '#{rand(1000)}'" }
|
122
|
+
|
123
|
+
describe "when the last argument is a Hash" do
|
124
|
+
describe "and environment is an option" do
|
125
|
+
it "should not change environment['LC_ALL'] when set to nil" do
|
126
|
+
options = { :environment => { 'LC_ALL' => nil } }
|
127
|
+
shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
|
128
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should not change environment['LC_ALL'] when set to non-nil" do
|
132
|
+
options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
|
133
|
+
shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
|
134
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
|
138
|
+
options = { :environment => { 'HOME' => '/Users/morty' } }
|
139
|
+
shell_out.should_receive(:shell_out).with(
|
140
|
+
cmd,
|
141
|
+
{ :environment => {
|
142
|
+
'HOME' => '/Users/morty',
|
143
|
+
'LC_ALL' => nil }
|
144
|
+
}
|
145
|
+
).and_return(true)
|
146
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
147
|
+
end
|
148
|
+
end
|
107
149
|
|
150
|
+
describe "and env is an option" do
|
151
|
+
it "should not change env when set to nil" do
|
152
|
+
options = { :env => { 'LC_ALL' => nil } }
|
153
|
+
shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
|
154
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should not change env when set to non-nil" do
|
158
|
+
options = { :env => { 'LC_ALL' => 'en_US.UTF-8'}}
|
159
|
+
shell_out.should_receive(:shell_out).with(cmd, options).and_return(true)
|
160
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should set env['LC_ALL'] to nil when 'LC_ALL' not present" do
|
164
|
+
options = { :env => { 'HOME' => '/Users/morty' } }
|
165
|
+
shell_out.should_receive(:shell_out).with(
|
166
|
+
cmd,
|
167
|
+
{ :env => {
|
168
|
+
'HOME' => '/Users/morty',
|
169
|
+
'LC_ALL' => nil }
|
170
|
+
}
|
171
|
+
).and_return(true)
|
172
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "and no env/environment option is present" do
|
177
|
+
it "should add environment option and set environment['LC_ALL'] to nil" do
|
178
|
+
options = { :user => 'morty' }
|
179
|
+
shell_out.should_receive(:shell_out).with(
|
180
|
+
cmd,
|
181
|
+
{ :environment => { 'LC_ALL' => nil },
|
182
|
+
:user => 'morty'
|
183
|
+
}
|
184
|
+
).and_return(true)
|
185
|
+
shell_out.shell_out_with_systems_locale(cmd, options)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "when the last argument is not a Hash" do
|
191
|
+
it "should add environment options and set environment['LC_ALL'] to nil" do
|
192
|
+
shell_out.should_receive(:shell_out).with(
|
193
|
+
cmd,
|
194
|
+
{ :environment => { 'LC_ALL' => nil } }
|
195
|
+
).and_return(true)
|
196
|
+
shell_out.shell_out_with_systems_locale(cmd)
|
197
|
+
end
|
198
|
+
end
|
108
199
|
end
|
200
|
+
|
109
201
|
end
|