chef 16.3.45-universal-mingw32 → 16.4.35-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -318,7 +318,9 @@ describe "knife diff", :workstation do
|
|
318
318
|
end
|
319
319
|
end # without versioned cookbooks
|
320
320
|
|
321
|
-
|
321
|
+
context "with versioned cookbooks" do
|
322
|
+
before { Chef::Config[:versioned_cookbooks] = true }
|
323
|
+
|
322
324
|
when_the_chef_server "has one of each thing" do
|
323
325
|
before do
|
324
326
|
client "x", "{}"
|
@@ -594,7 +594,9 @@ describe "knife download", :workstation do
|
|
594
594
|
end
|
595
595
|
end # without versioned cookbooks
|
596
596
|
|
597
|
-
|
597
|
+
context "with versioned cookbooks" do
|
598
|
+
before { Chef::Config[:versioned_cookbooks] = true }
|
599
|
+
|
598
600
|
when_the_chef_server "has one of each thing" do
|
599
601
|
before do
|
600
602
|
client "x", {}
|
@@ -26,11 +26,11 @@ describe "knife serve", :workstation do
|
|
26
26
|
def with_knife_serve
|
27
27
|
exception = nil
|
28
28
|
t = Thread.new do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
|
30
|
+
knife("serve --chef-zero-port=8890")
|
31
|
+
rescue
|
32
|
+
exception = $!
|
33
|
+
|
34
34
|
end
|
35
35
|
begin
|
36
36
|
Chef::Config.log_level = :debug
|
@@ -800,7 +800,9 @@ describe "knife upload", :workstation do
|
|
800
800
|
end
|
801
801
|
end # without versioned cookbooks
|
802
802
|
|
803
|
-
|
803
|
+
context "with versioned cookbooks" do
|
804
|
+
before { Chef::Config[:versioned_cookbooks] = true }
|
805
|
+
|
804
806
|
when_the_chef_server "has one of each thing" do
|
805
807
|
|
806
808
|
before do
|
@@ -59,7 +59,7 @@ describe "LWRPs with inline resources" do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
after { File.delete(LwrpShadowedPropertyTest::PATH) if File.
|
62
|
+
after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exist?(LwrpShadowedPropertyTest::PATH) }
|
63
63
|
|
64
64
|
# https://github.com/chef/chef/issues/4334
|
65
65
|
it "does not warn spuriously" do
|
data/spec/spec_helper.rb
CHANGED
@@ -68,7 +68,7 @@ end
|
|
68
68
|
|
69
69
|
# If you want to load anything into the testing environment
|
70
70
|
# without versioning it, add it to spec/support/local_gems.rb
|
71
|
-
require "spec/support/local_gems.rb" if File.
|
71
|
+
require "spec/support/local_gems.rb" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
|
72
72
|
|
73
73
|
# Explicitly require spec helpers that need to load first
|
74
74
|
require "spec/support/platform_helpers"
|
@@ -297,11 +297,11 @@ RSpec.configure do |config|
|
|
297
297
|
|
298
298
|
# Protect Rspec from accidental exit(0) causing rspec to terminate without error
|
299
299
|
config.around(:example) do |ex|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
300
|
+
|
301
|
+
ex.run
|
302
|
+
rescue SystemExit => e
|
303
|
+
raise UnexpectedSystemExit.from(e)
|
304
|
+
|
305
305
|
end
|
306
306
|
end
|
307
307
|
|
@@ -105,7 +105,7 @@ def mac_osx_1014?
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def mac_osx?
|
108
|
-
if File.
|
108
|
+
if File.exist? "/usr/bin/sw_vers"
|
109
109
|
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
|
110
110
|
result.stdout.each_line do |line|
|
111
111
|
if /^ProductName:\sMac OS X.*$/.match?(line)
|
@@ -134,19 +134,19 @@ def unix?
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def linux?
|
137
|
-
|
137
|
+
RUBY_PLATFORM.match?(/linux/)
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
141
|
-
|
140
|
+
def macos?
|
141
|
+
RUBY_PLATFORM.match?(/darwin/)
|
142
142
|
end
|
143
143
|
|
144
144
|
def solaris?
|
145
|
-
|
145
|
+
RUBY_PLATFORM.match?(/solaris/)
|
146
146
|
end
|
147
147
|
|
148
148
|
def freebsd?
|
149
|
-
|
149
|
+
RUBY_PLATFORM.match?(/freebsd/)
|
150
150
|
end
|
151
151
|
|
152
152
|
def intel_64bit?
|
@@ -182,7 +182,7 @@ def debian_family?
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def aix?
|
185
|
-
|
185
|
+
RUBY_PLATFORM.match?(/aix/)
|
186
186
|
end
|
187
187
|
|
188
188
|
def wpar?
|
@@ -216,8 +216,8 @@ def selinux_enabled?
|
|
216
216
|
end
|
217
217
|
|
218
218
|
def suse?
|
219
|
-
::File.
|
220
|
-
( ::File.
|
219
|
+
::File.exist?("/etc/SuSE-release") ||
|
220
|
+
( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
|
221
221
|
end
|
222
222
|
|
223
223
|
def root?
|
@@ -26,7 +26,7 @@ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
|
26
26
|
|
27
27
|
def service_main(*startup_parameters)
|
28
28
|
while running?
|
29
|
-
unless File.
|
29
|
+
unless File.exist?(@test_service_file)
|
30
30
|
File.open(@test_service_file, "wb") do |f|
|
31
31
|
f.write("This file is created by SpecService")
|
32
32
|
end
|
@@ -62,7 +62,7 @@ shared_context "a command that can be executed as an alternate user" do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
after do
|
65
|
-
File.delete(script_output_path) if File.
|
65
|
+
File.delete(script_output_path) if File.exist?(script_output_path)
|
66
66
|
Dir.rmdir(script_output_dir) if Dir.exist?(script_output_dir)
|
67
67
|
end
|
68
68
|
end
|
@@ -476,12 +476,12 @@ shared_examples_for "a configured file resource" do
|
|
476
476
|
end
|
477
477
|
|
478
478
|
it "issues a warning/assumption in whyrun mode" do
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
479
|
+
|
480
|
+
Chef::Config[:why_run] = true
|
481
|
+
resource.run_action(:create) # should not raise
|
482
|
+
ensure
|
483
|
+
Chef::Config[:why_run] = false
|
484
|
+
|
485
485
|
end
|
486
486
|
end
|
487
487
|
|
@@ -504,12 +504,12 @@ shared_examples_for "a configured file resource" do
|
|
504
504
|
end
|
505
505
|
|
506
506
|
it "issues a warning/assumption in whyrun mode" do
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
507
|
+
|
508
|
+
Chef::Config[:why_run] = true
|
509
|
+
resource.run_action(:create) # should not raise
|
510
|
+
ensure
|
511
|
+
Chef::Config[:why_run] = false
|
512
|
+
|
513
513
|
end
|
514
514
|
end
|
515
515
|
|
@@ -535,12 +535,12 @@ shared_examples_for "a configured file resource" do
|
|
535
535
|
end
|
536
536
|
|
537
537
|
it "issues a warning/assumption in whyrun mode" do
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
538
|
+
|
539
|
+
Chef::Config[:why_run] = true
|
540
|
+
resource.run_action(:create) # should not raise
|
541
|
+
ensure
|
542
|
+
Chef::Config[:why_run] = false
|
543
|
+
|
544
544
|
end
|
545
545
|
end
|
546
546
|
|
@@ -1037,8 +1037,8 @@ shared_context Chef::Resource::File do
|
|
1037
1037
|
end
|
1038
1038
|
|
1039
1039
|
after(:each) do
|
1040
|
-
FileUtils.rm_r(path) if File.
|
1041
|
-
FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.
|
1040
|
+
FileUtils.rm_r(path) if File.exist?(path)
|
1041
|
+
FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
|
1042
1042
|
end
|
1043
1043
|
|
1044
1044
|
after do
|
@@ -39,11 +39,11 @@ shared_context Chef::Resource::WindowsScript do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
before(:each) do
|
42
|
-
File.delete(script_output_path) if File.
|
42
|
+
File.delete(script_output_path) if File.exist?(script_output_path)
|
43
43
|
end
|
44
44
|
|
45
45
|
after(:each) do
|
46
|
-
File.delete(script_output_path) if File.
|
46
|
+
File.delete(script_output_path) if File.exist?(script_output_path)
|
47
47
|
end
|
48
48
|
|
49
49
|
shared_examples_for "a script resource with architecture attribute" do
|
@@ -138,7 +138,7 @@ shared_context Chef::Resource::WindowsScript do
|
|
138
138
|
|
139
139
|
after do
|
140
140
|
script_file.close! if script_file
|
141
|
-
::File.delete(script_file.to_path) if script_file && ::File.
|
141
|
+
::File.delete(script_file.to_path) if script_file && ::File.exist?(script_file.to_path)
|
142
142
|
end
|
143
143
|
|
144
144
|
include_context "alternate user identity"
|
@@ -44,15 +44,30 @@ module IntegrationSupport
|
|
44
44
|
|
45
45
|
def when_the_repository(desc, *tags, &block)
|
46
46
|
context("when the chef repo #{desc}", *tags) do
|
47
|
-
|
47
|
+
before :each do
|
48
|
+
raise "Can only create one directory per test" if @repository_dir
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
@repository_dir = Dir.mktmpdir("chef_repo")
|
51
|
+
Chef::Config.chef_repo_path = @repository_dir
|
52
|
+
%w{client cookbook data_bag environment node role user}.each do |object_name|
|
53
|
+
Chef::Config.delete("#{object_name}_path".to_sym)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
after :each do
|
58
|
+
if @repository_dir
|
59
|
+
begin
|
60
|
+
# TODO: "force" actually means "silence all exceptions". this
|
61
|
+
# silences a weird permissions error on Windows that we should track
|
62
|
+
# down, but for now there's no reason for it to blow up our CI.
|
63
|
+
FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
|
64
|
+
ensure
|
65
|
+
@repository_dir = nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
Dir.chdir(@old_cwd) if @old_cwd
|
69
|
+
end
|
52
70
|
|
53
|
-
def with_versioned_cookbooks(&block)
|
54
|
-
context("with versioned cookbooks") do
|
55
|
-
include_context "with versioned cookbooks"
|
56
71
|
module_eval(&block)
|
57
72
|
end
|
58
73
|
end
|
@@ -105,49 +120,4 @@ module IntegrationSupport
|
|
105
120
|
@old_cwd = Dir.pwd
|
106
121
|
Dir.chdir(path_to(relative_path))
|
107
122
|
end
|
108
|
-
|
109
|
-
RSpec.shared_context "with a chef repo" do
|
110
|
-
before :each do
|
111
|
-
raise "Can only create one directory per test" if @repository_dir
|
112
|
-
|
113
|
-
@repository_dir = Dir.mktmpdir("chef_repo")
|
114
|
-
Chef::Config.chef_repo_path = @repository_dir
|
115
|
-
%w{client cookbook data_bag environment node role user}.each do |object_name|
|
116
|
-
Chef::Config.delete("#{object_name}_path".to_sym)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
after :each do
|
121
|
-
if @repository_dir
|
122
|
-
begin
|
123
|
-
%w{client cookbook data_bag environment node role user}.each do |object_name|
|
124
|
-
Chef::Config.delete("#{object_name}_path".to_sym)
|
125
|
-
end
|
126
|
-
Chef::Config.delete(:chef_repo_path)
|
127
|
-
# TODO: "force" actually means "silence all exceptions". this
|
128
|
-
# silences a weird permissions error on Windows that we should track
|
129
|
-
# down, but for now there's no reason for it to blow up our CI.
|
130
|
-
FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
|
131
|
-
ensure
|
132
|
-
@repository_dir = nil
|
133
|
-
end
|
134
|
-
end
|
135
|
-
Dir.chdir(@old_cwd) if @old_cwd
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
# Versioned cookbooks
|
141
|
-
|
142
|
-
RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do
|
143
|
-
before(:each) { Chef::Config[:versioned_cookbooks] = true }
|
144
|
-
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
|
145
|
-
end
|
146
|
-
|
147
|
-
RSpec.shared_context "without versioned cookbooks", versioned_cookbooks: false do
|
148
|
-
# Just make sure this goes back to default
|
149
|
-
before(:each) { Chef::Config[:versioned_cookbooks] = false }
|
150
|
-
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
|
151
|
-
end
|
152
|
-
|
153
123
|
end
|
@@ -47,21 +47,6 @@ shared_examples_for "a script resource" do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "when executing guards" do
|
50
|
-
let(:resource) do
|
51
|
-
resource = script_resource
|
52
|
-
resource.run_context = run_context
|
53
|
-
resource.code "echo hi"
|
54
|
-
resource
|
55
|
-
end
|
56
|
-
let(:node) do
|
57
|
-
node = Chef::Node.new
|
58
|
-
node.automatic[:platform] = "debian"
|
59
|
-
node.automatic[:platform_version] = "6.0"
|
60
|
-
node
|
61
|
-
end
|
62
|
-
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
63
|
-
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
64
|
-
|
65
50
|
it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do
|
66
51
|
inherited_difference = Chef::Resource::Script.guard_inherited_attributes -
|
67
52
|
%i{cwd environment group path user umask}
|
@@ -73,16 +58,17 @@ shared_examples_for "a script resource" do
|
|
73
58
|
expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block)
|
74
59
|
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).not_to receive(:evaluate_action)
|
75
60
|
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:evaluate).and_return(true)
|
76
|
-
|
77
|
-
expect(
|
61
|
+
script_resource.only_if "echo hi"
|
62
|
+
expect(script_resource.should_skip?(:run)).to eq(nil)
|
78
63
|
end
|
79
64
|
|
80
65
|
it "when a valid guard_interpreter resource is specified, a block should be used to evaluate the guard" do
|
66
|
+
expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block)
|
81
67
|
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
|
82
68
|
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
|
83
|
-
|
84
|
-
|
85
|
-
expect(
|
69
|
+
script_resource.guard_interpreter :script
|
70
|
+
script_resource.only_if "echo hi"
|
71
|
+
expect(script_resource.should_skip?(:run)).to eq(nil)
|
86
72
|
end
|
87
73
|
end
|
88
74
|
end
|
@@ -20,59 +20,46 @@ require "support/shared/unit/execute_resource"
|
|
20
20
|
require "support/shared/unit/script_resource"
|
21
21
|
|
22
22
|
shared_examples_for "a Windows script resource" do
|
23
|
-
before(:each) do
|
24
|
-
node = Chef::Node.new
|
25
|
-
|
26
|
-
node.default["kernel"] = {}
|
27
|
-
node.default["kernel"][:machine] = :x86_64.to_s
|
28
|
-
|
29
|
-
run_context = Chef::RunContext.new(node, nil, nil)
|
30
|
-
|
31
|
-
@resource = resource_instance
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
23
|
it "should be a kind of Chef::Resource::WindowsScript" do
|
36
|
-
expect(
|
37
|
-
expect(
|
24
|
+
expect(windows_script_resource).to be_a_kind_of(Chef::Resource)
|
25
|
+
expect(windows_script_resource).to be_a_kind_of(Chef::Resource::WindowsScript)
|
38
26
|
end
|
39
27
|
|
40
28
|
context "when evaluating guards" do
|
41
29
|
it "should have a default_guard_interpreter attribute that is the same as the resource" do
|
42
|
-
expect(
|
30
|
+
expect(windows_script_resource.default_guard_interpreter).to eq(windows_script_resource.resource_name)
|
43
31
|
end
|
44
32
|
|
45
33
|
it "should default to using guard_interpreter attribute that is the same as the resource" do
|
46
|
-
expect(
|
34
|
+
expect(windows_script_resource.guard_interpreter).to eq(windows_script_resource.resource_name)
|
47
35
|
end
|
48
36
|
|
49
37
|
it "should use a resource to evaluate the guard when guard_interpreter is not specified" do
|
50
38
|
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
|
51
39
|
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
|
52
|
-
|
53
|
-
expect(
|
40
|
+
windows_script_resource.only_if "echo hi"
|
41
|
+
expect(windows_script_resource.should_skip?(:run)).to eq(nil)
|
54
42
|
end
|
55
43
|
|
56
44
|
describe "when the guard is given a ruby block" do
|
57
45
|
it "should evaluate the guard if the guard_interpreter is set to its default value" do
|
58
|
-
|
59
|
-
expect(
|
46
|
+
windows_script_resource.only_if { true }
|
47
|
+
expect(windows_script_resource.should_skip?(:run)).to eq(nil)
|
60
48
|
end
|
61
49
|
|
62
50
|
it "should raise an exception if the guard_interpreter is overridden from its default value" do
|
63
|
-
|
64
|
-
|
65
|
-
expect {
|
51
|
+
windows_script_resource.guard_interpreter :bash
|
52
|
+
windows_script_resource.only_if { true }
|
53
|
+
expect { windows_script_resource.should_skip?(:run) }.to raise_error(ArgumentError)
|
66
54
|
end
|
67
55
|
end
|
68
56
|
end
|
69
57
|
|
70
58
|
context "script with a default guard interpreter" do
|
71
|
-
let(:script_resource)
|
72
|
-
|
73
|
-
|
74
|
-
|
59
|
+
let(:script_resource) { windows_script_resource }
|
60
|
+
|
61
|
+
before { windows_script_resource.guard_interpreter :default }
|
62
|
+
|
75
63
|
it_should_behave_like "a script resource"
|
76
64
|
end
|
77
|
-
|
78
65
|
end
|