chef 13.2.20-universal-mingw32 → 13.3.42-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/CONTRIBUTING.md +1 -1
- data/Gemfile +2 -8
- data/README.md +6 -2
- data/Rakefile +0 -11
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +1 -1
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +34 -18
- data/acceptance/data-collector/.acceptance/data-collector-test/recipes/default.rb +6 -0
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/deprecation/warnings.rb +3 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/http.rb +9 -10
- data/lib/chef/http/api_versions.rb +2 -0
- data/lib/chef/http/http_request.rb +3 -0
- data/lib/chef/knife/core/bootstrap_context.rb +1 -0
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +4 -0
- data/lib/chef/provider/apt_preference.rb +99 -0
- data/lib/chef/provider/execute.rb +3 -2
- data/lib/chef/provider/http_request.rb +14 -0
- data/lib/chef/provider/mount/aix.rb +49 -8
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +5 -5
- data/lib/chef/provider/service/systemd.rb +12 -11
- data/lib/chef/provider/support/zypper_repo.erb +17 -0
- data/lib/chef/provider/systemd_unit.rb +3 -2
- data/lib/chef/provider/windows_task.rb +92 -71
- data/lib/chef/provider/zypper_repository.rb +81 -0
- data/lib/chef/providers.rb +2 -0
- data/lib/chef/resource/apt_preference.rb +36 -0
- data/lib/chef/resource/execute.rb +12 -2
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/zypper_repository.rb +51 -0
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/search/query.rb +6 -1
- data/lib/chef/server_api_versions.rb +21 -2
- data/lib/chef/version.rb +3 -4
- data/lib/chef/win32/api/file.rb +1 -0
- data/lib/chef/win32/file.rb +2 -0
- data/lib/chef/win32/version.rb +6 -0
- data/spec/functional/knife/ssh_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/http/api_versions_spec.rb +6 -3
- data/spec/unit/knife/bootstrap_spec.rb +4 -0
- data/spec/unit/knife/cookbook_show_spec.rb +3 -3
- data/spec/unit/knife/ssh_spec.rb +7 -1
- data/spec/unit/knife/status_spec.rb +2 -0
- data/spec/unit/provider/apt_preference_spec.rb +87 -0
- data/spec/unit/provider/apt_update_spec.rb +7 -7
- data/spec/unit/provider/dsc_resource_spec.rb +2 -2
- data/spec/unit/provider/execute_spec.rb +32 -14
- data/spec/unit/provider/mount/aix_spec.rb +33 -1
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +56 -3
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/zypper_spec.rb +43 -0
- data/spec/unit/provider/script_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +23 -21
- data/spec/unit/provider/systemd_unit_spec.rb +42 -41
- data/spec/unit/provider/windows_task_spec.rb +40 -0
- data/spec/unit/resource/apt_preference_spec.rb +41 -0
- data/spec/unit/resource/execute_spec.rb +21 -1
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/zypper_repository_spec.rb +65 -0
- data/spec/unit/search/query_spec.rb +13 -18
- data/spec/unit/server_api_spec.rb +75 -1
- data/spec/unit/server_api_versions_spec.rb +22 -0
- data/spec/unit/win32/link_spec.rb +73 -0
- data/tasks/dependencies.rb +0 -1
- metadata +14 -81
- data/acceptance/.bundle/config +0 -2
- data/acceptance/bin/aws.rb +0 -17
- data/acceptance/bin/berks +0 -17
- data/acceptance/bin/bundler +0 -17
- data/acceptance/bin/chef-acceptance +0 -17
- data/acceptance/bin/coderay +0 -17
- data/acceptance/bin/erubis +0 -17
- data/acceptance/bin/htmldiff +0 -17
- data/acceptance/bin/httpclient +0 -17
- data/acceptance/bin/inspec +0 -17
- data/acceptance/bin/kitchen +0 -17
- data/acceptance/bin/ldiff +0 -17
- data/acceptance/bin/nokogiri +0 -17
- data/acceptance/bin/pry +0 -17
- data/acceptance/bin/rake +0 -17
- data/acceptance/bin/rspec +0 -17
- data/acceptance/bin/rwinrm +0 -17
- data/acceptance/bin/rwinrmcp +0 -17
- data/acceptance/bin/safe_yaml +0 -17
- data/acceptance/bin/thor +0 -17
- data/acceptance/fips/.kitchen/fips-unit-functional-centos-6.yml +0 -7
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/id +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/Vagrantfile +0 -11
- data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -0
- data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -0
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -80
- data/acceptance/fips/.kitchen/logs/kitchen.log +0 -4
- data/tasks/changelog.rb +0 -37
- data/tasks/version.rb +0 -41
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright 2017, Chef Software
|
2
|
+
# Copyright:: Copyright 2017-2017, Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -27,7 +27,7 @@ describe Chef::HTTP::APIVersions do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
let(:method) { "GET" }
|
30
|
-
let(:url) { "http://
|
30
|
+
let(:url) { "http://localhost:60123" }
|
31
31
|
let(:headers) { {} }
|
32
32
|
let(:data) { false }
|
33
33
|
|
@@ -53,8 +53,11 @@ describe Chef::HTTP::APIVersions do
|
|
53
53
|
m
|
54
54
|
end
|
55
55
|
|
56
|
+
let(:client) do
|
57
|
+
TestVersionClient.new(url, { version_class: VersionedClassVersions })
|
58
|
+
end
|
59
|
+
|
56
60
|
let(:middleware) do
|
57
|
-
client = TestVersionClient.new(url)
|
58
61
|
client.middlewares[0]
|
59
62
|
end
|
60
63
|
|
@@ -586,6 +586,10 @@ describe Chef::Knife::Bootstrap do
|
|
586
586
|
expect(knife.bootstrap_context.first_boot).to have_key(:policy_group)
|
587
587
|
end
|
588
588
|
|
589
|
+
it "ensures that run_list is not set in the bootstrap context" do
|
590
|
+
expect(knife.bootstrap_context.first_boot).to_not have_key(:run_list)
|
591
|
+
end
|
592
|
+
|
589
593
|
end
|
590
594
|
|
591
595
|
# https://github.com/chef/chef/issues/4131
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2017, Chef Software Inc.
|
4
4
|
# License:: Apache License, eersion 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -110,8 +110,8 @@ describe Chef::Knife::CookbookShow do
|
|
110
110
|
"name" => nil,
|
111
111
|
"description" => "",
|
112
112
|
"long_description" => "",
|
113
|
-
"maintainer" =>
|
114
|
-
"maintainer_email" =>
|
113
|
+
"maintainer" => "",
|
114
|
+
"maintainer_email" => "",
|
115
115
|
"license" => "All rights reserved",
|
116
116
|
"platforms" => {},
|
117
117
|
"dependencies" => {},
|
data/spec/unit/knife/ssh_spec.rb
CHANGED
@@ -187,7 +187,7 @@ describe Chef::Knife::Ssh do
|
|
187
187
|
describe "#session_from_list" do
|
188
188
|
before :each do
|
189
189
|
@knife.instance_variable_set(:@longest, 0)
|
190
|
-
ssh_config = { :timeout => 50, :user => "locutus", :port => 23 }
|
190
|
+
ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 }
|
191
191
|
allow(Net::SSH).to receive(:configuration_for).with("the.b.org", true).and_return(ssh_config)
|
192
192
|
end
|
193
193
|
|
@@ -223,6 +223,12 @@ describe Chef::Knife::Ssh do
|
|
223
223
|
@knife.session_from_list([["the.b.org", 123]])
|
224
224
|
expect(@knife.session.servers[0].user).to eq("locutus")
|
225
225
|
end
|
226
|
+
|
227
|
+
it "uses keepalive settings from an ssh config file" do
|
228
|
+
@knife.session_from_list([["the.b.org", 123]])
|
229
|
+
expect(@knife.session.servers[0].options[:keepalive]).to be true
|
230
|
+
expect(@knife.session.servers[0].options[:keepalive_interval]).to eq 60
|
231
|
+
end
|
226
232
|
end
|
227
233
|
|
228
234
|
describe "#ssh_command" do
|
@@ -23,6 +23,8 @@ describe Chef::Knife::Status do
|
|
23
23
|
node = Chef::Node.new.tap do |n|
|
24
24
|
n.automatic_attrs["fqdn"] = "foobar"
|
25
25
|
n.automatic_attrs["ohai_time"] = 1343845969
|
26
|
+
n.automatic_attrs["platform"] = "mac_os_x"
|
27
|
+
n.automatic_attrs["platform_version"] = "10.12.5"
|
26
28
|
end
|
27
29
|
allow(Time).to receive(:now).and_return(Time.at(1428573420))
|
28
30
|
@query = double("Chef::Search::Query")
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Thom May (<thom@chef.io>)
|
3
|
+
# Author:: Tim Smith (<tim@chef.io>)
|
4
|
+
# Copyright:: 2016-2017, Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require "spec_helper"
|
21
|
+
|
22
|
+
describe Chef::Provider::AptPreference do
|
23
|
+
let(:new_resource) { Chef::Resource::AptPreference.new("libmysqlclient16.1*") }
|
24
|
+
let(:pref_dir) { Dir.mktmpdir("apt_pref_d") }
|
25
|
+
|
26
|
+
before do
|
27
|
+
stub_const("Chef::Provider::AptPreference::APT_PREFERENCE_DIR", pref_dir)
|
28
|
+
new_resource.pin = "1.0.1"
|
29
|
+
new_resource.pin_priority 1001
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:provider) do
|
33
|
+
node = Chef::Node.new
|
34
|
+
events = Chef::EventDispatch::Dispatcher.new
|
35
|
+
run_context = Chef::RunContext.new(node, {}, events)
|
36
|
+
Chef::Provider::AptPreference.new(new_resource, run_context)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "responds to load_current_resource" do
|
40
|
+
expect(provider).to respond_to(:load_current_resource)
|
41
|
+
end
|
42
|
+
|
43
|
+
context "#action_add" do
|
44
|
+
context "without a preferences.d directory" do
|
45
|
+
before do
|
46
|
+
FileUtils.rmdir pref_dir
|
47
|
+
end
|
48
|
+
|
49
|
+
it "creates the preferences.d directory" do
|
50
|
+
provider.run_action(:add)
|
51
|
+
expect(new_resource).to be_updated_by_last_action
|
52
|
+
expect(File.exist?(pref_dir)).to be true
|
53
|
+
expect(File.directory?(pref_dir)).to be true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "with a preferences.d directory" do
|
58
|
+
before do
|
59
|
+
FileUtils.mkdir pref_dir unless ::File.exist?(pref_dir)
|
60
|
+
FileUtils.touch("#{pref_dir}/libmysqlclient16.1*.pref")
|
61
|
+
FileUtils.touch("#{pref_dir}/libmysqlclient16.1*")
|
62
|
+
end
|
63
|
+
|
64
|
+
# FileUtils.touch throws "Invalid argument @ utime_failed" in appveyer
|
65
|
+
it "creates a sanitized .pref file and removes the legacy cookbook files", :unix_only do
|
66
|
+
provider.run_action(:add)
|
67
|
+
expect(new_resource).to be_updated_by_last_action
|
68
|
+
expect(File).not_to exist("#{pref_dir}/libmysqlclient16.1*.pref")
|
69
|
+
expect(File).not_to exist("#{pref_dir}/libmysqlclient16.1*")
|
70
|
+
expect(File.read(::File.join(pref_dir, "libmysqlclient16_1wildcard.pref"))).to match(/Package: libmysqlclient16.1*.*Pin: 1.0.1.*Pin-Priority: 1001/m)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "#action_delete" do
|
76
|
+
before do
|
77
|
+
FileUtils.mkdir pref_dir unless ::File.exist?(pref_dir)
|
78
|
+
FileUtils.touch("#{pref_dir}/libmysqlclient16_1wildcard.pref")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "deletes the name santized .pref file" do
|
82
|
+
provider.run_action(:remove)
|
83
|
+
expect(new_resource).to be_updated_by_last_action
|
84
|
+
expect(File).not_to exist("#{pref_dir}/libmysqlclient16_1wildcard.pref")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Thom May (<thom@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2016 Chef Software
|
3
|
+
# Copyright:: Copyright (c) 2016-2017, 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");
|
@@ -45,7 +45,7 @@ describe Chef::Provider::AptUpdate do
|
|
45
45
|
before do
|
46
46
|
FileUtils.rmdir config_dir
|
47
47
|
expect(File.exist?(config_dir)).to be false
|
48
|
-
allow_any_instance_of(Chef::Provider::Execute).to receive(:
|
48
|
+
allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should create the directory" do
|
@@ -64,7 +64,7 @@ describe Chef::Provider::AptUpdate do
|
|
64
64
|
describe "#action_update" do
|
65
65
|
it "should update the apt cache" do
|
66
66
|
provider.load_current_resource
|
67
|
-
expect_any_instance_of(Chef::Provider::Execute).to receive(:
|
67
|
+
expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
68
68
|
provider.run_action(:update)
|
69
69
|
expect(new_resource).to be_updated_by_last_action
|
70
70
|
end
|
@@ -79,14 +79,14 @@ describe Chef::Provider::AptUpdate do
|
|
79
79
|
|
80
80
|
it "should run if the time stamp is old" do
|
81
81
|
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 86_500)
|
82
|
-
expect_any_instance_of(Chef::Provider::Execute).to receive(:
|
82
|
+
expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
83
83
|
provider.run_action(:periodic)
|
84
84
|
expect(new_resource).to be_updated_by_last_action
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should not run if the time stamp is new" do
|
88
88
|
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now)
|
89
|
-
expect_any_instance_of(Chef::Provider::Execute).not_to receive(:
|
89
|
+
expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
90
90
|
provider.run_action(:periodic)
|
91
91
|
expect(new_resource).to_not be_updated_by_last_action
|
92
92
|
end
|
@@ -98,14 +98,14 @@ describe Chef::Provider::AptUpdate do
|
|
98
98
|
|
99
99
|
it "should run if the time stamp is old" do
|
100
100
|
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 500)
|
101
|
-
expect_any_instance_of(Chef::Provider::Execute).to receive(:
|
101
|
+
expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
102
102
|
provider.run_action(:periodic)
|
103
103
|
expect(new_resource).to be_updated_by_last_action
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should not run if the time stamp is new" do
|
107
107
|
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 300)
|
108
|
-
expect_any_instance_of(Chef::Provider::Execute).not_to receive(:
|
108
|
+
expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_with_systems_locale!).with("apt-get -q update", anything())
|
109
109
|
provider.run_action(:periodic)
|
110
110
|
expect(new_resource).to_not be_updated_by_last_action
|
111
111
|
end
|
@@ -155,8 +155,8 @@ describe Chef::Provider::DscResource do
|
|
155
155
|
context "multiple resource are found" do
|
156
156
|
let (:resource_records) do
|
157
157
|
[
|
158
|
-
{ "Module" => { "Name" => "ModuleName1" } },
|
159
|
-
{ "Module" => { "Name" => "
|
158
|
+
{ "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
|
159
|
+
{ "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
|
160
160
|
] end
|
161
161
|
|
162
162
|
it "raises MultipleDscResourcesFound" do
|
@@ -76,16 +76,34 @@ describe Chef::Provider::Execute do
|
|
76
76
|
|
77
77
|
describe "#action_run" do
|
78
78
|
it "runs shell_out with the default options" do
|
79
|
-
expect(provider).to receive(:
|
79
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
80
80
|
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
81
81
|
expect(Chef::Log).not_to receive(:warn)
|
82
82
|
provider.run_action(:run)
|
83
83
|
expect(new_resource).to be_updated
|
84
84
|
end
|
85
85
|
|
86
|
+
# this next test is tightly coupled to the implementation of the underlying shell_out mixin that we're using
|
87
|
+
# but the point is to ensure that we are not picking up the PATH mangling and locale-variable mangling that the internal
|
88
|
+
# shell_out API uses. we are asserting that we emulate `ls -la` when the user does `execute "ls -la"`, and to
|
89
|
+
# do that we get dirty and start mocking the implementation of the shell_out mixin itself. while arguments like
|
90
|
+
# "timeout", "returns", "log_level" and "log_tag" appear here, we MUST NOT have an "environment" or "env" argument
|
91
|
+
# that we are passing to Mixlib::ShellOut by default -- ever. you might have to add some other argument here from
|
92
|
+
# time to time, but you MUST NOT change the environment.
|
93
|
+
it "does not use shell_out in such a way as to insert extra environment variables" do
|
94
|
+
mock = instance_double(Mixlib::ShellOut)
|
95
|
+
expect(Mixlib::ShellOut).to receive(:new).with("foo_resource", { timeout: 3600, returns: 0, log_level: :info, log_tag: "execute[foo_resource]" }).and_return(mock)
|
96
|
+
expect(mock).to receive(:live_stream=).with(nil)
|
97
|
+
allow(mock).to receive(:live_stream)
|
98
|
+
expect(mock).to receive(:run_command)
|
99
|
+
expect(mock).to receive(:error!)
|
100
|
+
provider.run_action(:run)
|
101
|
+
expect(new_resource).to be_updated
|
102
|
+
end
|
103
|
+
|
86
104
|
it "if you pass a command attribute, it runs the command" do
|
87
105
|
new_resource.command "/usr/argelbargle/bin/oogachacka 12345"
|
88
|
-
expect(provider).to receive(:
|
106
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.command, opts)
|
89
107
|
expect(provider).to receive(:converge_by).with("execute #{new_resource.command}").and_call_original
|
90
108
|
expect(Chef::Log).not_to receive(:warn)
|
91
109
|
provider.run_action(:run)
|
@@ -96,7 +114,7 @@ describe Chef::Provider::Execute do
|
|
96
114
|
new_resource.sensitive true
|
97
115
|
# Since the resource is sensitive, it should not have :live_stream set
|
98
116
|
opts.delete(:live_stream)
|
99
|
-
expect(provider).to receive(:
|
117
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
100
118
|
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
101
119
|
expect(Chef::Log).not_to receive(:warn)
|
102
120
|
provider.run_action(:run)
|
@@ -106,7 +124,7 @@ describe Chef::Provider::Execute do
|
|
106
124
|
it "should do nothing if the sentinel file exists" do
|
107
125
|
new_resource.creates "/foo_resource"
|
108
126
|
expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
|
109
|
-
expect(provider).not_to receive(:
|
127
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
110
128
|
expect(Chef::Log).not_to receive(:warn)
|
111
129
|
provider.run_action(:run)
|
112
130
|
expect(new_resource).not_to be_updated
|
@@ -119,7 +137,7 @@ describe Chef::Provider::Execute do
|
|
119
137
|
end
|
120
138
|
|
121
139
|
it "should raise if user specified relative path without cwd for Chef-13" do
|
122
|
-
expect(provider).not_to receive(:
|
140
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
123
141
|
expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::Execute)
|
124
142
|
end
|
125
143
|
end
|
@@ -130,7 +148,7 @@ describe Chef::Provider::Execute do
|
|
130
148
|
expect(FileTest).not_to receive(:exist?).with(new_resource.creates)
|
131
149
|
expect(FileTest).to receive(:exist?).with(File.join("/tmp", new_resource.creates)).and_return(true)
|
132
150
|
expect(Chef::Log).not_to receive(:warn)
|
133
|
-
expect(provider).not_to receive(:
|
151
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
134
152
|
|
135
153
|
provider.run_action(:run)
|
136
154
|
expect(new_resource).not_to be_updated
|
@@ -139,7 +157,7 @@ describe Chef::Provider::Execute do
|
|
139
157
|
it "should not include stdout/stderr in failure exception for sensitive resource" do
|
140
158
|
opts.delete(:live_stream)
|
141
159
|
new_resource.sensitive true
|
142
|
-
expect(provider).to receive(:
|
160
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
143
161
|
expect do
|
144
162
|
provider.run_action(:run)
|
145
163
|
end.to raise_error(Mixlib::ShellOut::ShellCommandFailed, /suppressed for sensitive resource/)
|
@@ -148,7 +166,7 @@ describe Chef::Provider::Execute do
|
|
148
166
|
describe "streaming output" do
|
149
167
|
it "should not set the live_stream if sensitive is on" do
|
150
168
|
new_resource.sensitive true
|
151
|
-
expect(provider).to receive(:
|
169
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
152
170
|
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
153
171
|
expect(Chef::Log).not_to receive(:warn)
|
154
172
|
provider.run_action(:run)
|
@@ -165,7 +183,7 @@ describe Chef::Provider::Execute do
|
|
165
183
|
it "should set the live_stream if the log level is info or above" do
|
166
184
|
nopts = opts
|
167
185
|
nopts[:live_stream] = @live_stream
|
168
|
-
expect(provider).to receive(:
|
186
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
|
169
187
|
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
170
188
|
expect(Chef::Log).not_to receive(:warn)
|
171
189
|
provider.run_action(:run)
|
@@ -177,7 +195,7 @@ describe Chef::Provider::Execute do
|
|
177
195
|
new_resource.live_stream true
|
178
196
|
nopts = opts
|
179
197
|
nopts[:live_stream] = @live_stream
|
180
|
-
expect(provider).to receive(:
|
198
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
|
181
199
|
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
182
200
|
expect(Chef::Log).not_to receive(:warn)
|
183
201
|
provider.run_action(:run)
|
@@ -186,7 +204,7 @@ describe Chef::Provider::Execute do
|
|
186
204
|
|
187
205
|
it "should not set the live_stream if the resource is sensitive" do
|
188
206
|
new_resource.sensitive true
|
189
|
-
expect(provider).to receive(:
|
207
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
190
208
|
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
191
209
|
expect(Chef::Log).not_to receive(:warn)
|
192
210
|
provider.run_action(:run)
|
@@ -199,7 +217,7 @@ describe Chef::Provider::Execute do
|
|
199
217
|
nopts = opts
|
200
218
|
nopts[:live_stream] = STDOUT
|
201
219
|
allow(STDOUT).to receive(:tty?).and_return(true)
|
202
|
-
expect(provider).to receive(:
|
220
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, nopts)
|
203
221
|
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
204
222
|
expect(Chef::Log).not_to receive(:warn)
|
205
223
|
provider.run_action(:run)
|
@@ -209,7 +227,7 @@ describe Chef::Provider::Execute do
|
|
209
227
|
it "should not set the live_stream to STDOUT if we are a TTY, not daemonized, but sensitive" do
|
210
228
|
new_resource.sensitive true
|
211
229
|
allow(STDOUT).to receive(:tty?).and_return(true)
|
212
|
-
expect(provider).to receive(:
|
230
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
213
231
|
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
214
232
|
expect(Chef::Log).not_to receive(:warn)
|
215
233
|
provider.run_action(:run)
|
@@ -219,7 +237,7 @@ describe Chef::Provider::Execute do
|
|
219
237
|
it "should not set the live_stream to STDOUT if we are a TTY, but daemonized" do
|
220
238
|
Chef::Config[:daemon] = true
|
221
239
|
allow(STDOUT).to receive(:tty?).and_return(true)
|
222
|
-
expect(provider).to receive(:
|
240
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with(new_resource.name, opts)
|
223
241
|
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
224
242
|
expect(Chef::Log).not_to receive(:warn)
|
225
243
|
provider.run_action(:run)
|
@@ -44,6 +44,11 @@ MOUNT
|
|
44
44
|
#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
|
45
45
|
/tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no
|
46
46
|
ENABLED
|
47
|
+
|
48
|
+
@test_wrong_output = <<-WRONG
|
49
|
+
#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
|
50
|
+
/tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no
|
51
|
+
WRONG
|
47
52
|
end
|
48
53
|
|
49
54
|
before(:each) do
|
@@ -102,6 +107,25 @@ ENABLED
|
|
102
107
|
|
103
108
|
expect(@provider.current_resource.mounted).to be_falsey
|
104
109
|
end
|
110
|
+
|
111
|
+
context "mount_options_unchanged?" do
|
112
|
+
it "should return true if mounted device is the same" do
|
113
|
+
stub_mounted_enabled(@provider, @mounted_output, @enabled_output)
|
114
|
+
@provider.load_current_resource
|
115
|
+
|
116
|
+
allow(@provider.current_resource).to receive(:fstype).and_return("jfs2")
|
117
|
+
expect(@provider.send :mount_options_unchanged?).to be true
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return false if mounted device has changed" do
|
121
|
+
stub_mounted_enabled(@provider, @mounted_output, @enabled_output)
|
122
|
+
@provider.load_current_resource
|
123
|
+
|
124
|
+
allow(@provider.current_resource).to receive(:fstype).and_return("XXXX")
|
125
|
+
expect(@provider.send :mount_options_unchanged?).to be false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
105
129
|
end
|
106
130
|
|
107
131
|
# tests for #enabled?
|
@@ -188,12 +212,20 @@ ENABLED
|
|
188
212
|
|
189
213
|
it "should not enable mount if it is mounted and already enabled and mount options are unchanged" do
|
190
214
|
stub_mounted_enabled(@provider, @mounted_output, @enabled_output)
|
191
|
-
@new_resource.options "rw"
|
192
215
|
|
193
216
|
expect(@provider).not_to receive(:enable_fs)
|
194
217
|
|
195
218
|
@provider.run_action(:enable)
|
196
219
|
end
|
220
|
+
|
221
|
+
it "should return false if enabled_output is given in wrong syntax" do
|
222
|
+
stub_mounted_enabled(@provider, @mounted_output, @test_wrong_output)
|
223
|
+
|
224
|
+
expect(@provider).to receive(:enable_fs)
|
225
|
+
|
226
|
+
@provider.run_action(:enable)
|
227
|
+
end
|
228
|
+
|
197
229
|
end
|
198
230
|
|
199
231
|
describe "disable_fs" do
|