chef 12.18.31-universal-mingw32 → 12.19.33-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/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
data/spec/unit/knife/ssh_spec.rb
CHANGED
@@ -21,54 +21,53 @@ require "net/ssh"
|
|
21
21
|
require "net/ssh/multi"
|
22
22
|
|
23
23
|
describe Chef::Knife::Ssh do
|
24
|
-
|
25
|
-
Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
|
26
|
-
end
|
24
|
+
let(:query_result) { double("chef search results") }
|
27
25
|
|
28
26
|
before do
|
27
|
+
Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
|
29
28
|
@knife = Chef::Knife::Ssh.new
|
30
29
|
@knife.merge_configs
|
31
|
-
@node_foo =
|
32
|
-
@node_foo
|
33
|
-
@node_foo
|
30
|
+
@node_foo = {}
|
31
|
+
@node_foo["fqdn"] = "foo.example.org"
|
32
|
+
@node_foo["ipaddress"] = "10.0.0.1"
|
33
|
+
@node_foo["cloud"] = {}
|
34
|
+
|
35
|
+
@node_bar = {}
|
36
|
+
@node_bar["fqdn"] = "bar.example.org"
|
37
|
+
@node_bar["ipaddress"] = "10.0.0.2"
|
38
|
+
@node_bar["cloud"] = {}
|
34
39
|
|
35
|
-
@node_bar = Chef::Node.new
|
36
|
-
@node_bar.automatic_attrs[:fqdn] = "bar.example.org"
|
37
|
-
@node_bar.automatic_attrs[:ipaddress] = "10.0.0.2"
|
38
40
|
end
|
39
41
|
|
40
42
|
describe "#configure_session" do
|
41
43
|
context "manual is set to false (default)" do
|
42
44
|
before do
|
43
45
|
@knife.config[:manual] = false
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def configure_query(node_array)
|
48
|
-
allow(@query).to receive(:search).and_return([node_array])
|
49
|
-
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
46
|
+
allow(query_result).to receive(:search).with(any_args).and_yield(@node_foo).and_yield(@node_bar)
|
47
|
+
allow(Chef::Search::Query).to receive(:new).and_return(query_result)
|
50
48
|
end
|
51
49
|
|
52
50
|
def self.should_return_specified_attributes
|
53
51
|
it "returns an array of the attributes specified on the command line OR config file, if only one is set" do
|
52
|
+
@node_bar["config"] = "10.0.0.2"
|
53
|
+
@node_foo["config"] = "10.0.0.1"
|
54
54
|
@knife.config[:attribute] = "ipaddress"
|
55
55
|
Chef::Config[:knife][:ssh_attribute] = "ipaddress" # this value will be in the config file
|
56
|
-
configure_query([@node_foo, @node_bar])
|
57
56
|
expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]])
|
58
57
|
@knife.configure_session
|
59
58
|
end
|
60
59
|
|
61
60
|
it "returns an array of the attributes specified on the command line even when a config value is set" do
|
61
|
+
@node_bar["config"] = "10.0.0.2"
|
62
|
+
@node_foo["config"] = "10.0.0.1"
|
62
63
|
Chef::Config[:knife][:ssh_attribute] = "config_file" # this value will be in the config file
|
63
64
|
@knife.config[:attribute] = "ipaddress" # this is the value of the command line via #configure_attribute
|
64
|
-
configure_query([@node_foo, @node_bar])
|
65
65
|
expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]])
|
66
66
|
@knife.configure_session
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
it "searchs for and returns an array of fqdns" do
|
71
|
-
configure_query([@node_foo, @node_bar])
|
72
71
|
expect(@knife).to receive(:session_from_list).with([
|
73
72
|
["foo.example.org", nil],
|
74
73
|
["bar.example.org", nil],
|
@@ -80,11 +79,10 @@ describe Chef::Knife::Ssh do
|
|
80
79
|
|
81
80
|
context "when cloud hostnames are available" do
|
82
81
|
before do
|
83
|
-
@node_foo
|
84
|
-
@node_bar
|
82
|
+
@node_foo["cloud"]["public_hostname"] = "ec2-10-0-0-1.compute-1.amazonaws.com"
|
83
|
+
@node_bar["cloud"]["public_hostname"] = "ec2-10-0-0-2.compute-1.amazonaws.com"
|
85
84
|
end
|
86
85
|
it "returns an array of cloud public hostnames" do
|
87
|
-
configure_query([@node_foo, @node_bar])
|
88
86
|
expect(@knife).to receive(:session_from_list).with([
|
89
87
|
["ec2-10-0-0-1.compute-1.amazonaws.com", nil],
|
90
88
|
["ec2-10-0-0-2.compute-1.amazonaws.com", nil],
|
@@ -97,12 +95,11 @@ describe Chef::Knife::Ssh do
|
|
97
95
|
|
98
96
|
context "when cloud hostnames are available but empty" do
|
99
97
|
before do
|
100
|
-
@node_foo
|
101
|
-
@node_bar
|
98
|
+
@node_foo["cloud"]["public_hostname"] = ""
|
99
|
+
@node_bar["cloud"]["public_hostname"] = ""
|
102
100
|
end
|
103
101
|
|
104
102
|
it "returns an array of fqdns" do
|
105
|
-
configure_query([@node_foo, @node_bar])
|
106
103
|
expect(@knife).to receive(:session_from_list).with([
|
107
104
|
["foo.example.org", nil],
|
108
105
|
["bar.example.org", nil],
|
@@ -114,7 +111,7 @@ describe Chef::Knife::Ssh do
|
|
114
111
|
end
|
115
112
|
|
116
113
|
it "should raise an error if no host are found" do
|
117
|
-
|
114
|
+
allow(query_result).to receive(:search).with(any_args)
|
118
115
|
expect(@knife.ui).to receive(:fatal)
|
119
116
|
expect(@knife).to receive(:exit).with(10)
|
120
117
|
@knife.configure_session
|
@@ -122,10 +119,8 @@ describe Chef::Knife::Ssh do
|
|
122
119
|
|
123
120
|
context "when there are some hosts found but they do not have an attribute to connect with" do
|
124
121
|
before do
|
125
|
-
|
126
|
-
@
|
127
|
-
@node_bar.automatic_attrs[:fqdn] = nil
|
128
|
-
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
122
|
+
@node_foo["fqdn"] = nil
|
123
|
+
@node_bar["fqdn"] = nil
|
129
124
|
end
|
130
125
|
|
131
126
|
it "should raise a specific error (CHEF-3402)" do
|
@@ -158,31 +153,34 @@ describe Chef::Knife::Ssh do
|
|
158
153
|
before do
|
159
154
|
Chef::Config[:knife][:ssh_attribute] = nil
|
160
155
|
@knife.config[:attribute] = nil
|
161
|
-
@node_foo
|
162
|
-
@node_bar
|
156
|
+
@node_foo["cloud"]["public_hostname"] = "ec2-10-0-0-1.compute-1.amazonaws.com"
|
157
|
+
@node_bar["cloud"]["public_hostname"] = ""
|
163
158
|
end
|
164
159
|
|
165
160
|
it "should return fqdn by default" do
|
166
|
-
expect(@knife.get_ssh_attribute(
|
161
|
+
expect(@knife.get_ssh_attribute({ "fqdn" => "fqdn" })).to eq("fqdn")
|
167
162
|
end
|
168
163
|
|
169
164
|
it "should return cloud.public_hostname attribute if available" do
|
170
|
-
expect(@knife.get_ssh_attribute(@node_foo)).to eq("
|
165
|
+
expect(@knife.get_ssh_attribute(@node_foo)).to eq("ec2-10-0-0-1.compute-1.amazonaws.com")
|
171
166
|
end
|
172
167
|
|
173
168
|
it "should favor to attribute_from_cli over config file and cloud" do
|
174
169
|
@knife.config[:attribute] = "command_line"
|
175
170
|
Chef::Config[:knife][:ssh_attribute] = "config_file"
|
171
|
+
@node_foo["config"] = "command_line"
|
172
|
+
@node_foo["knife_config"] = "config_file"
|
176
173
|
expect( @knife.get_ssh_attribute(@node_foo)).to eq("command_line")
|
177
174
|
end
|
178
175
|
|
179
176
|
it "should favor config file over cloud and default" do
|
180
177
|
Chef::Config[:knife][:ssh_attribute] = "config_file"
|
178
|
+
@node_foo["knife_config"] = "config_file"
|
181
179
|
expect( @knife.get_ssh_attribute(@node_foo)).to eq("config_file")
|
182
180
|
end
|
183
181
|
|
184
182
|
it "should return fqdn if cloud.hostname is empty" do
|
185
|
-
expect( @knife.get_ssh_attribute(@node_bar)).to eq("
|
183
|
+
expect( @knife.get_ssh_attribute(@node_bar)).to eq("bar.example.org")
|
186
184
|
end
|
187
185
|
end
|
188
186
|
|
@@ -190,7 +188,7 @@ describe Chef::Knife::Ssh do
|
|
190
188
|
before :each do
|
191
189
|
@knife.instance_variable_set(:@longest, 0)
|
192
190
|
ssh_config = { :timeout => 50, :user => "locutus", :port => 23 }
|
193
|
-
allow(Net::SSH).to receive(:configuration_for).with("the.b.org").and_return(ssh_config)
|
191
|
+
allow(Net::SSH).to receive(:configuration_for).with("the.b.org", true).and_return(ssh_config)
|
194
192
|
end
|
195
193
|
|
196
194
|
it "uses the port from an ssh config file" do
|
@@ -294,7 +292,7 @@ describe Chef::Knife::Ssh do
|
|
294
292
|
describe "#run" do
|
295
293
|
before do
|
296
294
|
@query = Chef::Search::Query.new
|
297
|
-
expect(@query).to receive(:search).
|
295
|
+
expect(@query).to receive(:search).and_yield(@node_foo)
|
298
296
|
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
299
297
|
allow(@knife).to receive(:ssh_command).and_return(exit_code)
|
300
298
|
@knife.name_args = ["*:*", "false"]
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2015-2017, Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
require "chef/mixin/versioned_api"
|
20
|
+
|
21
|
+
describe Chef::Mixin::VersionedAPI do
|
22
|
+
let(:dummy_class) { Class.new { extend Chef::Mixin::VersionedAPI } }
|
23
|
+
|
24
|
+
it "allows a class to declare the minimum supported API version" do
|
25
|
+
dummy_class.minimum_api_version 3
|
26
|
+
expect(dummy_class.minimum_api_version).to eq(3)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Chef::Mixin::VersionedAPIFactory do
|
31
|
+
class V1Class; extend Chef::Mixin::VersionedAPI; minimum_api_version 1; end
|
32
|
+
class V2Class; extend Chef::Mixin::VersionedAPI; minimum_api_version 2; end
|
33
|
+
class V3Class; extend Chef::Mixin::VersionedAPI; minimum_api_version 3; end
|
34
|
+
|
35
|
+
let(:factory_class) { Class.new { extend Chef::Mixin::VersionedAPIFactory } }
|
36
|
+
|
37
|
+
before do
|
38
|
+
Chef::ServerAPIVersions.instance.reset!
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#add_versioned_api_class" do
|
42
|
+
it "adds a target class" do
|
43
|
+
factory_class.add_versioned_api_class V1Class
|
44
|
+
expect(factory_class.versioned_interfaces).to eq([V1Class])
|
45
|
+
end
|
46
|
+
|
47
|
+
it "can be called many times" do
|
48
|
+
factory_class.add_versioned_api_class V1Class
|
49
|
+
factory_class.add_versioned_api_class V2Class
|
50
|
+
expect(factory_class.versioned_interfaces).to eq([V1Class, V2Class])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#versioned_api_class" do
|
55
|
+
describe "with no known versions" do
|
56
|
+
it "with one class it returns that class" do
|
57
|
+
factory_class.add_versioned_api_class V2Class
|
58
|
+
expect(factory_class.versioned_api_class.minimum_api_version).to eq(2)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "with many classes it returns the highest minimum version" do
|
62
|
+
factory_class.add_versioned_api_class V1Class
|
63
|
+
factory_class.add_versioned_api_class V2Class
|
64
|
+
factory_class.add_versioned_api_class V3Class
|
65
|
+
expect(factory_class.versioned_api_class.minimum_api_version).to eq(3)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "with a known version" do
|
70
|
+
it "with one class it returns that class" do
|
71
|
+
Chef::ServerAPIVersions.instance.set_versions({ "min_version" => 0, "max_version" => 2 })
|
72
|
+
factory_class.add_versioned_api_class V2Class
|
73
|
+
expect(factory_class.versioned_api_class.minimum_api_version).to eq(2)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "with a maximum version it returns the highest possible versioned class" do
|
77
|
+
Chef::ServerAPIVersions.instance.set_versions({ "min_version" => 0, "max_version" => 2 })
|
78
|
+
factory_class.add_versioned_api_class V1Class
|
79
|
+
factory_class.add_versioned_api_class V2Class
|
80
|
+
factory_class.add_versioned_api_class V3Class
|
81
|
+
expect(factory_class.versioned_api_class.minimum_api_version).to eq(2)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "with no classes it returns nil" do
|
86
|
+
expect(factory_class.versioned_api_class).to be_nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#new" do
|
91
|
+
it "creates an instance of the versioned class" do
|
92
|
+
factory_class.add_versioned_api_class V2Class
|
93
|
+
expect { factory_class.new }.to_not raise_error
|
94
|
+
expect(factory_class.new.class).to eq(V2Class)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#def_versioned_delegator" do
|
99
|
+
it "delegates the method to the correct class" do
|
100
|
+
factory_class.add_versioned_api_class V2Class
|
101
|
+
factory_class.def_versioned_delegator("test_method")
|
102
|
+
expect(V2Class).to receive(:test_method).with("test message").and_return(true)
|
103
|
+
|
104
|
+
factory_class.test_method("test message")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2011-2017, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
|
20
|
+
class TestClass
|
21
|
+
include Chef::Mixin::Which
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Chef::Mixin::Which do
|
25
|
+
|
26
|
+
let(:test) { TestClass.new }
|
27
|
+
|
28
|
+
describe "#which" do
|
29
|
+
def self.test_which(description, *args, finds: nil, others: [], directory: false, &block)
|
30
|
+
it description do
|
31
|
+
# stub the ENV['PATH']
|
32
|
+
expect(test).to receive(:env_path).and_return(["/dir1", "/dir2" ].join(File::PATH_SEPARATOR))
|
33
|
+
|
34
|
+
# most files should not be found
|
35
|
+
allow(File).to receive(:executable?).and_return(false)
|
36
|
+
allow(File).to receive(:directory?).and_return(false)
|
37
|
+
|
38
|
+
# stub the expectation
|
39
|
+
expect(File).to receive(:executable?).with(finds).and_return(true) if finds
|
40
|
+
|
41
|
+
# if the file we find is a directory
|
42
|
+
expect(File).to receive(:directory?).with(finds).and_return(true) if finds && directory
|
43
|
+
|
44
|
+
# allow for stubbing other paths to exist that we should not find
|
45
|
+
others.each do |other|
|
46
|
+
allow(File).to receive(:executable?).with(other).and_return(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
# setup the actual expectation on the return value
|
50
|
+
if finds && !directory
|
51
|
+
expect(test.which(*args, &block)).to eql(finds)
|
52
|
+
else
|
53
|
+
expect(test.which(*args, &block)).to eql(false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "simple usage" do
|
59
|
+
test_which("returns false when it does not find anything", "foo1")
|
60
|
+
|
61
|
+
["/dir1", "/dir2", "/bin", "/usr/bin", "/sbin", "/usr/sbin" ].each do |dir|
|
62
|
+
test_which("finds `foo1` in #{dir} when it is stubbed", "foo1", finds: "#{dir}/foo1")
|
63
|
+
end
|
64
|
+
|
65
|
+
test_which("does not find an executable directory", "foo1", finds: "/dir1/foo1", directory: true)
|
66
|
+
end
|
67
|
+
|
68
|
+
context "with an array of args" do
|
69
|
+
test_which("finds the first arg", "foo1", "foo2", finds: "/dir2/foo1")
|
70
|
+
|
71
|
+
test_which("finds the second arg", "foo1", "foo2", finds: "/dir2/foo2")
|
72
|
+
|
73
|
+
test_which("finds the first arg when there's both", "foo1", "foo2", finds: "/dir2/foo1", others: [ "/dir1/foo2" ])
|
74
|
+
|
75
|
+
test_which("and the directory order can be reversed", "foo1", "foo2", finds: "/dir1/foo1", others: [ "/dir2/foo2" ])
|
76
|
+
|
77
|
+
test_which("or be the same", "foo1", "foo2", finds: "/dir1/foo1", others: [ "/dir1/foo2" ])
|
78
|
+
end
|
79
|
+
|
80
|
+
context "with a block" do
|
81
|
+
test_which("doesnt find it if its false", "foo1", others: [ "/dir1/foo1" ]) do |f|
|
82
|
+
false
|
83
|
+
end
|
84
|
+
|
85
|
+
test_which("finds it if its true", "foo1", finds: "/dir1/foo1") do |f|
|
86
|
+
true
|
87
|
+
end
|
88
|
+
|
89
|
+
test_which("passes in the filename as the arg", "foo1", finds: "/dir1/foo1") do |f|
|
90
|
+
raise "bad arg to block" unless f == "/dir1/foo1"
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
test_which("arrays with blocks", "foo1", "foo2", finds: "/dir2/foo1", others: [ "/dir1/foo2" ]) do |f|
|
95
|
+
raise "bad arg to block" unless f == "/dir2/foo1" || f == "/dir1/foo2"
|
96
|
+
true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#where" do
|
102
|
+
def self.test_where(description, *args, finds: [], others: [], &block)
|
103
|
+
it description do
|
104
|
+
# stub the ENV['PATH']
|
105
|
+
expect(test).to receive(:env_path).and_return(["/dir1", "/dir2" ].join(File::PATH_SEPARATOR))
|
106
|
+
|
107
|
+
# most files should not be found
|
108
|
+
allow(File).to receive(:executable?).and_return(false)
|
109
|
+
allow(File).to receive(:directory?).and_return(false)
|
110
|
+
|
111
|
+
# allow for stubbing other paths to exist that we should not return
|
112
|
+
others.each do |other|
|
113
|
+
allow(File).to receive(:executable?).with(other).and_return(true)
|
114
|
+
end
|
115
|
+
|
116
|
+
# stub the expectation
|
117
|
+
finds.each do |path|
|
118
|
+
expect(File).to receive(:executable?).with(path).and_return(true)
|
119
|
+
end
|
120
|
+
|
121
|
+
# setup the actual expectation on the return value
|
122
|
+
expect(test.where(*args, &block)).to eql(finds)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "simple usage" do
|
127
|
+
test_where("returns empty array when it doesn't find anything", "foo1")
|
128
|
+
|
129
|
+
["/dir1", "/dir2", "/bin", "/usr/bin", "/sbin", "/usr/sbin" ].each do |dir|
|
130
|
+
test_where("finds `foo1` in #{dir} when it is stubbed", "foo1", finds: [ "#{dir}/foo1" ])
|
131
|
+
end
|
132
|
+
|
133
|
+
test_where("finds `foo1` in all directories", "foo1", finds: [ "/dir1/foo1", "/dir2/foo1" ])
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with an array of args" do
|
137
|
+
test_where("finds the first arg", "foo1", "foo2", finds: [ "/dir2/foo1" ])
|
138
|
+
|
139
|
+
test_where("finds the second arg", "foo1", "foo2", finds: [ "/dir2/foo2" ])
|
140
|
+
|
141
|
+
test_where("finds foo1 before foo2", "foo1", "foo2", finds: [ "/dir2/foo1", "/dir1/foo2" ])
|
142
|
+
|
143
|
+
test_where("finds foo1 before foo2 if the dirs are reversed", "foo1", "foo2", finds: [ "/dir1/foo1", "/dir2/foo2" ])
|
144
|
+
|
145
|
+
test_where("finds them both in the same directory", "foo1", "foo2", finds: [ "/dir1/foo1", "/dir1/foo2" ])
|
146
|
+
|
147
|
+
test_where("finds foo2 first if they're reversed", "foo2", "foo1", finds: [ "/dir1/foo2", "/dir1/foo1" ])
|
148
|
+
end
|
149
|
+
|
150
|
+
context "with a block do" do
|
151
|
+
test_where("finds foo1 and foo2 if they exist and the block is true", "foo1", "foo2", finds: [ "/dir1/foo2", "/dir2/foo2" ]) do
|
152
|
+
true
|
153
|
+
end
|
154
|
+
|
155
|
+
test_where("does not finds foo1 and foo2 if they exist and the block is false", "foo1", "foo2", others: [ "/dir1/foo2", "/dir2/foo2" ]) do
|
156
|
+
false
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
data/spec/unit/platform_spec.rb
CHANGED
@@ -21,6 +21,14 @@ require "spec_helper"
|
|
21
21
|
describe Chef::Platform do
|
22
22
|
|
23
23
|
context "while testing with fake data" do
|
24
|
+
def expect_platform_warning(method_name, times: 1, recurse: true)
|
25
|
+
expect(Chef).to receive(:deprecated).with(:chef_platform_methods, "Chef::Platform.#{method_name} is deprecated").exactly(times).times
|
26
|
+
return unless recurse
|
27
|
+
|
28
|
+
expect_platform_warning(:find_provider_for_node, times: times) if method_name == :provider_for_resource
|
29
|
+
expect_platform_warning(:find_provider, times: times) if method_name == :find_provider_for_node
|
30
|
+
expect_platform_warning(:find, times: times) if method_name == :find_provider
|
31
|
+
end
|
24
32
|
|
25
33
|
before :all do
|
26
34
|
@original_platform_map = Chef::Platform.platforms
|
@@ -31,7 +39,6 @@ describe Chef::Platform do
|
|
31
39
|
end
|
32
40
|
|
33
41
|
before(:each) do
|
34
|
-
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
35
42
|
Chef::Platform.platforms = {
|
36
43
|
:darwin => {
|
37
44
|
">= 10.11" => {
|
@@ -58,57 +65,67 @@ describe Chef::Platform do
|
|
58
65
|
end
|
59
66
|
|
60
67
|
it "should allow you to look up a platform by name and version, returning the provider map for it" do
|
68
|
+
expect_platform_warning(:find)
|
61
69
|
pmap = Chef::Platform.find("Darwin", "9.2.2")
|
62
70
|
expect(pmap).to be_a_kind_of(Hash)
|
63
71
|
expect(pmap[:file]).to eql("darwinian")
|
64
72
|
end
|
65
73
|
|
66
74
|
it "should allow you to look up a platform by name and version using \"greater than\" style operators" do
|
75
|
+
expect_platform_warning(:find)
|
67
76
|
pmap = Chef::Platform.find("Darwin", "11.1.0")
|
68
77
|
expect(pmap).to be_a_kind_of(Hash)
|
69
78
|
expect(pmap[:file]).to eql("new_darwinian")
|
70
79
|
end
|
71
80
|
|
72
81
|
it "should use the default providers for an os if the specific version does not exist" do
|
82
|
+
expect_platform_warning(:find)
|
73
83
|
pmap = Chef::Platform.find("Darwin", "1")
|
74
84
|
expect(pmap).to be_a_kind_of(Hash)
|
75
85
|
expect(pmap[:file]).to eql("old school")
|
76
86
|
end
|
77
87
|
|
78
88
|
it "should use the default providers if the os doesn't give me a default, but does exist" do
|
89
|
+
expect_platform_warning(:find)
|
79
90
|
pmap = Chef::Platform.find("mars_volta", "1")
|
80
91
|
expect(pmap).to be_a_kind_of(Hash)
|
81
92
|
expect(pmap[:file]).to eql(Chef::Provider::File)
|
82
93
|
end
|
83
94
|
|
84
95
|
it "should use the default provider if the os does not exist" do
|
96
|
+
expect_platform_warning(:find)
|
85
97
|
pmap = Chef::Platform.find("AIX", "1")
|
86
98
|
expect(pmap).to be_a_kind_of(Hash)
|
87
99
|
expect(pmap[:file]).to eql(Chef::Provider::File)
|
88
100
|
end
|
89
101
|
|
90
102
|
it "should merge the defaults for an os with the specific version" do
|
103
|
+
expect_platform_warning(:find)
|
91
104
|
pmap = Chef::Platform.find("Darwin", "9.2.2")
|
92
105
|
expect(pmap[:file]).to eql("darwinian")
|
93
106
|
expect(pmap[:snicker]).to eql("snack")
|
94
107
|
end
|
95
108
|
|
96
109
|
it "should merge the defaults for an os with the universal defaults" do
|
110
|
+
expect_platform_warning(:find)
|
97
111
|
pmap = Chef::Platform.find("Darwin", "9.2.2")
|
98
112
|
expect(pmap[:file]).to eql("darwinian")
|
99
113
|
expect(pmap[:pax]).to eql("brittania")
|
100
114
|
end
|
101
115
|
|
102
116
|
it "should allow you to look up a provider for a platform directly by symbol" do
|
117
|
+
expect_platform_warning(:find_provider)
|
103
118
|
expect(Chef::Platform.find_provider("Darwin", "9.2.2", :file)).to eql("darwinian")
|
104
119
|
end
|
105
120
|
|
106
121
|
it "should raise an exception if a provider cannot be found for a resource type" do
|
122
|
+
expect_platform_warning(:find_provider)
|
107
123
|
expect { Chef::Platform.find_provider("Darwin", "9.2.2", :coffee) }.to raise_error(Chef::Exceptions::ProviderNotFound)
|
108
124
|
end
|
109
125
|
|
110
126
|
it "should look up a provider for a resource with a Chef::Resource object" do
|
111
127
|
kitty = Chef::Resource::Cat.new("loulou")
|
128
|
+
expect_platform_warning(:find_provider)
|
112
129
|
expect(Chef::Platform.find_provider("Darwin", "9.2.2", kitty)).to eql("nice")
|
113
130
|
end
|
114
131
|
|
@@ -118,10 +135,12 @@ describe Chef::Platform do
|
|
118
135
|
node.name("Intel")
|
119
136
|
node.automatic_attrs[:platform] = "mac_os_x"
|
120
137
|
node.automatic_attrs[:platform_version] = "9.2.2"
|
138
|
+
expect_platform_warning(:find_provider_for_node)
|
121
139
|
expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql("nice")
|
122
140
|
end
|
123
141
|
|
124
142
|
it "should not throw an exception when the platform version has an unknown format" do
|
143
|
+
expect_platform_warning(:find_provider)
|
125
144
|
expect(Chef::Platform.find_provider(:darwin, "bad-version", :file)).to eql("old school")
|
126
145
|
end
|
127
146
|
|
@@ -132,6 +151,8 @@ describe Chef::Platform do
|
|
132
151
|
node.name("Intel")
|
133
152
|
node.automatic_attrs[:platform] = "mac_os_x"
|
134
153
|
node.automatic_attrs[:platform_version] = "9.2.2"
|
154
|
+
expect_platform_warning(:find_provider_for_node, recurse: false)
|
155
|
+
expect_platform_warning(:find_provider, recurse: false)
|
135
156
|
expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql(Chef::Provider::File)
|
136
157
|
end
|
137
158
|
|
@@ -143,6 +164,7 @@ describe Chef::Platform do
|
|
143
164
|
node.name("Intel")
|
144
165
|
node.automatic_attrs[:platform] = "mac_os_x"
|
145
166
|
node.automatic_attrs[:platform_version] = "8.5"
|
167
|
+
expect_platform_warning(:find_provider_for_node)
|
146
168
|
expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql(Chef::Provider::Cat)
|
147
169
|
end
|
148
170
|
|
@@ -156,6 +178,7 @@ describe Chef::Platform do
|
|
156
178
|
|
157
179
|
it "returns a provider object given a Chef::Resource object which has a valid run context and an action" do
|
158
180
|
file, run_context = setup_file_resource
|
181
|
+
expect_platform_warning(:provider_for_resource)
|
159
182
|
provider = Chef::Platform.provider_for_resource(file, :foo)
|
160
183
|
expect(provider).to be_an_instance_of(Chef::Provider::File)
|
161
184
|
expect(provider.new_resource).to equal(file)
|
@@ -164,6 +187,7 @@ describe Chef::Platform do
|
|
164
187
|
|
165
188
|
it "returns a provider object given a Chef::Resource object which has a valid run context without an action" do
|
166
189
|
file, run_context = setup_file_resource
|
190
|
+
expect_platform_warning(:provider_for_resource)
|
167
191
|
provider = Chef::Platform.provider_for_resource(file)
|
168
192
|
expect(provider).to be_an_instance_of(Chef::Provider::File)
|
169
193
|
expect(provider.new_resource).to equal(file)
|
@@ -172,6 +196,7 @@ describe Chef::Platform do
|
|
172
196
|
|
173
197
|
it "raises an error when trying to find the provider for a resource with no run context" do
|
174
198
|
file = Chef::Resource::File.new("whateva")
|
199
|
+
expect_platform_warning(:provider_for_resource, recurse: false)
|
175
200
|
expect { Chef::Platform.provider_for_resource(file) }.to raise_error(ArgumentError)
|
176
201
|
end
|
177
202
|
|
@@ -180,6 +205,7 @@ describe Chef::Platform do
|
|
180
205
|
end
|
181
206
|
|
182
207
|
it "should update the provider map with map" do
|
208
|
+
expect_platform_warning(:set, times: 7)
|
183
209
|
Chef::Platform.set(
|
184
210
|
:platform => :darwin,
|
185
211
|
:version => "9.2.2",
|
@@ -228,6 +254,7 @@ describe Chef::Platform do
|
|
228
254
|
end
|
229
255
|
|
230
256
|
it "does not overwrite the platform map when using :default platform" do
|
257
|
+
expect_platform_warning(:set)
|
231
258
|
Chef::Platform.set(
|
232
259
|
:resource => :file,
|
233
260
|
:platform => :default,
|