chef 15.4.45 → 15.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +32 -8
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright 2011-
|
3
|
+
# Copyright:: Copyright 2011-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -35,7 +35,7 @@ describe Chef::Mixin::PathSanity do
|
|
35
35
|
@gem_bindir = "/some/gem/bin"
|
36
36
|
allow(Gem).to receive(:bindir).and_return(@gem_bindir)
|
37
37
|
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(@ruby_bindir)
|
38
|
-
allow(
|
38
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "adds all useful PATHs even if environment is an empty hash" do
|
@@ -83,7 +83,7 @@ describe Chef::Mixin::PathSanity do
|
|
83
83
|
gem_bindir = 'C:\gems\bin'
|
84
84
|
allow(Gem).to receive(:bindir).and_return(gem_bindir)
|
85
85
|
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
|
86
|
-
allow(
|
86
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
87
87
|
env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' }
|
88
88
|
@sanity.enforce_path_sanity(env)
|
89
89
|
expect(env["PATH"]).to eq("#{gem_bindir};#{ruby_bindir};C:\\Windows\\system32;C:\\mr\\softie")
|
@@ -24,13 +24,12 @@ require "spec_helper"
|
|
24
24
|
require "chef/mixin/path_sanity"
|
25
25
|
|
26
26
|
describe Chef::Mixin::ShellOut do
|
27
|
-
include
|
28
|
-
|
27
|
+
include ChefUtils::DSL::PathSanity
|
29
28
|
let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } }
|
30
29
|
subject(:shell_out_obj) { shell_out_class.new }
|
31
30
|
|
32
31
|
def env_path
|
33
|
-
if
|
32
|
+
if ChefUtils.windows?
|
34
33
|
"Path"
|
35
34
|
else
|
36
35
|
"PATH"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,7 +21,7 @@ require "spec_helper"
|
|
21
21
|
require "cgi"
|
22
22
|
describe Chef::Mixin::Template, "render_template" do
|
23
23
|
|
24
|
-
let(:sep) {
|
24
|
+
let(:sep) { ChefUtils.windows? ? "\r\n" : "\n" }
|
25
25
|
|
26
26
|
before :each do
|
27
27
|
@context = Chef::Mixin::Template::TemplateContext.new({})
|
@@ -39,7 +39,7 @@ describe Chef::Mixin::Template, "render_template" do
|
|
39
39
|
|
40
40
|
describe "when running on windows" do
|
41
41
|
before do
|
42
|
-
allow(
|
42
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should render the templates with windows line endings" do
|
@@ -54,7 +54,7 @@ describe Chef::Mixin::Template, "render_template" do
|
|
54
54
|
|
55
55
|
describe "when running on unix" do
|
56
56
|
before do
|
57
|
-
allow(
|
57
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should render the templates with unix line endings" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Edwards (<adamed@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2015 Chef Software
|
3
|
+
# Copyright:: Copyright (c) 2015-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -39,7 +39,7 @@ describe "a class that mixes in user_context" do
|
|
39
39
|
|
40
40
|
context "when running on Windows" do
|
41
41
|
before do
|
42
|
-
allow(
|
42
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
43
43
|
allow(::Chef::Util::Windows::LogonSession).to receive(:new).and_return(logon_session)
|
44
44
|
end
|
45
45
|
|
@@ -97,7 +97,7 @@ describe "a class that mixes in user_context" do
|
|
97
97
|
|
98
98
|
context "when not running on Windows" do
|
99
99
|
before do
|
100
|
-
allow(
|
100
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "raises a ::Chef::Exceptions::UnsupportedPlatform exception" do
|
data/spec/unit/node_map_spec.rb
CHANGED
@@ -104,8 +104,8 @@ describe Chef::NodeMap do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "returns nil when the platform_family does not match" do
|
107
|
-
|
108
|
-
|
107
|
+
node.automatic["os"] = "linux"
|
108
|
+
node.automatic["platform_family"] = "debian"
|
109
109
|
expect(node_map.get(node, :thing)).to eql(nil)
|
110
110
|
end
|
111
111
|
end
|
@@ -174,26 +174,26 @@ describe Chef::NodeMap do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "returns the value when the node matches" do
|
177
|
-
|
178
|
-
|
177
|
+
node.automatic["platform_family"] = "rhel"
|
178
|
+
node.automatic["platform_version"] = "7.0"
|
179
179
|
expect(node_map.get(node, :thing)).to eql(:foo)
|
180
180
|
end
|
181
181
|
|
182
182
|
it "returns nil when the block does not match" do
|
183
|
-
|
184
|
-
|
183
|
+
node.automatic["platform_family"] = "rhel"
|
184
|
+
node.automatic["platform_version"] = "6.4"
|
185
185
|
expect(node_map.get(node, :thing)).to eql(nil)
|
186
186
|
end
|
187
187
|
|
188
188
|
it "returns nil when the platform_family filter does not match" do
|
189
|
-
|
190
|
-
|
189
|
+
node.automatic["platform_family"] = "debian"
|
190
|
+
node.automatic["platform_version"] = "7.0"
|
191
191
|
expect(node_map.get(node, :thing)).to eql(nil)
|
192
192
|
end
|
193
193
|
|
194
194
|
it "returns nil when both do not match" do
|
195
|
-
|
196
|
-
|
195
|
+
node.automatic["platform_family"] = "debian"
|
196
|
+
node.automatic["platform_version"] = "6.0"
|
197
197
|
expect(node_map.get(node, :thing)).to eql(nil)
|
198
198
|
end
|
199
199
|
|
@@ -203,8 +203,8 @@ describe Chef::NodeMap do
|
|
203
203
|
end
|
204
204
|
|
205
205
|
it "returns the value when the node matches" do
|
206
|
-
|
207
|
-
|
206
|
+
node.automatic["platform_family"] = "rhel"
|
207
|
+
node.automatic["platform_version"] = "7.0"
|
208
208
|
expect(node_map.get(node, :thing)).to eql(:foo)
|
209
209
|
end
|
210
210
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright 2014-
|
3
|
+
# Copyright:: Copyright 2014-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -43,13 +43,13 @@ describe "Chef::Platform#windows_nano_server?" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns false early when not on windows" do
|
46
|
-
allow(
|
46
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
47
47
|
expect(Chef::Platform).to_not receive(:require)
|
48
48
|
expect(Chef::Platform.windows_nano_server?).to be false
|
49
49
|
end
|
50
50
|
|
51
51
|
it "returns true when the registry value is 1" do
|
52
|
-
allow(
|
52
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
53
53
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
54
54
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
55
55
|
.with(key, access)
|
@@ -59,7 +59,7 @@ describe "Chef::Platform#windows_nano_server?" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns false when the registry value is not 1" do
|
62
|
-
allow(
|
62
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
63
63
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
64
64
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
65
65
|
.with(key, access)
|
@@ -69,7 +69,7 @@ describe "Chef::Platform#windows_nano_server?" do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "returns false when the registry value does not exist" do
|
72
|
-
allow(
|
72
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
73
73
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
74
74
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
75
75
|
.with(key, access)
|
@@ -80,7 +80,7 @@ describe "Chef::Platform#windows_nano_server?" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "returns false when the registry key does not exist" do
|
83
|
-
allow(
|
83
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
84
84
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
85
85
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
86
86
|
.with(key, access)
|
@@ -114,13 +114,13 @@ describe "Chef::Platform#supports_msi?" do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "returns false early when not on windows" do
|
117
|
-
allow(
|
117
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
118
118
|
expect(Chef::Platform).to_not receive(:require)
|
119
119
|
expect(Chef::Platform.supports_msi?).to be false
|
120
120
|
end
|
121
121
|
|
122
122
|
it "returns true when the registry key exists" do
|
123
|
-
allow(
|
123
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
124
124
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
125
125
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
126
126
|
.with(key, access)
|
@@ -129,7 +129,7 @@ describe "Chef::Platform#supports_msi?" do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "returns false when the registry key does not exist" do
|
132
|
-
allow(
|
132
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
133
133
|
allow(Chef::Platform).to receive(:require).with("win32/registry")
|
134
134
|
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
|
135
135
|
.with(key, access)
|
@@ -42,7 +42,7 @@ describe Chef::Provider::Execute do
|
|
42
42
|
|
43
43
|
before do
|
44
44
|
allow(Chef::EventDispatch::EventsOutputStream).to receive(:new) { @live_stream }
|
45
|
-
allow(
|
45
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
46
46
|
@original_log_level = Chef::Log.level
|
47
47
|
Chef::Log.level = :info
|
48
48
|
allow(STDOUT).to receive(:tty?).and_return(false)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
|
3
3
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-2018, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,7 +21,7 @@ require "ostruct"
|
|
21
21
|
|
22
22
|
require "spec_helper"
|
23
23
|
|
24
|
-
if
|
24
|
+
if ChefUtils.windows?
|
25
25
|
require "chef/win32/file" # probably need this in spec_helper
|
26
26
|
end
|
27
27
|
|
@@ -41,7 +41,7 @@ describe Chef::Resource::Link do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def canonicalize(path)
|
44
|
-
|
44
|
+
ChefUtils.windows? ? path.tr("/", '\\') : path
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "when the target is a symlink" do
|
@@ -359,7 +359,7 @@ describe Chef::Resource::Link do
|
|
359
359
|
provider.new_resource.name
|
360
360
|
).and_return(resource_link)
|
361
361
|
allow(resource_link).to receive(:verify_links_supported!)
|
362
|
-
allow(
|
362
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
363
363
|
end
|
364
364
|
|
365
365
|
context "soft links" do
|
@@ -389,7 +389,7 @@ describe Chef::Resource::Link do
|
|
389
389
|
|
390
390
|
context "on Linux platform" do
|
391
391
|
before(:each) do
|
392
|
-
allow(
|
392
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
393
393
|
end
|
394
394
|
|
395
395
|
context "soft links" do
|
@@ -120,7 +120,7 @@ describe Chef::Provider::Package::Openbsd do
|
|
120
120
|
describe "delete a package" do
|
121
121
|
before do
|
122
122
|
@name = "ihavetoes"
|
123
|
-
@new_resource
|
123
|
+
@new_resource = Chef::Resource::Package.new(@name)
|
124
124
|
@current_resource = Chef::Resource::Package.new(@name)
|
125
125
|
@provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context)
|
126
126
|
@provider.current_resource = @current_resource
|
@@ -25,7 +25,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
|
|
25
25
|
@node = Chef::Node.new
|
26
26
|
@events = Chef::EventDispatch::Dispatcher.new
|
27
27
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
28
|
-
@new_resource
|
28
|
+
@new_resource = Chef::Resource::Package.new("varnish")
|
29
29
|
@current_resource = Chef::Resource::Package.new("varnish")
|
30
30
|
|
31
31
|
@status = double("Status", exitstatus: 0)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright 2014-
|
3
|
+
# Copyright:: Copyright 2014-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi"
|
|
22
22
|
|
23
23
|
describe Chef::Provider::Package::Windows, :windows_only do
|
24
24
|
before(:each) do
|
25
|
-
allow(
|
25
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
26
26
|
allow(Chef::FileCache).to receive(:create_cache_path).with("package/").and_return(cache_path)
|
27
27
|
end
|
28
28
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -27,7 +27,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
|
|
27
27
|
describe "when passed a network share" do
|
28
28
|
before do
|
29
29
|
expect(Chef::Provider::RemoteFile::NetworkFile).to receive(:new).and_return(fetcher_instance)
|
30
|
-
allow(
|
30
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
31
31
|
end
|
32
32
|
|
33
33
|
context "when host is a name" do
|
@@ -31,7 +31,7 @@ describe Chef::Provider::RemoteFile::LocalFile do
|
|
31
31
|
context "when parsing source path on windows" do
|
32
32
|
|
33
33
|
before do
|
34
|
-
allow(
|
34
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "when given local unix path" do
|
@@ -33,7 +33,7 @@ describe Chef::Provider::RemoteFile::NetworkFile do
|
|
33
33
|
let(:source_file) { double("::File", read: nil) }
|
34
34
|
|
35
35
|
before do
|
36
|
-
allow(
|
36
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "stages the local file to a temporary file" do
|
@@ -59,7 +59,7 @@ describe Chef::Provider::Script, "action_run" do
|
|
59
59
|
context "when configuring the script file's security" do
|
60
60
|
context "when not running on Windows" do
|
61
61
|
before do
|
62
|
-
allow(
|
62
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
63
63
|
end
|
64
64
|
context "#set_owner_and_group" do
|
65
65
|
it "sets the owner and group for the script file" do
|
@@ -73,7 +73,7 @@ describe Chef::Provider::Script, "action_run" do
|
|
73
73
|
|
74
74
|
context "when running on Windows" do
|
75
75
|
before do
|
76
|
-
allow(
|
76
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
77
77
|
expect(new_resource.user).to eq(nil)
|
78
78
|
stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_READ", 1)
|
79
79
|
stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE", 4)
|
@@ -36,11 +36,11 @@ describe Chef::Provider::Service::Systemd do
|
|
36
36
|
let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
|
37
37
|
|
38
38
|
let(:shell_out_success) do
|
39
|
-
double("shell_out", exitstatus: 0, error?: false)
|
39
|
+
double("shell_out", exitstatus: 0, error?: false, stdout: "")
|
40
40
|
end
|
41
41
|
|
42
42
|
let(:shell_out_failure) do
|
43
|
-
double("shell_out", exitstatus: 1, error?: true)
|
43
|
+
double("shell_out", exitstatus: 1, error?: true, stdout: "")
|
44
44
|
end
|
45
45
|
|
46
46
|
let(:current_resource) { Chef::Resource::Service.new(service_name) }
|
@@ -56,6 +56,7 @@ describe Chef::Provider::Service::Systemd do
|
|
56
56
|
allow(provider).to receive(:is_active?).and_return(false)
|
57
57
|
allow(provider).to receive(:is_enabled?).and_return(false)
|
58
58
|
allow(provider).to receive(:is_masked?).and_return(false)
|
59
|
+
allow(provider).to receive(:is_indirect?).and_return(false)
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should create a current resource with the name of the new resource" do
|
@@ -359,6 +360,29 @@ describe Chef::Provider::Service::Systemd do
|
|
359
360
|
expect(provider.is_masked?).to be false
|
360
361
|
end
|
361
362
|
end
|
363
|
+
|
364
|
+
describe "is_indirect?" do
|
365
|
+
before(:each) do
|
366
|
+
provider.current_resource = current_resource
|
367
|
+
current_resource.service_name(service_name)
|
368
|
+
allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 'indirect'" do
|
372
|
+
expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "indirect", exitstatus: shell_out_success))
|
373
|
+
expect(provider.is_indirect?).to be true
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns 0 and outputs something other than 'indirect'" do
|
377
|
+
expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_success))
|
378
|
+
expect(provider.is_indirect?).to be false
|
379
|
+
end
|
380
|
+
|
381
|
+
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns anything except 0 and outputs somethign other than 'indirect''" do
|
382
|
+
expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_failure))
|
383
|
+
expect(provider.is_indirect?).to be false
|
384
|
+
end
|
385
|
+
end
|
362
386
|
end
|
363
387
|
end
|
364
388
|
end
|