chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-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/Rakefile +12 -1
- data/lib/chef/api_client.rb +130 -26
- data/lib/chef/application.rb +0 -1
- data/lib/chef/application/client.rb +8 -19
- data/lib/chef/audit/audit_reporter.rb +12 -7
- data/lib/chef/audit/logger.rb +36 -0
- data/lib/chef/audit/runner.rb +4 -2
- data/lib/chef/chef_class.rb +62 -11
- data/lib/chef/client.rb +587 -207
- data/lib/chef/config.rb +0 -1
- data/lib/chef/dsl/recipe.rb +45 -56
- data/lib/chef/dsl/resources.rb +3 -2
- data/lib/chef/event_dispatch/base.rb +7 -2
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
- data/lib/chef/formatters/doc.rb +15 -7
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
- data/lib/chef/http/authenticator.rb +7 -2
- data/lib/chef/knife.rb +16 -4
- data/lib/chef/knife/client_create.rb +55 -31
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/osc_user_create.rb +97 -0
- data/lib/chef/knife/osc_user_delete.rb +51 -0
- data/lib/chef/knife/osc_user_edit.rb +58 -0
- data/lib/chef/knife/osc_user_list.rb +47 -0
- data/lib/chef/knife/osc_user_reregister.rb +64 -0
- data/lib/chef/knife/osc_user_show.rb +54 -0
- data/lib/chef/knife/user_create.rb +95 -36
- data/lib/chef/knife/user_delete.rb +52 -2
- data/lib/chef/knife/user_edit.rb +37 -7
- data/lib/chef/knife/user_list.rb +3 -0
- data/lib/chef/knife/user_reregister.rb +39 -8
- data/lib/chef/knife/user_show.rb +30 -1
- data/lib/chef/mixin/api_version_request_handling.rb +66 -0
- data/lib/chef/mixin/convert_to_class_name.rb +10 -4
- data/lib/chef/mixin/deprecation.rb +24 -0
- data/lib/chef/mixin/powershell_out.rb +98 -0
- data/lib/chef/mixin/provides.rb +5 -18
- data/lib/chef/mixin/uris.rb +11 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
- data/lib/chef/mixin/windows_env_helper.rb +11 -2
- data/lib/chef/node_map.rb +130 -75
- data/lib/chef/osc_user.rb +194 -0
- data/lib/chef/platform/provider_mapping.rb +2 -269
- data/lib/chef/platform/provider_priority_map.rb +6 -69
- data/lib/chef/platform/query_helpers.rb +5 -0
- data/lib/chef/platform/resource_priority_map.rb +12 -15
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/provider.rb +19 -0
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/dsc_resource.rb +8 -1
- data/lib/chef/provider/file.rb +1 -0
- data/lib/chef/provider/group/aix.rb +1 -0
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +1 -0
- data/lib/chef/provider/group/groupmod.rb +1 -1
- data/lib/chef/provider/group/pw.rb +1 -0
- data/lib/chef/provider/group/suse.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +2 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -0
- data/lib/chef/provider/ifconfig/aix.rb +1 -0
- data/lib/chef/provider/ifconfig/debian.rb +2 -0
- data/lib/chef/provider/ifconfig/redhat.rb +1 -0
- data/lib/chef/provider/lwrp_base.rb +4 -0
- data/lib/chef/provider/mount.rb +0 -1
- data/lib/chef/provider/mount/aix.rb +1 -0
- data/lib/chef/provider/mount/mount.rb +2 -0
- data/lib/chef/provider/mount/solaris.rb +2 -0
- data/lib/chef/provider/package.rb +55 -0
- data/lib/chef/provider/package/aix.rb +7 -7
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +4 -4
- data/lib/chef/provider/package/easy_install.rb +5 -5
- data/lib/chef/provider/package/freebsd/base.rb +2 -2
- data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
- data/lib/chef/provider/package/freebsd/port.rb +4 -4
- data/lib/chef/provider/package/homebrew.rb +2 -2
- data/lib/chef/provider/package/ips.rb +4 -4
- data/lib/chef/provider/package/macports.rb +5 -6
- data/lib/chef/provider/package/openbsd.rb +4 -5
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/rpm.rb +7 -8
- data/lib/chef/provider/package/rubygems.rb +5 -12
- data/lib/chef/provider/package/smartos.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +7 -7
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum.rb +4 -6
- data/lib/chef/provider/package/zypper.rb +16 -14
- data/lib/chef/provider/powershell_script.rb +129 -47
- data/lib/chef/provider/remote_file/content.rb +4 -1
- data/lib/chef/provider/remote_file/local_file.rb +10 -4
- data/lib/chef/provider/service.rb +44 -0
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +1 -0
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/windows.rb +0 -1
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -2
- data/lib/chef/provider/user/pw.rb +1 -0
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/provider_resolver.rb +87 -134
- data/lib/chef/resource.rb +274 -68
- data/lib/chef/resource/apt_package.rb +0 -2
- data/lib/chef/resource/bash.rb +0 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +0 -7
- data/lib/chef/resource/breakpoint.rb +3 -6
- data/lib/chef/resource/chef_gem.rb +0 -3
- data/lib/chef/resource/cookbook_file.rb +1 -3
- data/lib/chef/resource/cron.rb +2 -4
- data/lib/chef/resource/csh.rb +0 -2
- data/lib/chef/resource/deploy.rb +9 -6
- data/lib/chef/resource/deploy_revision.rb +0 -14
- data/lib/chef/resource/directory.rb +2 -4
- data/lib/chef/resource/dpkg_package.rb +0 -5
- data/lib/chef/resource/dsc_resource.rb +2 -3
- data/lib/chef/resource/dsc_script.rb +2 -3
- data/lib/chef/resource/easy_install_package.rb +0 -7
- data/lib/chef/resource/env.rb +3 -3
- data/lib/chef/resource/erl_call.rb +2 -5
- data/lib/chef/resource/execute.rb +2 -4
- data/lib/chef/resource/file.rb +2 -4
- data/lib/chef/resource/freebsd_package.rb +0 -5
- data/lib/chef/resource/gem_package.rb +0 -3
- data/lib/chef/resource/git.rb +0 -3
- data/lib/chef/resource/group.rb +2 -4
- data/lib/chef/resource/homebrew_package.rb +0 -2
- data/lib/chef/resource/http_request.rb +3 -4
- data/lib/chef/resource/ifconfig.rb +3 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/link.rb +3 -5
- data/lib/chef/resource/log.rb +2 -4
- data/lib/chef/resource/lwrp_base.rb +10 -61
- data/lib/chef/resource/macosx_service.rb +1 -2
- data/lib/chef/resource/macports_package.rb +0 -7
- data/lib/chef/resource/mdadm.rb +2 -5
- data/lib/chef/resource/mount.rb +2 -4
- data/lib/chef/resource/ohai.rb +2 -4
- data/lib/chef/resource/openbsd_package.rb +0 -6
- data/lib/chef/resource/package.rb +9 -6
- data/lib/chef/resource/pacman_package.rb +0 -7
- data/lib/chef/resource/paludis_package.rb +2 -3
- data/lib/chef/resource/perl.rb +0 -3
- data/lib/chef/resource/portage_package.rb +0 -3
- data/lib/chef/resource/powershell_script.rb +1 -2
- data/lib/chef/resource/python.rb +0 -3
- data/lib/chef/resource/reboot.rb +1 -3
- data/lib/chef/resource/registry_key.rb +3 -5
- data/lib/chef/resource/remote_directory.rb +3 -5
- data/lib/chef/resource/remote_file.rb +4 -5
- data/lib/chef/resource/route.rb +3 -5
- data/lib/chef/resource/rpm_package.rb +0 -2
- data/lib/chef/resource/ruby.rb +0 -4
- data/lib/chef/resource/ruby_block.rb +2 -4
- data/lib/chef/resource/scm.rb +3 -5
- data/lib/chef/resource/script.rb +0 -3
- data/lib/chef/resource/service.rb +3 -5
- data/lib/chef/resource/smartos_package.rb +0 -9
- data/lib/chef/resource/solaris_package.rb +0 -10
- data/lib/chef/resource/subversion.rb +1 -3
- data/lib/chef/resource/template.rb +0 -4
- data/lib/chef/resource/timestamped_deploy.rb +0 -4
- data/lib/chef/resource/user.rb +2 -5
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_script.rb +2 -2
- data/lib/chef/resource/windows_service.rb +3 -3
- data/lib/chef/resource/yum_package.rb +0 -3
- data/lib/chef/resource/zypper_package.rb +27 -0
- data/lib/chef/resource_builder.rb +7 -0
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resource_resolver.rb +108 -62
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/user.rb +193 -42
- data/lib/chef/util/backup.rb +9 -1
- data/lib/chef/util/path_helper.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +22 -42
- data/spec/functional/mixin/powershell_out_spec.rb +43 -0
- data/spec/functional/resource/execute_spec.rb +9 -2
- data/spec/functional/resource/file_spec.rb +25 -0
- data/spec/functional/resource/group_spec.rb +5 -0
- data/spec/functional/resource/link_spec.rb +5 -11
- data/spec/functional/resource/powershell_spec.rb +40 -5
- data/spec/functional/resource/user/useradd_spec.rb +10 -18
- data/spec/integration/recipes/lwrp_spec.rb +57 -0
- data/spec/integration/recipes/provider_choice.rb +2 -7
- data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
- data/spec/support/lib/chef/resource/cat.rb +0 -2
- data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
- data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
- data/spec/support/lib/chef/resource/with_state.rb +0 -9
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
- data/spec/support/lib/chef/resource/zen_master.rb +1 -6
- data/spec/support/shared/context/client.rb +277 -0
- data/spec/support/shared/examples/client.rb +53 -0
- data/spec/support/shared/functional/file_resource.rb +0 -4
- data/spec/support/shared/functional/securable_resource.rb +0 -24
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/api_versioning.rb +77 -0
- data/spec/support/shared/unit/knife_shared.rb +40 -0
- data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
- data/spec/unit/api_client_spec.rb +189 -14
- data/spec/unit/application/client_spec.rb +0 -5
- data/spec/unit/audit/audit_reporter_spec.rb +58 -14
- data/spec/unit/audit/logger_spec.rb +42 -0
- data/spec/unit/audit/runner_spec.rb +2 -2
- data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
- data/spec/unit/client_spec.rb +58 -374
- data/spec/unit/cookbook_spec.rb +0 -9
- data/spec/unit/cookbook_version_spec.rb +0 -20
- data/spec/unit/deprecation_spec.rb +55 -0
- data/spec/unit/dsl/resources_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +2 -2
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
- data/spec/unit/formatters/doc_spec.rb +46 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +11 -2
- data/spec/unit/knife/client_create_spec.rb +122 -51
- data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
- data/spec/unit/knife/core/ui_spec.rb +14 -0
- data/spec/unit/knife/osc_user_create_spec.rb +93 -0
- data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
- data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
- data/spec/unit/knife/osc_user_list_spec.rb +37 -0
- data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
- data/spec/unit/knife/osc_user_show_spec.rb +46 -0
- data/spec/unit/knife/user_create_spec.rb +177 -51
- data/spec/unit/knife/user_delete_spec.rb +34 -8
- data/spec/unit/knife/user_edit_spec.rb +31 -12
- data/spec/unit/knife/user_list_spec.rb +7 -3
- data/spec/unit/knife/user_reregister_spec.rb +38 -17
- data/spec/unit/knife/user_show_spec.rb +35 -11
- data/spec/unit/knife_spec.rb +10 -4
- data/spec/unit/lwrp_spec.rb +228 -54
- data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
- data/spec/unit/mixin/command_spec.rb +1 -2
- data/spec/unit/mixin/powershell_out_spec.rb +70 -0
- data/spec/unit/mixin/uris_spec.rb +23 -11
- data/spec/unit/node_map_spec.rb +4 -1
- data/spec/unit/osc_user_spec.rb +276 -0
- data/spec/unit/platform_spec.rb +0 -60
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +199 -135
- data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
- data/spec/unit/provider/package/aix_spec.rb +16 -16
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
- data/spec/unit/provider/package/ips_spec.rb +22 -22
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +4 -26
- data/spec/unit/provider/package/pacman_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +14 -14
- data/spec/unit/provider/package/rubygems_spec.rb +10 -44
- data/spec/unit/provider/package/smartos_spec.rb +4 -4
- data/spec/unit/provider/package/solaris_spec.rb +11 -11
- data/spec/unit/provider/package/zypper_spec.rb +125 -90
- data/spec/unit/provider/package_spec.rb +34 -0
- data/spec/unit/provider/powershell_spec.rb +53 -11
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
- data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
- data/spec/unit/provider/user_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +463 -327
- data/spec/unit/recipe_spec.rb +42 -15
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/ifconfig_spec.rb +10 -6
- data/spec/unit/resource/remote_file_spec.rb +5 -0
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +2 -2
- data/spec/unit/resource/template_spec.rb +1 -1
- data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +99 -13
- data/spec/unit/rest_spec.rb +5 -5
- data/spec/unit/run_context_spec.rb +41 -0
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/user_spec.rb +406 -93
- data/tasks/maintainers.rb +69 -0
- metadata +37 -4
@@ -19,126 +19,150 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
21
|
describe Chef::Provider::Package::Zypper do
|
22
|
+
let!(:new_resource) { Chef::Resource::ZypperPackage.new("cups") }
|
23
|
+
|
24
|
+
let!(:current_resource) { Chef::Resource::ZypperPackage.new("cups") }
|
25
|
+
|
26
|
+
let(:provider) do
|
27
|
+
node = Chef::Node.new
|
28
|
+
events = Chef::EventDispatch::Dispatcher.new
|
29
|
+
run_context = Chef::RunContext.new(node, {}, events)
|
30
|
+
Chef::Provider::Package::Zypper.new(new_resource, run_context)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:status) { double(:stdout => "\n", :exitstatus => 0) }
|
34
|
+
|
22
35
|
before(:each) do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
|
37
|
+
allow(provider).to receive(:shell_out).and_return(status)
|
38
|
+
allow(provider).to receive(:`).and_return("2.0")
|
39
|
+
end
|
40
|
+
|
41
|
+
def shell_out_expectation(command, options=nil)
|
42
|
+
options ||= { timeout: 900 }
|
43
|
+
expect(provider).to receive(:shell_out).with(command, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def shell_out_expectation!(command, options=nil)
|
47
|
+
options ||= { timeout: 900 }
|
48
|
+
expect(provider).to receive(:shell_out!).with(command, options)
|
35
49
|
end
|
36
50
|
|
37
51
|
describe "when loading the current package state" do
|
38
52
|
it "should create a current resource with the name of the new_resource" do
|
39
|
-
expect(Chef::Resource::Package).to receive(:new).and_return(
|
40
|
-
|
53
|
+
expect(Chef::Resource::Package).to receive(:new).with(new_resource.name).and_return(current_resource)
|
54
|
+
provider.load_current_resource
|
41
55
|
end
|
42
56
|
|
43
57
|
it "should set the current resources package name to the new resources package name" do
|
44
|
-
expect(
|
45
|
-
|
58
|
+
expect(current_resource).to receive(:package_name).with(new_resource.package_name)
|
59
|
+
provider.load_current_resource
|
46
60
|
end
|
47
61
|
|
48
62
|
it "should run zypper info with the package name" do
|
49
|
-
|
50
|
-
|
63
|
+
shell_out_expectation(
|
64
|
+
"zypper --non-interactive info #{new_resource.package_name}"
|
65
|
+
).and_return(status)
|
66
|
+
provider.load_current_resource
|
51
67
|
end
|
52
68
|
|
53
69
|
it "should set the installed version to nil on the current resource if zypper info installed version is (none)" do
|
54
|
-
allow(
|
55
|
-
expect(
|
56
|
-
|
70
|
+
allow(provider).to receive(:shell_out).and_return(status)
|
71
|
+
expect(current_resource).to receive(:version).with(nil).and_return(true)
|
72
|
+
provider.load_current_resource
|
57
73
|
end
|
58
74
|
|
59
75
|
it "should set the installed version if zypper info has one" do
|
60
76
|
status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0)
|
61
77
|
|
62
|
-
allow(
|
63
|
-
expect(
|
64
|
-
|
78
|
+
allow(provider).to receive(:shell_out).and_return(status)
|
79
|
+
expect(current_resource).to receive(:version).with("1.0").and_return(true)
|
80
|
+
provider.load_current_resource
|
65
81
|
end
|
66
82
|
|
67
83
|
it "should set the candidate version if zypper info has one" do
|
68
84
|
status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0)
|
69
85
|
|
70
|
-
allow(
|
71
|
-
|
72
|
-
expect(
|
86
|
+
allow(provider).to receive(:shell_out).and_return(status)
|
87
|
+
provider.load_current_resource
|
88
|
+
expect(provider.candidate_version).to eql("1.0")
|
73
89
|
end
|
74
90
|
|
75
91
|
it "should raise an exception if zypper info fails" do
|
76
|
-
expect(
|
77
|
-
expect {
|
92
|
+
expect(status).to receive(:exitstatus).and_return(1)
|
93
|
+
expect { provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
|
78
94
|
end
|
79
95
|
|
80
96
|
it "should not raise an exception if zypper info succeeds" do
|
81
|
-
expect(
|
82
|
-
expect {
|
97
|
+
expect(status).to receive(:exitstatus).and_return(0)
|
98
|
+
expect { provider.load_current_resource }.not_to raise_error
|
83
99
|
end
|
84
100
|
|
85
101
|
it "should return the current resouce" do
|
86
|
-
expect(
|
102
|
+
expect(provider.load_current_resource).to eql(current_resource)
|
87
103
|
end
|
88
104
|
end
|
89
105
|
|
90
106
|
describe "install_package" do
|
91
107
|
it "should run zypper install with the package name and version" do
|
92
108
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(true)
|
93
|
-
|
94
|
-
"zypper --non-interactive install --auto-agree-with-licenses emacs=1.0"
|
95
|
-
|
109
|
+
shell_out_expectation!(
|
110
|
+
"zypper --non-interactive install --auto-agree-with-licenses emacs=1.0"
|
111
|
+
)
|
112
|
+
provider.install_package("emacs", "1.0")
|
96
113
|
end
|
97
114
|
it "should run zypper install without gpg checks" do
|
98
115
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
|
99
|
-
|
116
|
+
shell_out_expectation!(
|
100
117
|
"zypper --non-interactive --no-gpg-checks install "+
|
101
|
-
"--auto-agree-with-licenses emacs=1.0"
|
102
|
-
|
118
|
+
"--auto-agree-with-licenses emacs=1.0"
|
119
|
+
)
|
120
|
+
provider.install_package("emacs", "1.0")
|
103
121
|
end
|
104
122
|
it "should warn about gpg checks on zypper install" do
|
105
123
|
expect(Chef::Log).to receive(:warn).with(
|
106
|
-
/All packages will be installed without gpg signature checks/
|
107
|
-
|
124
|
+
/All packages will be installed without gpg signature checks/
|
125
|
+
)
|
126
|
+
shell_out_expectation!(
|
108
127
|
"zypper --non-interactive --no-gpg-checks install "+
|
109
|
-
"--auto-agree-with-licenses emacs=1.0"
|
110
|
-
|
128
|
+
"--auto-agree-with-licenses emacs=1.0"
|
129
|
+
)
|
130
|
+
provider.install_package("emacs", "1.0")
|
111
131
|
end
|
112
132
|
end
|
113
133
|
|
114
134
|
describe "upgrade_package" do
|
115
135
|
it "should run zypper update with the package name and version" do
|
116
136
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(true)
|
117
|
-
|
118
|
-
"zypper --non-interactive install --auto-agree-with-licenses emacs=1.0"
|
119
|
-
|
137
|
+
shell_out_expectation!(
|
138
|
+
"zypper --non-interactive install --auto-agree-with-licenses emacs=1.0"
|
139
|
+
)
|
140
|
+
provider.upgrade_package("emacs", "1.0")
|
120
141
|
end
|
121
142
|
it "should run zypper update without gpg checks" do
|
122
143
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
|
123
|
-
|
144
|
+
shell_out_expectation!(
|
124
145
|
"zypper --non-interactive --no-gpg-checks install "+
|
125
|
-
"--auto-agree-with-licenses emacs=1.0"
|
126
|
-
|
146
|
+
"--auto-agree-with-licenses emacs=1.0"
|
147
|
+
)
|
148
|
+
provider.upgrade_package("emacs", "1.0")
|
127
149
|
end
|
128
150
|
it "should warn about gpg checks on zypper upgrade" do
|
129
151
|
expect(Chef::Log).to receive(:warn).with(
|
130
|
-
/All packages will be installed without gpg signature checks/
|
131
|
-
|
152
|
+
/All packages will be installed without gpg signature checks/
|
153
|
+
)
|
154
|
+
shell_out_expectation!(
|
132
155
|
"zypper --non-interactive --no-gpg-checks install "+
|
133
|
-
"--auto-agree-with-licenses emacs=1.0"
|
134
|
-
|
156
|
+
"--auto-agree-with-licenses emacs=1.0"
|
157
|
+
)
|
158
|
+
provider.upgrade_package("emacs", "1.0")
|
135
159
|
end
|
136
160
|
it "should run zypper upgrade without gpg checks" do
|
137
|
-
|
161
|
+
shell_out_expectation!(
|
138
162
|
"zypper --non-interactive --no-gpg-checks install "+
|
139
|
-
"--auto-agree-with-licenses emacs=1.0"
|
140
|
-
|
141
|
-
|
163
|
+
"--auto-agree-with-licenses emacs=1.0"
|
164
|
+
)
|
165
|
+
provider.upgrade_package("emacs", "1.0")
|
142
166
|
end
|
143
167
|
end
|
144
168
|
|
@@ -147,83 +171,94 @@ describe Chef::Provider::Package::Zypper do
|
|
147
171
|
context "when package version is not explicitly specified" do
|
148
172
|
it "should run zypper remove with the package name" do
|
149
173
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(true)
|
150
|
-
|
151
|
-
"zypper --non-interactive remove emacs"
|
152
|
-
|
174
|
+
shell_out_expectation!(
|
175
|
+
"zypper --non-interactive remove emacs"
|
176
|
+
)
|
177
|
+
provider.remove_package("emacs", nil)
|
153
178
|
end
|
154
179
|
end
|
155
180
|
|
156
181
|
context "when package version is explicitly specified" do
|
157
182
|
it "should run zypper remove with the package name" do
|
158
183
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(true)
|
159
|
-
|
160
|
-
"zypper --non-interactive remove emacs=1.0"
|
161
|
-
|
184
|
+
shell_out_expectation!(
|
185
|
+
"zypper --non-interactive remove emacs=1.0"
|
186
|
+
)
|
187
|
+
provider.remove_package("emacs", "1.0")
|
162
188
|
end
|
163
189
|
it "should run zypper remove without gpg checks" do
|
164
190
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
|
165
|
-
|
166
|
-
"zypper --non-interactive --no-gpg-checks remove emacs=1.0"
|
167
|
-
|
191
|
+
shell_out_expectation!(
|
192
|
+
"zypper --non-interactive --no-gpg-checks remove emacs=1.0"
|
193
|
+
)
|
194
|
+
provider.remove_package("emacs", "1.0")
|
168
195
|
end
|
169
196
|
it "should warn about gpg checks on zypper remove" do
|
170
197
|
expect(Chef::Log).to receive(:warn).with(
|
171
|
-
/All packages will be installed without gpg signature checks/
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
198
|
+
/All packages will be installed without gpg signature checks/
|
199
|
+
)
|
200
|
+
shell_out_expectation!(
|
201
|
+
"zypper --non-interactive --no-gpg-checks remove emacs=1.0"
|
202
|
+
)
|
203
|
+
provider.remove_package("emacs", "1.0")
|
176
204
|
end
|
177
205
|
end
|
178
206
|
end
|
179
207
|
|
180
208
|
describe "purge_package" do
|
181
209
|
it "should run remove_package with the name and version" do
|
182
|
-
|
183
|
-
"zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0"
|
184
|
-
|
210
|
+
shell_out_expectation!(
|
211
|
+
"zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0"
|
212
|
+
)
|
213
|
+
provider.purge_package("emacs", "1.0")
|
185
214
|
end
|
186
215
|
it "should run zypper purge without gpg checks" do
|
187
216
|
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
|
188
|
-
|
189
|
-
"zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0"
|
190
|
-
|
217
|
+
shell_out_expectation!(
|
218
|
+
"zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0"
|
219
|
+
)
|
220
|
+
provider.purge_package("emacs", "1.0")
|
191
221
|
end
|
192
222
|
it "should warn about gpg checks on zypper purge" do
|
193
223
|
expect(Chef::Log).to receive(:warn).with(
|
194
|
-
/All packages will be installed without gpg signature checks/
|
195
|
-
|
196
|
-
|
197
|
-
|
224
|
+
/All packages will be installed without gpg signature checks/
|
225
|
+
)
|
226
|
+
shell_out_expectation!(
|
227
|
+
"zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0"
|
228
|
+
)
|
229
|
+
provider.purge_package("emacs", "1.0")
|
198
230
|
end
|
199
231
|
end
|
200
232
|
|
201
233
|
describe "on an older zypper" do
|
202
234
|
before(:each) do
|
203
|
-
allow(
|
235
|
+
allow(provider).to receive(:`).and_return("0.11.6")
|
204
236
|
end
|
205
237
|
|
206
238
|
describe "install_package" do
|
207
239
|
it "should run zypper install with the package name and version" do
|
208
|
-
|
209
|
-
"zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs"
|
210
|
-
|
240
|
+
shell_out_expectation!(
|
241
|
+
"zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs"
|
242
|
+
)
|
243
|
+
provider.install_package("emacs", "1.0")
|
211
244
|
end
|
212
245
|
end
|
213
246
|
|
214
247
|
describe "upgrade_package" do
|
215
248
|
it "should run zypper update with the package name and version" do
|
216
|
-
|
217
|
-
"zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs"
|
218
|
-
|
249
|
+
shell_out_expectation!(
|
250
|
+
"zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs"
|
251
|
+
)
|
252
|
+
provider.upgrade_package("emacs", "1.0")
|
219
253
|
end
|
220
254
|
end
|
221
255
|
|
222
256
|
describe "remove_package" do
|
223
257
|
it "should run zypper remove with the package name" do
|
224
|
-
|
225
|
-
"zypper --no-gpg-checks remove -y emacs"
|
226
|
-
|
258
|
+
shell_out_expectation!(
|
259
|
+
"zypper --no-gpg-checks remove -y emacs"
|
260
|
+
)
|
261
|
+
provider.remove_package("emacs", "1.0")
|
227
262
|
end
|
228
263
|
end
|
229
264
|
end
|
@@ -704,4 +704,38 @@ describe "Chef::Provider::Package - Multi" do
|
|
704
704
|
expect(@new_resource).not_to be_updated_by_last_action
|
705
705
|
end
|
706
706
|
end
|
707
|
+
|
708
|
+
describe "shell_out helpers" do
|
709
|
+
[ :shell_out_with_timeout, :shell_out_with_timeout! ].each do |method|
|
710
|
+
stubbed_method = method == :shell_out_with_timeout! ? :shell_out! : :shell_out
|
711
|
+
[ %w{command arg1 arg2}, "command arg1 arg2" ].each do |command|
|
712
|
+
it "#{method} defaults to 900 seconds" do
|
713
|
+
expect(@provider).to receive(stubbed_method).with(*command, timeout: 900)
|
714
|
+
@provider.send(method, *command)
|
715
|
+
end
|
716
|
+
it "#{method} overrides the default timeout with its options" do
|
717
|
+
expect(@provider).to receive(stubbed_method).with(*command, timeout: 1)
|
718
|
+
@provider.send(method, *command, timeout: 1)
|
719
|
+
end
|
720
|
+
it "#{method} overrides both timeouts with the new_resource.timeout" do
|
721
|
+
@new_resource.timeout(99)
|
722
|
+
expect(@provider).to receive(stubbed_method).with(*command, timeout: 99)
|
723
|
+
@provider.send(method, *command, timeout: 1)
|
724
|
+
end
|
725
|
+
it "#{method} defaults to 900 seconds and preserves options" do
|
726
|
+
expect(@provider).to receive(stubbed_method).with(*command, env: nil, timeout: 900)
|
727
|
+
@provider.send(method, *command, env: nil)
|
728
|
+
end
|
729
|
+
it "#{method} overrides the default timeout with its options and preserves options" do
|
730
|
+
expect(@provider).to receive(stubbed_method).with(*command, timeout: 1, env: nil)
|
731
|
+
@provider.send(method, *command, timeout: 1, env: nil)
|
732
|
+
end
|
733
|
+
it "#{method} overrides both timeouts with the new_resource.timeout and preseves options" do
|
734
|
+
@new_resource.timeout(99)
|
735
|
+
expect(@provider).to receive(stubbed_method).with(*command, timeout: 99, env: nil)
|
736
|
+
@provider.send(method, *command, timeout: 1, env: nil)
|
737
|
+
end
|
738
|
+
end
|
739
|
+
end
|
740
|
+
end
|
707
741
|
end
|
@@ -19,20 +19,62 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
describe Chef::Provider::PowershellScript, "action_run" do
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
let(:powershell_version) { nil }
|
23
|
+
let(:node) {
|
24
|
+
node = Chef::Node.new
|
25
|
+
node.default["kernel"] = Hash.new
|
26
|
+
node.default["kernel"][:machine] = :x86_64.to_s
|
27
|
+
if ! powershell_version.nil?
|
28
|
+
node.default[:languages] = { :powershell => { :version => powershell_version } }
|
29
|
+
end
|
30
|
+
node
|
31
|
+
}
|
24
32
|
|
25
|
-
|
26
|
-
|
33
|
+
let(:provider) {
|
34
|
+
empty_events = Chef::EventDispatch::Dispatcher.new
|
35
|
+
run_context = Chef::RunContext.new(node, {}, empty_events)
|
36
|
+
new_resource = Chef::Resource::PowershellScript.new('run some powershell code', run_context)
|
37
|
+
Chef::Provider::PowershellScript.new(new_resource, run_context)
|
38
|
+
}
|
27
39
|
|
28
|
-
|
29
|
-
|
40
|
+
context 'when setting interpreter flags' do
|
41
|
+
it "should set the -File flag as the last flag" do
|
42
|
+
expect(provider.flags.split(' ').pop).to eq("-File")
|
43
|
+
end
|
30
44
|
|
31
|
-
|
32
|
-
|
45
|
+
let(:execution_policy_flag) do
|
46
|
+
execution_policy_index = 0
|
47
|
+
provider_flags = provider.flags.split(' ')
|
48
|
+
execution_policy_specified = false
|
33
49
|
|
34
|
-
|
35
|
-
|
36
|
-
|
50
|
+
provider_flags.find do | value |
|
51
|
+
execution_policy_index += 1
|
52
|
+
execution_policy_specified = value.downcase == '-ExecutionPolicy'.downcase
|
53
|
+
end
|
54
|
+
|
55
|
+
execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil
|
56
|
+
end
|
37
57
|
|
58
|
+
context 'when running with an unspecified PowerShell version' do
|
59
|
+
let(:powershell_version) { nil }
|
60
|
+
it "should set the -ExecutionPolicy flag to 'Unrestricted' by default" do
|
61
|
+
expect(execution_policy_flag.downcase).to eq('unrestricted'.downcase)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
{ '2.0' => 'Unrestricted',
|
66
|
+
'2.5' => 'Unrestricted',
|
67
|
+
'3.0' => 'Bypass',
|
68
|
+
'3.6' => 'Bypass',
|
69
|
+
'4.0' => 'Bypass',
|
70
|
+
'5.0' => 'Bypass' }.each do | version_policy |
|
71
|
+
let(:powershell_version) { version_policy[0].to_f }
|
72
|
+
context "when running PowerShell version #{version_policy[0]}" do
|
73
|
+
let(:powershell_version) { version_policy[0].to_f }
|
74
|
+
it "should set the -ExecutionPolicy flag to '#{version_policy[1]}'" do
|
75
|
+
expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
38
80
|
end
|
@@ -194,8 +194,8 @@ describe Chef::Provider::RemoteDirectory do
|
|
194
194
|
|
195
195
|
expect(::File.exist?(symlinked_dir_path)).to be_falsey
|
196
196
|
expect(::File.exist?(tmp_dir)).to be_truthy
|
197
|
-
rescue Chef::Exceptions::Win32APIError
|
198
|
-
|
197
|
+
rescue Chef::Exceptions::Win32APIError
|
198
|
+
skip "This must be run as an Administrator to create symlinks"
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|