chef 15.10.12-universal-mingw32 → 15.14.0-universal-mingw32
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/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +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 +32 -18
@@ -6,7 +6,7 @@ describe "Accumulators" do
|
|
6
6
|
include IntegrationSupport
|
7
7
|
include Chef::Mixin::ShellOut
|
8
8
|
|
9
|
-
let(:chef_dir) { File.expand_path("
|
9
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
10
10
|
|
11
11
|
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
|
12
12
|
# following constraints are satisfied:
|
@@ -6,7 +6,7 @@ describe "LWRPs with inline resources" do
|
|
6
6
|
include IntegrationSupport
|
7
7
|
include Chef::Mixin::ShellOut
|
8
8
|
|
9
|
-
let(:chef_dir) { File.expand_path("
|
9
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
10
10
|
|
11
11
|
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
|
12
12
|
# following constraints are satisfied:
|
@@ -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
|
@@ -6,7 +6,7 @@ describe "LWRPs" do
|
|
6
6
|
include IntegrationSupport
|
7
7
|
include Chef::Mixin::ShellOut
|
8
8
|
|
9
|
-
let(:chef_dir) { File.expand_path("
|
9
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
10
10
|
|
11
11
|
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
|
12
12
|
# following constraints are satisfied:
|
@@ -6,7 +6,7 @@ describe "notifications" do
|
|
6
6
|
include IntegrationSupport
|
7
7
|
include Chef::Mixin::ShellOut
|
8
8
|
|
9
|
-
let(:chef_dir) { File.expand_path("
|
9
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
10
10
|
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
|
11
11
|
|
12
12
|
when_the_repository "notifies a nameless resource" do
|
@@ -23,7 +23,7 @@ describe "notifying_block" do
|
|
23
23
|
include IntegrationSupport
|
24
24
|
include Chef::Mixin::ShellOut
|
25
25
|
|
26
|
-
let(:chef_dir) { File.expand_path("
|
26
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
27
27
|
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
|
28
28
|
|
29
29
|
when_the_repository "notifying_block test one" do
|
@@ -1319,7 +1319,7 @@ describe "Recipe DSL methods" do
|
|
1319
1319
|
|
1320
1320
|
it "utf-8 dsl names work" do
|
1321
1321
|
recipe = converge do
|
1322
|
-
Straße("blah") {}
|
1322
|
+
Straße("blah") {} # rubocop: disable Naming/AsciiIdentifiers
|
1323
1323
|
end
|
1324
1324
|
expect(recipe.logged_warnings).to eq ""
|
1325
1325
|
expect(BaseThingy.created_resource).to eq(UTF8Thingy)
|
@@ -6,6 +6,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
6
6
|
module Namer
|
7
7
|
extend self
|
8
8
|
attr_accessor :current_index
|
9
|
+
|
9
10
|
def incrementing_value
|
10
11
|
@incrementing_value += 1
|
11
12
|
@incrementing_value
|
@@ -30,6 +31,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
30
31
|
property :state2, default: "default_state2"
|
31
32
|
property :sensitive1, default: "default_dontprintme", sensitive: true
|
32
33
|
attr_accessor :converged
|
34
|
+
|
33
35
|
def initialize(*args)
|
34
36
|
super
|
35
37
|
@converged = 0
|
@@ -6,7 +6,7 @@ describe "Unified Mode" do
|
|
6
6
|
include IntegrationSupport
|
7
7
|
include Chef::Mixin::ShellOut
|
8
8
|
|
9
|
-
let(:chef_dir) { File.expand_path("
|
9
|
+
let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
|
10
10
|
|
11
11
|
let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
|
12
12
|
|
data/spec/scripts/ssl-serve.rb
CHANGED
@@ -12,7 +12,7 @@ require "webrick/https"
|
|
12
12
|
|
13
13
|
$ssl = true
|
14
14
|
|
15
|
-
CHEF_SPEC_DATA = File.expand_path("
|
15
|
+
CHEF_SPEC_DATA = File.expand_path("../data", __dir__)
|
16
16
|
cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
|
17
17
|
cert = OpenSSL::X509::Certificate.new(cert_text)
|
18
18
|
key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
|
data/spec/spec_helper.rb
CHANGED
@@ -24,27 +24,17 @@ module Shell
|
|
24
24
|
IRB = nil unless defined? IRB
|
25
25
|
end
|
26
26
|
|
27
|
-
$LOAD_PATH.unshift File.expand_path("
|
28
|
-
|
29
|
-
$LOAD_PATH.unshift File.expand_path("
|
30
|
-
$LOAD_PATH.unshift File.expand_path("
|
27
|
+
$LOAD_PATH.unshift File.expand_path("..", __dir__)
|
28
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
29
|
+
$LOAD_PATH.unshift File.expand_path("../chef-config/lib", __dir__)
|
30
|
+
$LOAD_PATH.unshift File.expand_path("../chef-utils/lib", __dir__)
|
31
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
31
32
|
|
32
33
|
require "rubygems"
|
33
34
|
require "rspec/mocks"
|
34
35
|
|
35
36
|
require "webmock/rspec"
|
36
37
|
|
37
|
-
if ENV["COVERAGE"]
|
38
|
-
require "simplecov"
|
39
|
-
SimpleCov.start do
|
40
|
-
add_filter "/spec/"
|
41
|
-
add_group "Remote File", "remote_file"
|
42
|
-
add_group "Resources", "/resource/"
|
43
|
-
add_group "Providers", "/provider/"
|
44
|
-
add_group "Knife", "knife"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
38
|
require "chef"
|
49
39
|
require "chef/knife"
|
50
40
|
|
@@ -79,7 +69,7 @@ end
|
|
79
69
|
|
80
70
|
# If you want to load anything into the testing environment
|
81
71
|
# without versioning it, add it to spec/support/local_gems.rb
|
82
|
-
require "spec/support/local_gems.rb" if File.
|
72
|
+
require "spec/support/local_gems.rb" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
|
83
73
|
|
84
74
|
# Explicitly require spec helpers that need to load first
|
85
75
|
require "spec/support/platform_helpers"
|
@@ -114,6 +104,12 @@ resource_priority_map ||= nil
|
|
114
104
|
provider_handler_map ||= nil
|
115
105
|
resource_handler_map ||= nil
|
116
106
|
|
107
|
+
class UnexpectedSystemExit < RuntimeError
|
108
|
+
def self.from(system_exit)
|
109
|
+
new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
117
113
|
RSpec.configure do |config|
|
118
114
|
config.include(Matchers)
|
119
115
|
config.include(MockShellout::RSpec)
|
@@ -128,6 +124,7 @@ RSpec.configure do |config|
|
|
128
124
|
end
|
129
125
|
config.mock_with :rspec do |c|
|
130
126
|
c.syntax = :expect
|
127
|
+
c.allow_message_expectations_on_nil = false
|
131
128
|
end
|
132
129
|
|
133
130
|
# Only run these tests on platforms that are also chef workstations
|
@@ -142,9 +139,10 @@ RSpec.configure do |config|
|
|
142
139
|
|
143
140
|
config.filter_run_excluding windows_only: true unless windows?
|
144
141
|
config.filter_run_excluding not_supported_on_windows: true if windows?
|
145
|
-
config.filter_run_excluding not_supported_on_macos: true if
|
146
|
-
config.filter_run_excluding macos_only: true unless
|
147
|
-
config.filter_run_excluding
|
142
|
+
config.filter_run_excluding not_supported_on_macos: true if macos?
|
143
|
+
config.filter_run_excluding macos_only: true unless macos?
|
144
|
+
config.filter_run_excluding macos_1013: true unless macos_1013?
|
145
|
+
config.filter_run_excluding macos_gte_1014: true unless macos_gte_1014?
|
148
146
|
config.filter_run_excluding not_supported_on_aix: true if aix?
|
149
147
|
config.filter_run_excluding not_supported_on_solaris: true if solaris?
|
150
148
|
config.filter_run_excluding not_supported_on_gce: true if gce?
|
@@ -293,6 +291,15 @@ RSpec.configure do |config|
|
|
293
291
|
config.before(:suite) do
|
294
292
|
ARGV.clear
|
295
293
|
end
|
294
|
+
|
295
|
+
# Protect Rspec from accidental exit(0) causing rspec to terminate without error
|
296
|
+
config.around(:example) do |ex|
|
297
|
+
begin
|
298
|
+
ex.run
|
299
|
+
rescue SystemExit => e
|
300
|
+
raise UnexpectedSystemExit.from(e)
|
301
|
+
end
|
302
|
+
end
|
296
303
|
end
|
297
304
|
|
298
305
|
require "webrick/utils"
|
@@ -27,7 +27,7 @@ Chef::Log.level(Chef::Config.log_level)
|
|
27
27
|
Chef::Config.solo(false)
|
28
28
|
|
29
29
|
def sha256_checksum(path)
|
30
|
-
OpenSSL::Digest
|
30
|
+
OpenSSL::Digest.hexdigest("SHA256", File.read(path))
|
31
31
|
end
|
32
32
|
|
33
33
|
# extracted from Ruby < 2.5 to return a unique temp file name without creating it
|
@@ -3,7 +3,6 @@ require "chef/mixin/shell_out"
|
|
3
3
|
require "ohai/mixin/http_helper"
|
4
4
|
require "ohai/mixin/gce_metadata"
|
5
5
|
require "chef/mixin/powershell_out"
|
6
|
-
require "chef/version_class"
|
7
6
|
|
8
7
|
class ShellHelpers
|
9
8
|
extend Chef::Mixin::ShellOut
|
@@ -100,39 +99,12 @@ def windows_user_right?(right)
|
|
100
99
|
Chef::ReservedNames::Win32::Security.get_account_right(ENV["USERNAME"]).include?(right)
|
101
100
|
end
|
102
101
|
|
103
|
-
def
|
104
|
-
|
105
|
-
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
|
106
|
-
result.stdout.each_line do |line|
|
107
|
-
if line =~ /^ProductVersion:\s10.6.*$/
|
108
|
-
return true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
false
|
114
|
-
end
|
115
|
-
|
116
|
-
def mac_osx_1014?
|
117
|
-
if mac_osx?
|
118
|
-
ver = Chef::Version.new(ohai[:platform_version])
|
119
|
-
return ver.major == 10 && ver.minor == 14
|
120
|
-
end
|
121
|
-
|
122
|
-
false
|
102
|
+
def macos_1013?
|
103
|
+
macos? && Gem::Requirement.new("~> 10.13.0").satisfied_by?(Gem::Version.new(ohai[:platform_version]))
|
123
104
|
end
|
124
105
|
|
125
|
-
def
|
126
|
-
|
127
|
-
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
|
128
|
-
result.stdout.each_line do |line|
|
129
|
-
if line =~ /^ProductName:\sMac OS X.*$/
|
130
|
-
return true
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
false
|
106
|
+
def macos_gte_1014?
|
107
|
+
macos? && Gem::Requirement.new(">= 10.14").satisfied_by?(Gem::Version.new(ohai[:platform_version]))
|
136
108
|
end
|
137
109
|
|
138
110
|
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
|
@@ -145,26 +117,24 @@ def windows32?
|
|
145
117
|
windows? && !windows64?
|
146
118
|
end
|
147
119
|
|
148
|
-
# def jruby?
|
149
|
-
|
150
120
|
def unix?
|
151
121
|
!windows?
|
152
122
|
end
|
153
123
|
|
154
124
|
def linux?
|
155
|
-
|
125
|
+
RUBY_PLATFORM.match?(/linux/)
|
156
126
|
end
|
157
127
|
|
158
|
-
def
|
159
|
-
|
128
|
+
def macos?
|
129
|
+
RUBY_PLATFORM.match?(/darwin/)
|
160
130
|
end
|
161
131
|
|
162
132
|
def solaris?
|
163
|
-
|
133
|
+
RUBY_PLATFORM.match?(/solaris/)
|
164
134
|
end
|
165
135
|
|
166
136
|
def freebsd?
|
167
|
-
|
137
|
+
RUBY_PLATFORM.match?(/freebsd/)
|
168
138
|
end
|
169
139
|
|
170
140
|
def intel_64bit?
|
@@ -200,7 +170,7 @@ def debian_family?
|
|
200
170
|
end
|
201
171
|
|
202
172
|
def aix?
|
203
|
-
|
173
|
+
RUBY_PLATFORM.match?(/aix/)
|
204
174
|
end
|
205
175
|
|
206
176
|
def wpar?
|
@@ -236,8 +206,8 @@ def selinux_enabled?
|
|
236
206
|
end
|
237
207
|
|
238
208
|
def suse?
|
239
|
-
::File.
|
240
|
-
( ::File.
|
209
|
+
::File.exist?("/etc/SuSE-release") ||
|
210
|
+
( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
|
241
211
|
end
|
242
212
|
|
243
213
|
def root?
|
@@ -26,7 +26,7 @@ if RUBY_PLATFORM =~ /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
|
@@ -370,7 +370,7 @@ shared_examples_for "a configured file resource" do
|
|
370
370
|
Chef::Config[:ssl_verify_mode] = :verify_none
|
371
371
|
end
|
372
372
|
|
373
|
-
|
373
|
+
# note the stripping of the drive letter from the tmpdir on windows
|
374
374
|
let(:backup_glob) { File.join(CHEF_SPEC_BACKUP_PATH, test_file_dir.sub(/^([A-Za-z]:)/, ""), "#{file_base}*") }
|
375
375
|
|
376
376
|
# Most tests update the resource, but a few do not. We need to test that the
|
@@ -1038,8 +1038,8 @@ shared_context Chef::Resource::File do
|
|
1038
1038
|
end
|
1039
1039
|
|
1040
1040
|
after(:each) do
|
1041
|
-
FileUtils.rm_r(path) if File.
|
1042
|
-
FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.
|
1041
|
+
FileUtils.rm_r(path) if File.exist?(path)
|
1042
|
+
FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
|
1043
1043
|
end
|
1044
1044
|
|
1045
1045
|
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
|
@@ -149,7 +149,7 @@ shared_context Chef::Resource::WindowsScript do
|
|
149
149
|
|
150
150
|
after do
|
151
151
|
script_file.close! if script_file
|
152
|
-
::File.delete(script_file.to_path) if script_file && ::File.
|
152
|
+
::File.delete(script_file.to_path) if script_file && ::File.exist?(script_file.to_path)
|
153
153
|
end
|
154
154
|
|
155
155
|
include_context "alternate user identity"
|
@@ -39,10 +39,7 @@ module KnifeSupport
|
|
39
39
|
|
40
40
|
# Work on machines where we can't access /var
|
41
41
|
Dir.mktmpdir("checksums") do |checksums_cache_dir|
|
42
|
-
Chef::Config[:
|
43
|
-
path: checksums_cache_dir,
|
44
|
-
skip_expires: true,
|
45
|
-
}
|
42
|
+
Chef::Config[:syntax_check_cache_path] = checksums_cache_dir
|
46
43
|
|
47
44
|
# This is Chef::Knife.run without load_commands--we'll load stuff
|
48
45
|
# ourselves, thank you very much
|
@@ -117,7 +114,7 @@ module KnifeSupport
|
|
117
114
|
ensure
|
118
115
|
Chef::Log.use_log_devices(old_loggers)
|
119
116
|
Chef::Log.level = old_log_level
|
120
|
-
Chef::Config.delete(:
|
117
|
+
Chef::Config.delete(:syntax_check_cache_path)
|
121
118
|
Chef::Config.delete(:concurrency)
|
122
119
|
end
|
123
120
|
|
@@ -94,6 +94,13 @@ describe Chef::Application do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
describe "when enforce_license is set to false" do
|
98
|
+
it "should not check the license acceptance" do
|
99
|
+
expect(@app).to_not receive(:check_license_acceptance)
|
100
|
+
@app.run(enforce_license: false)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
97
104
|
it "should run the actual application" do
|
98
105
|
expect(@app).to receive(:run_application).and_return(true)
|
99
106
|
@app.run
|
@@ -25,11 +25,9 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do
|
|
25
25
|
|
26
26
|
context "has a cause attribute and HTTP result code is 400" do
|
27
27
|
it "include error cause" do
|
28
|
-
allow_message_expectations_on_nil
|
29
28
|
response_body = '{"error":["Invalid key test in request body"]}'
|
30
|
-
|
31
|
-
|
32
|
-
exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
|
29
|
+
response = double(:response, code: "400", body: response_body)
|
30
|
+
exception = Net::HTTPClientException.new("(exception) unauthorized", response)
|
33
31
|
expect do
|
34
32
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, exception), error_message
|
35
33
|
end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}")
|