chef 16.3.45-universal-mingw32 → 16.4.35-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef-universal-mingw32.gemspec +0 -1
- data/lib/chef/action_collection.rb +4 -0
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +5 -5
- data/lib/chef/application/windows_service.rb +27 -27
- data/lib/chef/chef_class.rb +0 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +54 -54
- data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +10 -10
- data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +8 -8
- data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +8 -8
- 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 +18 -18
- 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/client.rb +11 -11
- data/lib/chef/data_collector/run_end_message.rb +11 -1
- data/lib/chef/dsl/platform_introspection.rb +8 -8
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_content_management/tempfile.rb +9 -9
- data/lib/chef/http.rb +2 -1
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +23 -23
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
- data/lib/chef/knife/core/windows_bootstrap_context.rb +32 -24
- data/lib/chef/knife/delete.rb +15 -15
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +6 -6
- data/lib/chef/knife/xargs.rb +19 -19
- data/lib/chef/knife/yaml_convert.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/deep_merge.rb +35 -6
- data/lib/chef/mixin/openssl_helper.rb +3 -1
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +10 -10
- data/lib/chef/node/attribute.rb +2 -4
- data/lib/chef/platform/service_helpers.rb +1 -1
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider/cron/unix.rb +0 -2
- data/lib/chef/provider/git.rb +5 -5
- data/lib/chef/provider/group.rb +0 -2
- data/lib/chef/provider/group/suse.rb +5 -5
- data/lib/chef/provider/ifconfig.rb +1 -4
- data/lib/chef/provider/mount.rb +0 -2
- data/lib/chef/provider/package.rb +0 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +9 -9
- data/lib/chef/provider/powershell_script.rb +21 -5
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/service/arch.rb +1 -1
- 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 -4
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +10 -10
- data/lib/chef/provider/systemd_unit.rb +0 -2
- data/lib/chef/provider/template/content.rb +1 -0
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/provider/user/mac.rb +9 -9
- data/lib/chef/provider/windows_task.rb +0 -3
- data/lib/chef/provider/zypper_repository.rb +0 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/recipe.rb +1 -1
- data/lib/chef/resource.rb +6 -10
- data/lib/chef/resource/apt_repository.rb +1 -10
- data/lib/chef/resource/chef_client_systemd_timer.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +13 -13
- data/lib/chef/resource/execute.rb +2 -3
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/openssl_dhparam.rb +2 -0
- data/lib/chef/resource/openssl_ec_private_key.rb +2 -0
- data/lib/chef/resource/openssl_ec_public_key.rb +2 -0
- data/lib/chef/resource/openssl_rsa_private_key.rb +2 -0
- data/lib/chef/resource/openssl_rsa_public_key.rb +2 -0
- data/lib/chef/resource/openssl_x509_certificate.rb +24 -21
- data/lib/chef/resource/openssl_x509_crl.rb +2 -0
- data/lib/chef/resource/openssl_x509_request.rb +23 -20
- data/lib/chef/resource/osx_profile.rb +227 -5
- data/lib/chef/resource/powershell_package_source.rb +1 -1
- data/lib/chef/resource/powershell_script.rb +24 -30
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/sysctl.rb +5 -5
- data/lib/chef/resource/windows_ad_join.rb +2 -0
- data/lib/chef/resource/windows_audit_policy.rb +3 -0
- data/lib/chef/resource/windows_auto_run.rb +2 -0
- data/lib/chef/resource/windows_certificate.rb +2 -0
- data/lib/chef/resource/windows_dfs_folder.rb +2 -0
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -0
- data/lib/chef/resource/windows_dfs_server.rb +2 -0
- data/lib/chef/resource/windows_dns_record.rb +10 -7
- data/lib/chef/resource/windows_dns_zone.rb +12 -7
- data/lib/chef/resource/windows_feature.rb +2 -0
- data/lib/chef/resource/windows_feature_dism.rb +10 -0
- data/lib/chef/resource/windows_feature_powershell.rb +14 -2
- data/lib/chef/resource/windows_firewall_profile.rb +4 -2
- data/lib/chef/resource/windows_firewall_rule.rb +5 -3
- data/lib/chef/resource/windows_font.rb +3 -1
- data/lib/chef/resource/windows_pagefile.rb +4 -0
- data/lib/chef/resource/windows_printer.rb +17 -18
- data/lib/chef/resource/windows_printer_port.rb +14 -13
- data/lib/chef/resource/windows_security_policy.rb +2 -0
- data/lib/chef/resource/windows_share.rb +5 -3
- data/lib/chef/resource/windows_shortcut.rb +2 -0
- data/lib/chef/resource/windows_uac.rb +2 -0
- data/lib/chef/resource/windows_user_privilege.rb +2 -0
- data/lib/chef/resource/windows_workgroup.rb +2 -3
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -2
- data/lib/chef/role.rb +2 -2
- data/lib/chef/run_context/cookbook_compiler.rb +20 -20
- data/lib/chef/run_status.rb +2 -6
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/diff.rb +11 -11
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/file.rb +2 -2
- data/lib/chef/win32/file/version_info.rb +5 -5
- data/spec/data/ssl/chef-rspec.cert +15 -15
- data/spec/functional/resource/aixinit_service_spec.rb +7 -7
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +0 -1
- data/spec/functional/resource/group_spec.rb +6 -6
- data/spec/functional/resource/insserv_spec.rb +4 -4
- data/spec/functional/resource/link_spec.rb +20 -20
- data/spec/functional/resource/powershell_script_spec.rb +4 -4
- data/spec/functional/resource/rpm_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_security_policy_spec.rb +0 -3
- data/spec/functional/run_lock_spec.rb +24 -24
- data/spec/functional/win32/registry_spec.rb +8 -8
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +12 -12
- data/spec/integration/knife/config_get_profile_spec.rb +69 -68
- data/spec/integration/knife/config_get_spec.rb +126 -125
- data/spec/integration/knife/config_list_profiles_spec.rb +181 -180
- data/spec/integration/knife/config_use_profile_spec.rb +110 -109
- data/spec/integration/knife/diff_spec.rb +3 -1
- data/spec/integration/knife/download_spec.rb +3 -1
- data/spec/integration/knife/serve_spec.rb +5 -5
- data/spec/integration/knife/upload_spec.rb +3 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -6
- data/spec/support/platform_helpers.rb +9 -9
- 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 +20 -20
- 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/integration_helper.rb +22 -52
- data/spec/support/shared/unit/script_resource.rb +6 -20
- data/spec/support/shared/unit/windows_script_resource.rb +15 -28
- data/spec/unit/data_collector_spec.rb +22 -0
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/knife/bootstrap_spec.rb +14 -14
- 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/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +21 -12
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/mixin/template_spec.rb +30 -30
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +4 -4
- data/spec/unit/node/immutable_collections_spec.rb +6 -2
- data/spec/unit/node_spec.rb +5 -5
- data/spec/unit/provider/powershell_script_spec.rb +11 -4
- data/spec/unit/provider/remote_directory_spec.rb +9 -9
- 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 +7 -7
- 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_resolver_spec.rb +6 -6
- data/spec/unit/resource/batch_spec.rb +6 -6
- data/spec/unit/resource/execute_spec.rb +113 -118
- data/spec/unit/resource/osx_profile_spec.rb +233 -0
- data/spec/unit/resource/powershell_script_spec.rb +11 -29
- data/spec/unit/resource/script_spec.rb +6 -1
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/role_spec.rb +11 -11
- data/tasks/rspec.rb +1 -1
- metadata +7 -22
- data/lib/chef/provider/osx_profile.rb +0 -255
- data/spec/unit/provider/osx_profile_spec.rb +0 -255
@@ -39,6 +39,7 @@ describe Chef::DataCollector do
|
|
39
39
|
let(:new_resource) do
|
40
40
|
new_resource = Chef::Resource::File.new("/tmp/a-file.txt")
|
41
41
|
new_resource.checksum nil
|
42
|
+
new_resource.path
|
42
43
|
new_resource
|
43
44
|
end
|
44
45
|
|
@@ -780,6 +781,13 @@ describe Chef::DataCollector do
|
|
780
781
|
let(:resource_record) do
|
781
782
|
rec = resource_record_for(new_resource, current_resource, nil, :create, "failed", "1234")
|
782
783
|
rec["error_message"] = "imperial to metric conversion error"
|
784
|
+
rec["error"] = {
|
785
|
+
"class" => exception.class,
|
786
|
+
"message" => exception.message,
|
787
|
+
"backtrace" => exception.backtrace,
|
788
|
+
"description" => error_description,
|
789
|
+
}
|
790
|
+
|
783
791
|
[ rec ]
|
784
792
|
end
|
785
793
|
let(:status) { "failure" }
|
@@ -808,6 +816,13 @@ describe Chef::DataCollector do
|
|
808
816
|
rec = resource_record_for(new_resource, nil, nil, :create, "failed", "1234")
|
809
817
|
rec["before"] = {}
|
810
818
|
rec["error_message"] = "imperial to metric conversion error"
|
819
|
+
rec["error"] = {
|
820
|
+
"class" => exception.class,
|
821
|
+
"message" => exception.message,
|
822
|
+
"backtrace" => exception.backtrace,
|
823
|
+
"description" => error_description,
|
824
|
+
}
|
825
|
+
|
811
826
|
[ rec ]
|
812
827
|
end
|
813
828
|
let(:status) { "failure" }
|
@@ -842,6 +857,13 @@ describe Chef::DataCollector do
|
|
842
857
|
let(:resource_record) do
|
843
858
|
rec1 = resource_record_for(new_resource, current_resource, nil, :create, "failed", "1234")
|
844
859
|
rec1["error_message"] = "imperial to metric conversion error"
|
860
|
+
rec1["error"] = {
|
861
|
+
"class" => exception.class,
|
862
|
+
"message" => exception.message,
|
863
|
+
"backtrace" => exception.backtrace,
|
864
|
+
"description" => error_description,
|
865
|
+
}
|
866
|
+
|
845
867
|
rec2 = resource_record_for(unprocessed_resource, nil, nil, :nothing, "unprocessed", "")
|
846
868
|
[ rec1, rec2 ]
|
847
869
|
end
|
@@ -402,8 +402,8 @@ describe Chef::Environment do
|
|
402
402
|
|
403
403
|
it "should get the environment from the environment_path" do
|
404
404
|
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
|
405
|
-
expect(File).to receive(:
|
406
|
-
expect(File).to receive(:
|
405
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
|
406
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
|
407
407
|
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
|
408
408
|
expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
|
409
409
|
role_dsl = "name \"foo\"\ndescription \"desc\"\n"
|
@@ -413,7 +413,7 @@ describe Chef::Environment do
|
|
413
413
|
|
414
414
|
it "should return a Chef::Environment object from JSON" do
|
415
415
|
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
|
416
|
-
expect(File).to receive(:
|
416
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
|
417
417
|
environment_hash = {
|
418
418
|
"name" => "foo",
|
419
419
|
"default_attributes" => {
|
@@ -436,8 +436,8 @@ describe Chef::Environment do
|
|
436
436
|
|
437
437
|
it "should return a Chef::Environment object from Ruby DSL" do
|
438
438
|
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
|
439
|
-
expect(File).to receive(:
|
440
|
-
expect(File).to receive(:
|
439
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
|
440
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
|
441
441
|
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
|
442
442
|
expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
|
443
443
|
role_dsl = "name \"foo\"\ndescription \"desc\"\n"
|
@@ -463,8 +463,8 @@ describe Chef::Environment do
|
|
463
463
|
|
464
464
|
it "should raise an error if the file does not exist" do
|
465
465
|
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
|
466
|
-
expect(File).to receive(:
|
467
|
-
expect(File).to receive(:
|
466
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
|
467
|
+
expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
|
468
468
|
|
469
469
|
expect do
|
470
470
|
Chef::Environment.load("foo")
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -148,24 +148,28 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
|
|
148
148
|
|
149
149
|
describe "#config_content" do
|
150
150
|
before do
|
151
|
-
bootstrap_context.instance_variable_set(
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
151
|
+
bootstrap_context.instance_variable_set(
|
152
|
+
:@chef_config, Mash.new(
|
153
|
+
config_log_level: :info,
|
154
|
+
config_log_location: STDOUT,
|
155
|
+
chef_server_url: "http://chef.example.com:4444",
|
156
|
+
validation_client_name: "chef-validator-testing",
|
157
|
+
file_cache_path: "c:/chef/cache",
|
158
|
+
file_backup_path: "c:/chef/backup",
|
159
|
+
cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })
|
160
|
+
)
|
161
|
+
)
|
158
162
|
end
|
159
163
|
|
160
164
|
it "generates the config file data" do
|
161
165
|
expected = <<~EXPECTED
|
162
166
|
echo.chef_server_url "http://chef.example.com:4444"
|
163
167
|
echo.validation_client_name "chef-validator-testing"
|
164
|
-
echo.file_cache_path "C
|
165
|
-
echo.file_backup_path "C
|
166
|
-
echo.cache_options ^({:path =^> "C
|
168
|
+
echo.file_cache_path "C:\\\\chef\\\\cache"
|
169
|
+
echo.file_backup_path "C:\\\\chef\\\\backup"
|
170
|
+
echo.cache_options ^({:path =^> "C:\\\\chef\\\\cache\\\\checksums", :skip_expires =^> true}^)
|
167
171
|
echo.# Using default node name ^(fqdn^)
|
168
|
-
echo.log_level
|
172
|
+
echo.log_level :auto
|
169
173
|
echo.log_location STDOUT
|
170
174
|
EXPECTED
|
171
175
|
expect(bootstrap_context.config_content).to eq expected
|
@@ -183,7 +187,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
|
|
183
187
|
|
184
188
|
describe "#start_chef" do
|
185
189
|
it "returns the expected string" do
|
186
|
-
expect(bootstrap_context.start_chef).to
|
190
|
+
expect(bootstrap_context.start_chef).to eq(
|
191
|
+
<<~EOH
|
192
|
+
SET "PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin;%PATH%"
|
193
|
+
chef-client -c C:\\chef\\client.rb -j C:\\chef\\first-boot.json
|
194
|
+
EOH
|
195
|
+
)
|
187
196
|
end
|
188
197
|
end
|
189
198
|
|
@@ -108,7 +108,7 @@ describe Chef::Knife::SupermarketShare do
|
|
108
108
|
expect { @knife.run }.to raise_error(SystemExit)
|
109
109
|
end
|
110
110
|
|
111
|
-
if File.
|
111
|
+
if File.exist?("/usr/bin/gnutar") || File.exist?("/bin/gnutar")
|
112
112
|
it "should use gnutar to make a tarball of the cookbook" do
|
113
113
|
expect(@knife).to receive(:shell_out!) do |args|
|
114
114
|
expect(args.to_s).to match(/gnutar -czf/)
|
@@ -104,16 +104,16 @@ describe Chef::Mixin::Template, "render_template" do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should render local files" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
107
|
+
|
108
|
+
tf = Tempfile.new("partial")
|
109
|
+
tf.write "test"
|
110
|
+
tf.rewind
|
111
|
+
|
112
|
+
output = @template_context.render_template_from_string("before {<%= render '#{tf.path}', :local => true %>} after")
|
113
|
+
expect(output).to eq("before {test} after")
|
114
|
+
ensure
|
115
|
+
tf.close
|
116
|
+
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should render partials from a different cookbook" do
|
@@ -124,16 +124,16 @@ describe Chef::Mixin::Template, "render_template" do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should render using the source argument if provided" do
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
127
|
+
|
128
|
+
tf = Tempfile.new("partial")
|
129
|
+
tf.write "test"
|
130
|
+
tf.rewind
|
131
|
+
|
132
|
+
output = @template_context.render_template_from_string("before {<%= render 'something', :local => true, :source => '#{tf.path}' %>} after")
|
133
|
+
expect(output).to eq("before {test} after")
|
134
|
+
ensure
|
135
|
+
tf.close
|
136
|
+
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should pass the node to partials" do
|
@@ -195,11 +195,11 @@ describe Chef::Mixin::Template, "render_template" do
|
|
195
195
|
|
196
196
|
describe "the raised TemplateError" do
|
197
197
|
subject(:exception) do
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
198
|
+
|
199
|
+
do_raise
|
200
|
+
rescue Chef::Mixin::Template::TemplateError => e
|
201
|
+
e
|
202
|
+
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should contain template file and line numbers" do
|
@@ -274,11 +274,11 @@ describe Chef::Mixin::Template, "render_template" do
|
|
274
274
|
|
275
275
|
describe "the raised TemplateError" do
|
276
276
|
before :each do
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
277
|
+
|
278
|
+
do_raise
|
279
|
+
rescue Chef::Mixin::Template::TemplateError => e
|
280
|
+
@exception = e
|
281
|
+
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should have the original exception" do
|
@@ -50,10 +50,10 @@ describe Chef::Mixin::WindowsArchitectureHelper do
|
|
50
50
|
|
51
51
|
it "raises an error if an invalid architecture is passed to assert_valid_windows_architecture!" do
|
52
52
|
@invalid_architectures.each do |architecture|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
|
54
|
+
expect(assert_valid_windows_architecture!(architecture)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
|
55
|
+
rescue Chef::Exceptions::Win32ArchitectureIncorrect
|
56
|
+
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -73,7 +73,11 @@ shared_examples_for "Immutable#to_yaml" do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should create a YAML string with content" do
|
76
|
-
|
76
|
+
# Roundtrip the test string through YAML to compensate for some changes in libyaml-0.2.5
|
77
|
+
# See: https://github.com/yaml/libyaml/pull/186
|
78
|
+
expected = YAML.dump(YAML.load(parsed_yaml))
|
79
|
+
|
80
|
+
expect(copy).to eq(expected)
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
@@ -241,7 +245,7 @@ describe Chef::Node::ImmutableArray do
|
|
241
245
|
|
242
246
|
describe "to_yaml" do
|
243
247
|
let(:copy) { @immutable_nested_array.to_yaml }
|
244
|
-
let(:parsed_yaml) { "---\n- level1\n- - foo\n - bar\n - baz\n - 1\n - 2\n - 3\n
|
248
|
+
let(:parsed_yaml) { "---\n- level1\n- - foo\n - bar\n - baz\n - 1\n - 2\n - 3\n -\n - true\n - false\n - - el\n - 0\n -\n- m: m\n" }
|
245
249
|
|
246
250
|
include_examples "Immutable#to_yaml"
|
247
251
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -1773,11 +1773,11 @@ describe Chef::Node do
|
|
1773
1773
|
end
|
1774
1774
|
|
1775
1775
|
let(:http_exception) do
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1776
|
+
|
1777
|
+
response.error!
|
1778
|
+
rescue => e
|
1779
|
+
e
|
1780
|
+
|
1781
1781
|
end
|
1782
1782
|
|
1783
1783
|
let(:trimmed_node) do
|
@@ -30,14 +30,21 @@ describe Chef::Provider::PowershellScript, "action_run" do
|
|
30
30
|
Chef::Provider::PowershellScript.new(new_resource, run_context)
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
describe "#command" do
|
34
34
|
before(:each) do
|
35
35
|
allow(provider).to receive(:basepath).and_return("C:\\Windows\\system32")
|
36
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
36
37
|
end
|
37
38
|
|
38
|
-
it "
|
39
|
-
flags =
|
40
|
-
|
39
|
+
it "includes the user's flags after the default flags when building the command" do
|
40
|
+
new_resource.flags = "-InputFormat Fabulous"
|
41
|
+
provider.send(:script_file_path=, "C:\\Temp\\Script.ps1")
|
42
|
+
|
43
|
+
expected = <<~CMD.strip
|
44
|
+
"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -InputFormat Fabulous -File "C:\\Temp\\Script.ps1"
|
45
|
+
CMD
|
46
|
+
|
47
|
+
expect(provider.command).to eq(expected)
|
41
48
|
end
|
42
49
|
end
|
43
50
|
end
|