chef 15.10.12 → 15.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -10
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/chef-universal-mingw32.gemspec +2 -2
- data/chef.gemspec +3 -3
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/application/apply.rb +2 -2
- data/lib/chef/application/exit_code.rb +2 -2
- data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +3 -3
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +4 -4
- data/lib/chef/data_bag.rb +2 -2
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/deprecated.rb +13 -1
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +3 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
- data/lib/chef/http.rb +2 -1
- data/lib/chef/knife.rb +26 -20
- data/lib/chef/knife/bootstrap.rb +30 -31
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
- data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
- data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_show.rb +1 -1
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +21 -2
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/create_path.rb +8 -8
- data/lib/chef/mixin/openssl_helper.rb +26 -3
- data/lib/chef/mixin/template.rb +1 -0
- data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
- data/lib/chef/node_map.rb +5 -2
- data/lib/chef/provider/mount/solaris.rb +0 -1
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +4 -3
- data/lib/chef/provider/package/msu.rb +1 -0
- data/lib/chef/provider/package/powershell.rb +5 -1
- data/lib/chef/provider/package/snap.rb +96 -27
- data/lib/chef/provider/package/zypper.rb +0 -1
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/debian.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +3 -3
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/windows_task.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/provider/zypper_repository.rb +31 -11
- data/lib/chef/resource.rb +2 -0
- data/lib/chef/resource/archive_file.rb +28 -8
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cron_access.rb +13 -5
- data/lib/chef/resource/cron_d.rb +1 -1
- data/lib/chef/resource/hostname.rb +19 -18
- data/lib/chef/resource/launchd.rb +4 -4
- data/lib/chef/resource/lwrp_base.rb +7 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -3
- data/lib/chef/resource/msu_package.rb +5 -0
- data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
- data/lib/chef/resource/sudo.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +6 -2
- data/lib/chef/resource/windows_firewall_rule.rb +8 -4
- data/lib/chef/resource/windows_font.rb +2 -1
- data/lib/chef/resource/windows_share.rb +4 -4
- data/lib/chef/resource/windows_task.rb +13 -13
- data/lib/chef/resource_inspector.rb +4 -3
- data/lib/chef/role.rb +2 -2
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/shell_session.rb +2 -0
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/win32/api/command_line_helper.rb +89 -0
- data/lib/chef/win32/api/file.rb +18 -18
- data/lib/chef/win32/file.rb +3 -3
- data/lib/chef/win32/process.rb +2 -2
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/resource/aix_service_spec.rb +0 -1
- data/spec/functional/resource/aixinit_service_spec.rb +7 -8
- data/spec/functional/resource/apt_package_spec.rb +0 -1
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +0 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/insserv_spec.rb +4 -5
- data/spec/functional/resource/link_spec.rb +17 -17
- data/spec/functional/resource/msu_package_spec.rb +5 -2
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +2 -2
- data/spec/functional/resource/user/mac_user_spec.rb +2 -2
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_font_spec.rb +49 -0
- data/spec/functional/resource/windows_task_spec.rb +8 -8
- data/spec/functional/run_lock_spec.rb +2 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
- data/spec/integration/recipes/resource_load_spec.rb +1 -0
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +26 -19
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/platform_helpers.rb +12 -42
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/directory_resource.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +3 -3
- data/spec/support/shared/integration/knife_support.rb +2 -5
- data/spec/unit/application_spec.rb +7 -0
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
- data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/data_collector_spec.rb +1 -1
- data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/json_compat_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +26 -29
- data/spec/unit/knife/cookbook_download_spec.rb +4 -4
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
- data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
- data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/ssh_spec.rb +2 -2
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +4 -4
- data/spec/unit/mixin/securable_spec.rb +0 -1
- data/spec/unit/mixin/user_context_spec.rb +1 -9
- data/spec/unit/property_spec.rb +6 -6
- data/spec/unit/provider/apt_repository_spec.rb +2 -2
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/osx_profile_spec.rb +2 -2
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
- data/spec/unit/provider/package/msu_spec.rb +3 -3
- data/spec/unit/provider/package/powershell_spec.rb +95 -86
- data/spec/unit/provider/package/rubygems_spec.rb +5 -10
- data/spec/unit/provider/package/snap_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +30 -53
- data/spec/unit/provider/service/arch_service_spec.rb +3 -2
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
- data/spec/unit/provider/service/macosx_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider/service/windows_spec.rb +2 -6
- data/spec/unit/provider/systemd_unit_spec.rb +28 -24
- data/spec/unit/provider/zypper_repository_spec.rb +75 -25
- data/spec/unit/provider_resolver_spec.rb +9 -9
- data/spec/unit/provider_spec.rb +1 -0
- data/spec/unit/resource/archive_file_spec.rb +11 -2
- data/spec/unit/resource/msu_package_spec.rb +4 -0
- data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
- data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/resource/windows_package_spec.rb +1 -0
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/windows_uac_spec.rb +2 -2
- data/spec/unit/resource/yum_repository_spec.rb +21 -21
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +1 -1
- data/spec/unit/role_spec.rb +11 -11
- data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +1 -1
- data/spec/unit/run_lock_spec.rb +1 -1
- data/spec/unit/scan_access_control_spec.rb +1 -1
- data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
- data/spec/unit/win32/security_spec.rb +4 -3
- data/tasks/rspec.rb +5 -13
- metadata +24 -16
@@ -61,6 +61,7 @@ describe Chef::EventDispatch::Dispatcher do
|
|
61
61
|
let(:event_sink) do
|
62
62
|
Class.new(Chef::EventDispatch::Base) do
|
63
63
|
attr_reader :synchronized_cookbook_args
|
64
|
+
|
64
65
|
def synchronized_cookbook(cookbook_name)
|
65
66
|
@synchronized_cookbook_args = [cookbook_name]
|
66
67
|
end
|
@@ -79,6 +80,7 @@ describe Chef::EventDispatch::Dispatcher do
|
|
79
80
|
let(:event_sink_1) do
|
80
81
|
Class.new(Chef::EventDispatch::Base) do
|
81
82
|
attr_reader :synchronized_cookbook_args
|
83
|
+
|
82
84
|
def synchronized_cookbook(cookbook_name)
|
83
85
|
@synchronized_cookbook_args = [cookbook_name]
|
84
86
|
end
|
@@ -87,6 +89,7 @@ describe Chef::EventDispatch::Dispatcher do
|
|
87
89
|
let(:event_sink_2) do
|
88
90
|
Class.new(Chef::EventDispatch::Base) do
|
89
91
|
attr_reader :synchronized_cookbook_args
|
92
|
+
|
90
93
|
def synchronized_cookbook(cookbook_name, cookbook)
|
91
94
|
@synchronized_cookbook_args = [cookbook_name, cookbook]
|
92
95
|
end
|
@@ -93,7 +93,7 @@ describe Chef::FileAccessControl do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "wraps uids to their negative complements to correctly handle negative uids" do
|
96
|
-
# More:
|
96
|
+
# More: macOS (at least) has negative UIDs for 'nobody' and some other
|
97
97
|
# users. Ruby doesn't believe in negative UIDs so you get the diminished radix
|
98
98
|
# complement (i.e., it wraps around the maximum size of C unsigned int) of these
|
99
99
|
# uids. So we have to get ruby and negative uids to smoke the peace pipe
|
@@ -206,7 +206,7 @@ describe Chef::Knife::Bootstrap do
|
|
206
206
|
end
|
207
207
|
|
208
208
|
before(:each) do
|
209
|
-
expect(File).to receive(:
|
209
|
+
expect(File).to receive(:exist?).with(bootstrap_template).and_return(false)
|
210
210
|
end
|
211
211
|
|
212
212
|
context "when file is available everywhere" do
|
@@ -215,7 +215,7 @@ describe Chef::Knife::Bootstrap do
|
|
215
215
|
configure_env_home
|
216
216
|
configure_gem_files
|
217
217
|
|
218
|
-
expect(File).to receive(:
|
218
|
+
expect(File).to receive(:exist?).with(builtin_template_path).and_return(true)
|
219
219
|
end
|
220
220
|
|
221
221
|
it "should load the template from built-in templates" do
|
@@ -229,8 +229,8 @@ describe Chef::Knife::Bootstrap do
|
|
229
229
|
configure_env_home
|
230
230
|
configure_gem_files
|
231
231
|
|
232
|
-
expect(File).to receive(:
|
233
|
-
expect(File).to receive(:
|
232
|
+
expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
|
233
|
+
expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(true)
|
234
234
|
|
235
235
|
it "should load the template from chef_config_dir" do
|
236
236
|
knife.find_template.should eq(chef_config_dir_template_path)
|
@@ -244,9 +244,9 @@ describe Chef::Knife::Bootstrap do
|
|
244
244
|
configure_env_home
|
245
245
|
configure_gem_files
|
246
246
|
|
247
|
-
expect(File).to receive(:
|
248
|
-
expect(File).to receive(:
|
249
|
-
expect(File).to receive(:
|
247
|
+
expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
|
248
|
+
expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
|
249
|
+
expect(File).to receive(:exist?).with(env_home_template_path).and_return(true)
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should load the template from chef_config_dir" do
|
@@ -260,10 +260,10 @@ describe Chef::Knife::Bootstrap do
|
|
260
260
|
configure_env_home
|
261
261
|
configure_gem_files
|
262
262
|
|
263
|
-
expect(File).to receive(:
|
264
|
-
expect(File).to receive(:
|
265
|
-
expect(File).to receive(:
|
266
|
-
expect(File).to receive(:
|
263
|
+
expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
|
264
|
+
expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
|
265
|
+
expect(File).to receive(:exist?).with(env_home_template_path).and_return(false)
|
266
|
+
expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
|
267
267
|
end
|
268
268
|
|
269
269
|
it "should load the template from Gem files" do
|
@@ -277,9 +277,9 @@ describe Chef::Knife::Bootstrap do
|
|
277
277
|
configure_gem_files
|
278
278
|
allow(Chef::Util::PathHelper).to receive(:home).with(".chef", "bootstrap", "example.erb").and_return(nil)
|
279
279
|
|
280
|
-
expect(File).to receive(:
|
281
|
-
expect(File).to receive(:
|
282
|
-
expect(File).to receive(:
|
280
|
+
expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
|
281
|
+
expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
|
282
|
+
expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
|
283
283
|
end
|
284
284
|
|
285
285
|
it "should load the template from Gem files" do
|
@@ -854,6 +854,7 @@ describe Chef::Knife::Bootstrap do
|
|
854
854
|
context "and no CLI options have been given" do
|
855
855
|
before do
|
856
856
|
knife.config = {}
|
857
|
+
knife.merge_configs
|
857
858
|
end
|
858
859
|
let(:expected_result) do
|
859
860
|
{
|
@@ -905,6 +906,7 @@ describe Chef::Knife::Bootstrap do
|
|
905
906
|
knife.config[:connection_port] = 12
|
906
907
|
knife.config[:winrm_port] = "13" # indirectly verify we're not looking for the wrong CLI flag
|
907
908
|
knife.config[:connection_password] = "lobster"
|
909
|
+
knife.merge_configs
|
908
910
|
end
|
909
911
|
|
910
912
|
it "generates a config hash using the CLI options when available and falling back to Chef::Config values" do
|
@@ -1004,6 +1006,7 @@ describe Chef::Knife::Bootstrap do
|
|
1004
1006
|
context "and no CLI options have been given" do
|
1005
1007
|
before do
|
1006
1008
|
knife.config = {}
|
1009
|
+
knife.merge_configs
|
1007
1010
|
end
|
1008
1011
|
let(:expected_result) do
|
1009
1012
|
{
|
@@ -1018,7 +1021,7 @@ describe Chef::Knife::Bootstrap do
|
|
1018
1021
|
keys_only: true,
|
1019
1022
|
key_files: ["/identity.pem", "/gateway.pem"],
|
1020
1023
|
sudo: false,
|
1021
|
-
verify_host_key:
|
1024
|
+
verify_host_key: false,
|
1022
1025
|
port: 9999,
|
1023
1026
|
non_interactive: true,
|
1024
1027
|
}
|
@@ -1056,6 +1059,7 @@ describe Chef::Knife::Bootstrap do
|
|
1056
1059
|
knife.config[:use_sudo] = true
|
1057
1060
|
knife.config[:use_sudo_pasword] = true
|
1058
1061
|
knife.config[:ssh_forward_agent] = true
|
1062
|
+
knife.merge_configs
|
1059
1063
|
end
|
1060
1064
|
|
1061
1065
|
let(:expected_result) do
|
@@ -1072,7 +1076,7 @@ describe Chef::Knife::Bootstrap do
|
|
1072
1076
|
keys_only: false, # implied false from config password present
|
1073
1077
|
key_files: ["/identity.pem", "/gateway.pem"], # Config
|
1074
1078
|
sudo: true, # ccli
|
1075
|
-
verify_host_key:
|
1079
|
+
verify_host_key: false, # Config
|
1076
1080
|
port: 12, # cli
|
1077
1081
|
non_interactive: true,
|
1078
1082
|
}
|
@@ -1743,8 +1747,8 @@ describe Chef::Knife::Bootstrap do
|
|
1743
1747
|
allow(vault_handler_mock).to receive(:doing_chef_vault?).and_return false
|
1744
1748
|
end
|
1745
1749
|
|
1746
|
-
it "shows a message" do
|
1747
|
-
expect(knife.ui).to receive(:
|
1750
|
+
it "shows a warning message" do
|
1751
|
+
expect(knife.ui).to receive(:warn).twice
|
1748
1752
|
knife.register_client
|
1749
1753
|
end
|
1750
1754
|
end
|
@@ -1940,22 +1944,15 @@ describe Chef::Knife::Bootstrap do
|
|
1940
1944
|
Chef::Config[:knife][:test_key_a] = "a from Chef::Config"
|
1941
1945
|
Chef::Config[:knife][:test_key_c] = "c from Chef::Config"
|
1942
1946
|
Chef::Config[:knife][:alt_test_key_c] = "alt c from Chef::Config"
|
1947
|
+
knife.merge_configs
|
1943
1948
|
end
|
1944
1949
|
|
1945
|
-
it "returns
|
1946
|
-
expect(knife.config_value(:
|
1947
|
-
end
|
1948
|
-
|
1949
|
-
it "returns CLI value when key is provided by CLI and Chef::Config" do
|
1950
|
-
expect(knife.config_value(:test_key_a)).to eq "a from cli"
|
1951
|
-
end
|
1952
|
-
|
1953
|
-
it "returns Chef::Config value whent he key is only provided by Chef::Config" do
|
1954
|
-
expect(knife.config_value(:test_key_c)).to eq "c from Chef::Config"
|
1950
|
+
it "returns the Chef::Config value from the cli when the CLI key is set" do
|
1951
|
+
expect(knife.config_value(:test_key_a, :alt_test_key_c)).to eq "a from cli"
|
1955
1952
|
end
|
1956
1953
|
|
1957
1954
|
it "returns the Chef::Config value from the alternative key when the CLI key is not set" do
|
1958
|
-
expect(knife.config_value(:
|
1955
|
+
expect(knife.config_value(:test_key_d, :alt_test_key_c)).to eq "alt c from Chef::Config"
|
1959
1956
|
end
|
1960
1957
|
|
1961
1958
|
it "returns the default value when the key is not provided by CLI or Chef::Config" do
|
@@ -94,7 +94,7 @@ describe Chef::Knife::CookbookDownload do
|
|
94
94
|
let (:manifest_data) { { all_files: [] } }
|
95
95
|
it "should determine which version to download" do
|
96
96
|
expect(@knife).to receive(:determine_version).and_return("1.0.0")
|
97
|
-
expect(File).to receive(:
|
97
|
+
expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
|
98
98
|
@knife.run
|
99
99
|
end
|
100
100
|
end
|
@@ -111,7 +111,7 @@ describe Chef::Knife::CookbookDownload do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should print an error and exit if the cookbook download directory already exists" do
|
114
|
-
expect(File).to receive(:
|
114
|
+
expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
|
115
115
|
expect(@knife.ui).to receive(:fatal).with(%r{/var/tmp/chef/foobar-1\.0\.0 exists}i)
|
116
116
|
expect { @knife.run }.to raise_error(SystemExit)
|
117
117
|
end
|
@@ -135,7 +135,7 @@ describe Chef::Knife::CookbookDownload do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should download the cookbook when the cookbook download directory doesn't exist" do
|
138
|
-
expect(File).to receive(:
|
138
|
+
expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
|
139
139
|
@knife.run
|
140
140
|
%w{attributes recipes templates}.each do |segment|
|
141
141
|
expect(@stderr.string).to match /downloading #{segment}/im
|
@@ -147,7 +147,7 @@ describe Chef::Knife::CookbookDownload do
|
|
147
147
|
describe "with -f or --force" do
|
148
148
|
it "should remove the existing the cookbook download directory if it exists" do
|
149
149
|
@knife.config[:force] = true
|
150
|
-
expect(File).to receive(:
|
150
|
+
expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
|
151
151
|
expect(FileUtils).to receive(:rm_rf).with("/var/tmp/chef/foobar-1.0.0")
|
152
152
|
@knife.run
|
153
153
|
end
|
@@ -323,19 +323,18 @@ describe Chef::Knife::CookbookUpload do
|
|
323
323
|
|
324
324
|
context "when cookbook path is an array" do
|
325
325
|
it "should warn users that no cookbooks exist" do
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
)
|
326
|
+
cookbook_path = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
|
327
|
+
knife.config[:cookbook_path] = [cookbook_path, "/home/user/cookbooks"]
|
328
|
+
expect(knife.ui).to receive(:warn).with("Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(", ")}'. Use --cookbook-path to specify the desired path.")
|
330
329
|
knife.run
|
331
330
|
end
|
332
331
|
end
|
333
332
|
|
334
333
|
context "when cookbook path is a string" do
|
335
334
|
it "should warn users that no cookbooks exist" do
|
336
|
-
knife.config[:cookbook_path] = "/chef-repo/cookbooks"
|
335
|
+
knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
|
337
336
|
expect(knife.ui).to receive(:warn).with(
|
338
|
-
|
337
|
+
"Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'. Use --cookbook-path to specify the desired path."
|
339
338
|
)
|
340
339
|
knife.run
|
341
340
|
end
|
@@ -50,7 +50,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
|
|
50
50
|
|
51
51
|
describe "#list_commands" do
|
52
52
|
before do
|
53
|
-
allow(File).to receive(:
|
53
|
+
allow(File).to receive(:exist?).and_return(true)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "lists all commands by category when no argument is given" do
|
@@ -63,7 +63,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
|
|
63
63
|
|
64
64
|
context "when the plugin path is invalid" do
|
65
65
|
before do
|
66
|
-
expect(File).to receive(:
|
66
|
+
expect(File).to receive(:exist?).with("/file/for/plugin/b").and_return(false)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "lists all commands by category when no argument is given" do
|
@@ -90,7 +90,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "loads the correct file and returns true if the command exists" do
|
93
|
-
allow(File).to receive(:
|
93
|
+
allow(File).to receive(:exist?).and_return(true)
|
94
94
|
expect(Kernel).to receive(:load).with("/file/for/plugin/a").and_return(true)
|
95
95
|
expect(loader.load_command(["cool_a"])).to eq(true)
|
96
96
|
end
|
@@ -184,6 +184,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
describe "#start_chef" do
|
188
|
+
it "returns the expected string" do
|
189
|
+
expect(bootstrap_context.start_chef).to match(%r{SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\/opscode\/chef\\bin;C:\/opscode\/chef\\embedded\\bin\;%PATH%\"\n})
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
187
193
|
describe "msi_url" do
|
188
194
|
context "when msi_url config option is not set" do
|
189
195
|
let(:config) { { channel: "stable" } }
|
@@ -21,8 +21,8 @@ require "spec_helper"
|
|
21
21
|
|
22
22
|
describe Chef::Knife::RoleEnvRunListAdd do
|
23
23
|
before(:each) do
|
24
|
-
# Chef::Config[:role_name] = "websimian"
|
25
|
-
# Chef::Config[:env_name] = "QA"
|
24
|
+
# Chef::Config[:role_name] = "websimian"
|
25
|
+
# Chef::Config[:env_name] = "QA"
|
26
26
|
@knife = Chef::Knife::RoleEnvRunListAdd.new
|
27
27
|
@knife.config = {
|
28
28
|
after: nil,
|
@@ -36,10 +36,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
|
|
36
36
|
|
37
37
|
describe "run" do
|
38
38
|
|
39
|
-
# it "should display all the things" do
|
40
|
-
# @knife.run
|
41
|
-
# @role.to_json.should == 'show all the things'
|
42
|
-
# end
|
39
|
+
# it "should display all the things" do
|
40
|
+
# @knife.run
|
41
|
+
# @role.to_json.should == 'show all the things'
|
42
|
+
# end
|
43
43
|
|
44
44
|
it "should have an empty default run list" do
|
45
45
|
@knife.run
|
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListClear do
|
|
44
44
|
|
45
45
|
describe "run" do
|
46
46
|
|
47
|
-
# it "should display all the things" do
|
48
|
-
# @knife.run
|
49
|
-
# @role.to_json.should == 'show all the things'
|
50
|
-
# end
|
47
|
+
# it "should display all the things" do
|
48
|
+
# @knife.run
|
49
|
+
# @role.to_json.should == 'show all the things'
|
50
|
+
# end
|
51
51
|
|
52
52
|
it "should load the node" do
|
53
53
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListRemove do
|
|
44
44
|
|
45
45
|
describe "run" do
|
46
46
|
|
47
|
-
# it "should display all the things" do
|
48
|
-
# @knife.run
|
49
|
-
# @role.to_json.should == 'show all the things'
|
50
|
-
# end
|
47
|
+
# it "should display all the things" do
|
48
|
+
# @knife.run
|
49
|
+
# @role.to_json.should == 'show all the things'
|
50
|
+
# end
|
51
51
|
|
52
52
|
it "should load the node" do
|
53
53
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListReplace do
|
|
44
44
|
|
45
45
|
describe "run" do
|
46
46
|
|
47
|
-
# it "should display all the things" do
|
48
|
-
# @knife.run
|
49
|
-
# @role.to_json.should == 'show all the things'
|
50
|
-
# end
|
47
|
+
# it "should display all the things" do
|
48
|
+
# @knife.run
|
49
|
+
# @role.to_json.should == 'show all the things'
|
50
|
+
# end
|
51
51
|
|
52
52
|
it "should load the node" do
|
53
53
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListSet do
|
|
44
44
|
|
45
45
|
describe "run" do
|
46
46
|
|
47
|
-
# it "should display all the things" do
|
48
|
-
# @knife.run
|
49
|
-
# @role.to_json.should == 'show all the things'
|
50
|
-
# end
|
47
|
+
# it "should display all the things" do
|
48
|
+
# @knife.run
|
49
|
+
# @role.to_json.should == 'show all the things'
|
50
|
+
# end
|
51
51
|
|
52
52
|
it "should load the node" do
|
53
53
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|
@@ -21,8 +21,8 @@ require "spec_helper"
|
|
21
21
|
|
22
22
|
describe Chef::Knife::RoleRunListAdd do
|
23
23
|
before(:each) do
|
24
|
-
# Chef::Config[:role_name] = "websimian"
|
25
|
-
# Chef::Config[:env_name] = "QA"
|
24
|
+
# Chef::Config[:role_name] = "websimian"
|
25
|
+
# Chef::Config[:env_name] = "QA"
|
26
26
|
@knife = Chef::Knife::RoleRunListAdd.new
|
27
27
|
@knife.config = {
|
28
28
|
after: nil,
|
@@ -36,10 +36,10 @@ describe Chef::Knife::RoleRunListAdd do
|
|
36
36
|
|
37
37
|
describe "run" do
|
38
38
|
|
39
|
-
# it "should display all the things" do
|
40
|
-
# @knife.run
|
41
|
-
# @role.to_json.should == 'show all the things'
|
42
|
-
# end
|
39
|
+
# it "should display all the things" do
|
40
|
+
# @knife.run
|
41
|
+
# @role.to_json.should == 'show all the things'
|
42
|
+
# end
|
43
43
|
|
44
44
|
it "should have a run list with the monkey role" do
|
45
45
|
@knife.run
|
@@ -43,10 +43,10 @@ describe Chef::Knife::RoleRunListClear do
|
|
43
43
|
|
44
44
|
describe "run" do
|
45
45
|
|
46
|
-
# it "should display all the things" do
|
47
|
-
# @knife.run
|
48
|
-
# @role.to_json.should == 'show all the things'
|
49
|
-
# end
|
46
|
+
# it "should display all the things" do
|
47
|
+
# @knife.run
|
48
|
+
# @role.to_json.should == 'show all the things'
|
49
|
+
# end
|
50
50
|
|
51
51
|
it "should load the node" do
|
52
52
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|
@@ -43,10 +43,10 @@ describe Chef::Knife::RoleRunListRemove do
|
|
43
43
|
|
44
44
|
describe "run" do
|
45
45
|
|
46
|
-
# it "should display all the things" do
|
47
|
-
# @knife.run
|
48
|
-
# @role.to_json.should == 'show all the things'
|
49
|
-
# end
|
46
|
+
# it "should display all the things" do
|
47
|
+
# @knife.run
|
48
|
+
# @role.to_json.should == 'show all the things'
|
49
|
+
# end
|
50
50
|
|
51
51
|
it "should load the node" do
|
52
52
|
expect(Chef::Role).to receive(:load).with("will").and_return(@role)
|