chef 17.8.25-universal-mingw32 → 17.9.46-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/lib/chef/application/exit_code.rb +7 -21
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/compliance/input_collection.rb +1 -1
- data/lib/chef/compliance/waiver_collection.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +2 -2
- data/lib/chef/provider/ifconfig.rb +5 -5
- data/lib/chef/provider/package/yum/python_helper.rb +81 -25
- data/lib/chef/provider/package/yum.rb +39 -12
- data/lib/chef/provider/package.rb +5 -5
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider.rb +4 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource/apt_package.rb +2 -2
- data/lib/chef/resource/archive_file.rb +6 -6
- data/lib/chef/resource/chef_client_config.rb +2 -3
- data/lib/chef/resource/chocolatey_package.rb +3 -3
- data/lib/chef/resource/cron/cron.rb +75 -1
- data/lib/chef/resource/cron/cron_d.rb +2 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +1 -1
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +1 -5
- data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
- data/lib/chef/resource/launchd.rb +2 -2
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +8 -8
- data/lib/chef/resource/remote_file.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +3 -3
- data/lib/chef/resource/windows_feature_powershell.rb +1 -2
- data/lib/chef/resource/windows_task.rb +25 -10
- data/lib/chef/resource.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/secret_fetcher/azure_key_vault.rb +4 -2
- data/lib/chef/secret_fetcher/hashi_vault.rb +37 -3
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/archive_file_spec.rb +3 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +107 -107
- data/spec/functional/resource/dsc_script_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/resource/yum_package_spec.rb +789 -129
- data/spec/integration/client/client_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -5
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +2 -2
- data/spec/support/shared/functional/http.rb +9 -9
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +1 -1
- data/spec/unit/dsl/registry_helper_spec.rb +6 -6
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +2 -2
- data/spec/unit/provider/dsc_script_spec.rb +8 -8
- data/spec/unit/provider/group/usermod_spec.rb +2 -2
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +1 -1
- data/spec/unit/provider/ifconfig/redhat_spec.rb +1 -1
- data/spec/unit/provider/ifconfig_spec.rb +3 -3
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider/user/solaris_spec.rb +1 -1
- data/spec/unit/resource/archive_file_spec.rb +1 -2
- data/spec/unit/resource/conditional_spec.rb +4 -4
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/secret_fetcher/hashi_vault_spec.rb +46 -0
- metadata +6 -8
- data/lib/chef/provider/group/suse.rb +0 -82
- data/spec/unit/provider/group/suse_spec.rb +0 -90
data/spec/spec_helper.rb
CHANGED
@@ -78,9 +78,9 @@ require "spec/support/recipe_dsl_helper"
|
|
78
78
|
# Excludes support/platforms by default
|
79
79
|
# Do not change the gsub.
|
80
80
|
Dir["spec/support/**/*.rb"]
|
81
|
-
.
|
82
|
-
.
|
83
|
-
.
|
81
|
+
.grep_v(%r{^spec/support/platforms})
|
82
|
+
.grep_v(%r{^spec/support/pedant})
|
83
|
+
.grep_v(%r{^spec/support/shared/integration/knife_support})
|
84
84
|
.map { |f| f.gsub(/.rb$/, "") }
|
85
85
|
.map { |f| f.gsub(%r{spec/}, "") }
|
86
86
|
.each { |f| require f }
|
@@ -187,8 +187,6 @@ RSpec.configure do |config|
|
|
187
187
|
config.filter_run_excluding not_rhel7: true if rhel7?
|
188
188
|
config.filter_run_excluding not_intel_64bit: true if intel_64bit?
|
189
189
|
|
190
|
-
config.filter_run_excluding libarchive_loading_broken: true if aix? || amazon_linux? || rhel7?
|
191
|
-
|
192
190
|
# these let us use chef: ">= 13" or ruby: "~> 2.0.0" or any other Gem::Dependency-style constraint
|
193
191
|
config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION)
|
194
192
|
config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION)
|
@@ -48,4 +48,4 @@ rescue LoadError
|
|
48
48
|
$stderr.puts "Failed to load ruby_installer. Assuming Ruby Installer is not being used."
|
49
49
|
end
|
50
50
|
|
51
|
-
add_libarchive_dll_directory if RUBY_PLATFORM
|
51
|
+
add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
@@ -157,7 +157,7 @@ shared_examples_for "a file with the wrong content" do
|
|
157
157
|
|
158
158
|
context "when running :create action" do
|
159
159
|
let(:provider) { resource.provider_for_action(:create) }
|
160
|
-
let(:reporter_messages) { provider.instance_variable_get(
|
160
|
+
let(:reporter_messages) { provider.instance_variable_get(:@converge_actions).actions[0][0] }
|
161
161
|
|
162
162
|
before do
|
163
163
|
provider.run_action
|
@@ -391,7 +391,7 @@ shared_examples_for "a configured file resource" do
|
|
391
391
|
end
|
392
392
|
|
393
393
|
def binread(file)
|
394
|
-
content = File.
|
394
|
+
content = File.binread(file)
|
395
395
|
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
|
396
396
|
content
|
397
397
|
end
|
@@ -30,7 +30,7 @@ module ChefHTTPShared
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def binread(file)
|
33
|
-
content = File.
|
33
|
+
content = File.binread(file)
|
34
34
|
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
|
35
35
|
content
|
36
36
|
end
|
@@ -51,19 +51,19 @@ module ChefHTTPShared
|
|
51
51
|
# just a normal file
|
52
52
|
# (expected_content should be uncompressed)
|
53
53
|
@api.get("/nyan_cat.png", 200) do
|
54
|
-
File.
|
54
|
+
File.binread(nyan_uncompressed_filename)
|
55
55
|
end
|
56
56
|
|
57
57
|
# this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
|
58
58
|
# (expected_content should be compressed)
|
59
59
|
@api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
|
60
|
-
File.
|
60
|
+
File.binread(nyan_compressed_filename)
|
61
61
|
end
|
62
62
|
|
63
63
|
# this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
|
64
64
|
# (expected_content should be uncompressed)
|
65
65
|
@api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
|
66
|
-
File.
|
66
|
+
File.binread(nyan_compressed_filename)
|
67
67
|
end
|
68
68
|
|
69
69
|
#
|
@@ -75,7 +75,7 @@ module ChefHTTPShared
|
|
75
75
|
{
|
76
76
|
"Content-Length" => nyan_uncompressed_size.to_s,
|
77
77
|
}) do
|
78
|
-
File.
|
78
|
+
File.binread(nyan_uncompressed_filename)
|
79
79
|
end
|
80
80
|
|
81
81
|
# (expected_content should be uncompressed)
|
@@ -85,7 +85,7 @@ module ChefHTTPShared
|
|
85
85
|
"Content-Type" => "application/gzip",
|
86
86
|
"Content-Encoding" => "gzip",
|
87
87
|
}) do
|
88
|
-
File.
|
88
|
+
File.binread(nyan_compressed_filename)
|
89
89
|
end
|
90
90
|
|
91
91
|
#
|
@@ -97,7 +97,7 @@ module ChefHTTPShared
|
|
97
97
|
{
|
98
98
|
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
|
99
99
|
}) do
|
100
|
-
File.
|
100
|
+
File.binread(nyan_uncompressed_filename)
|
101
101
|
end
|
102
102
|
|
103
103
|
# (expected_content should be uncompressed)
|
@@ -107,7 +107,7 @@ module ChefHTTPShared
|
|
107
107
|
"Content-Type" => "application/gzip",
|
108
108
|
"Content-Encoding" => "gzip",
|
109
109
|
}) do
|
110
|
-
File.
|
110
|
+
File.binread(nyan_compressed_filename)
|
111
111
|
end
|
112
112
|
|
113
113
|
#
|
@@ -120,7 +120,7 @@ module ChefHTTPShared
|
|
120
120
|
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
|
121
121
|
"Transfer-Encoding" => "anything",
|
122
122
|
}) do
|
123
|
-
File.
|
123
|
+
File.binread(nyan_uncompressed_filename)
|
124
124
|
end
|
125
125
|
|
126
126
|
#
|
@@ -169,7 +169,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
|
|
169
169
|
before do
|
170
170
|
provider.new_resource.system true
|
171
171
|
# there is no public API to set attribute's value to nil
|
172
|
-
provider.new_resource.instance_variable_set(
|
172
|
+
provider.new_resource.instance_variable_set(:@home, nil)
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should not include -m or -d in the command options" do
|
@@ -31,22 +31,22 @@ describe Chef::Resource::RegistryKey do
|
|
31
31
|
|
32
32
|
context "tests registry dsl" do
|
33
33
|
it "resource can access registry_helper method registry_key_exists" do
|
34
|
-
expect(@resource.respond_to?(
|
34
|
+
expect(@resource.respond_to?(:registry_key_exists?)).to eq(true)
|
35
35
|
end
|
36
36
|
it "resource can access registry_helper method registry_get_values" do
|
37
|
-
expect(@resource.respond_to?(
|
37
|
+
expect(@resource.respond_to?(:registry_get_values)).to eq(true)
|
38
38
|
end
|
39
39
|
it "resource can access registry_helper method registry_has_subkey" do
|
40
|
-
expect(@resource.respond_to?(
|
40
|
+
expect(@resource.respond_to?(:registry_has_subkeys?)).to eq(true)
|
41
41
|
end
|
42
42
|
it "resource can access registry_helper method registry_get_subkeys" do
|
43
|
-
expect(@resource.respond_to?(
|
43
|
+
expect(@resource.respond_to?(:registry_get_subkeys)).to eq(true)
|
44
44
|
end
|
45
45
|
it "resource can access registry_helper method registry_value_exists" do
|
46
|
-
expect(@resource.respond_to?(
|
46
|
+
expect(@resource.respond_to?(:registry_value_exists?)).to eq(true)
|
47
47
|
end
|
48
48
|
it "resource can access registry_helper method data_value_exists" do
|
49
|
-
expect(@resource.respond_to?(
|
49
|
+
expect(@resource.respond_to?(:registry_data_exists?)).to eq(true)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -94,7 +94,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
|
|
94
94
|
|
95
95
|
describe "script command opts switch" do
|
96
96
|
let(:guard_interpreter) { Chef::GuardInterpreter::ResourceGuardInterpreter.new(parent_resource, "exit 0", {}) }
|
97
|
-
let(:resource) { guard_interpreter.instance_variable_get(
|
97
|
+
let(:resource) { guard_interpreter.instance_variable_get(:@resource) }
|
98
98
|
|
99
99
|
context "resource is a Script" do
|
100
100
|
context "and guard_interpreter is a :script" do
|
data/spec/unit/lwrp_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe "LWRP" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should not skip loading a resource when there's a top level symbol of the same name" do
|
57
|
-
Object.const_set(
|
57
|
+
Object.const_set(:LwrpFoo, Class.new)
|
58
58
|
file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA)
|
59
59
|
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
|
60
60
|
expect(Chef::Log).not_to receive(:trace).with(/anymore/)
|
@@ -63,7 +63,7 @@ describe "LWRP" do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should not skip loading a provider when there's a top level symbol of the same name" do
|
66
|
-
Object.const_set(
|
66
|
+
Object.const_set(:LwrpBuckPasser, Class.new)
|
67
67
|
file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA)
|
68
68
|
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
|
69
69
|
expect(Chef::Log).not_to receive(:trace).with(/anymore/)
|
@@ -39,21 +39,21 @@ describe Chef::Provider::DscScript do
|
|
39
39
|
it "describes the resource as converged if there were 0 DSC resources" do
|
40
40
|
allow(provider).to receive(:run_configuration).with(:test).and_return([])
|
41
41
|
provider.load_current_resource
|
42
|
-
expect(provider.instance_variable_get(
|
42
|
+
expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
|
43
43
|
end
|
44
44
|
|
45
45
|
it "describes the resource as not converged if there is 1 DSC resources that is converged" do
|
46
46
|
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
|
47
47
|
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
|
48
48
|
provider.load_current_resource
|
49
|
-
expect(provider.instance_variable_get(
|
49
|
+
expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
|
50
50
|
end
|
51
51
|
|
52
52
|
it "describes the resource as not converged if there is 1 DSC resources that is not converged" do
|
53
53
|
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"])
|
54
54
|
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
|
55
55
|
provider.load_current_resource
|
56
|
-
expect(provider.instance_variable_get(
|
56
|
+
expect(provider.instance_variable_get(:@resource_converged)).to be_falsey
|
57
57
|
end
|
58
58
|
|
59
59
|
it "describes the resource as not converged if there are any DSC resources that are not converged" do
|
@@ -62,7 +62,7 @@ describe Chef::Provider::DscScript do
|
|
62
62
|
|
63
63
|
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
|
64
64
|
provider.load_current_resource
|
65
|
-
expect(provider.instance_variable_get(
|
65
|
+
expect(provider.instance_variable_get(:@resource_converged)).to be_falsey
|
66
66
|
end
|
67
67
|
|
68
68
|
it "describes the resource as converged if all DSC resources that are converged" do
|
@@ -71,7 +71,7 @@ describe Chef::Provider::DscScript do
|
|
71
71
|
|
72
72
|
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
|
73
73
|
provider.load_current_resource
|
74
|
-
expect(provider.instance_variable_get(
|
74
|
+
expect(provider.instance_variable_get(:@resource_converged)).to be_truthy
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -126,19 +126,19 @@ describe Chef::Provider::DscScript do
|
|
126
126
|
describe "#generate_description" do
|
127
127
|
it "removes the resource name from the beginning of any log line from the LCM" do
|
128
128
|
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
|
129
|
-
provider.instance_variable_set(
|
129
|
+
provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
|
130
130
|
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/)
|
131
131
|
end
|
132
132
|
|
133
133
|
it "ignores the last line" do
|
134
134
|
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
|
135
|
-
provider.instance_variable_set(
|
135
|
+
provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
|
136
136
|
expect(provider.send(:generate_description)[1]).not_to match(/lastline/)
|
137
137
|
end
|
138
138
|
|
139
139
|
it "reports a dsc resource has not been changed if the LCM reported no change was required" do
|
140
140
|
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"])
|
141
|
-
provider.instance_variable_set(
|
141
|
+
provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info])
|
142
142
|
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/)
|
143
143
|
end
|
144
144
|
end
|
@@ -61,7 +61,7 @@ describe Chef::Provider::Group::Usermod do
|
|
61
61
|
@provider.action = :modify
|
62
62
|
@provider.define_resource_requirements
|
63
63
|
@provider.load_current_resource
|
64
|
-
@provider.instance_variable_set(
|
64
|
+
@provider.instance_variable_set(:@group_exists, true)
|
65
65
|
expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider}, must set append true in group")
|
66
66
|
end
|
67
67
|
|
@@ -69,7 +69,7 @@ describe Chef::Provider::Group::Usermod do
|
|
69
69
|
@provider.action = :modify
|
70
70
|
@provider.define_resource_requirements
|
71
71
|
@provider.load_current_resource
|
72
|
-
@provider.instance_variable_set(
|
72
|
+
@provider.instance_variable_set(:@group_exists, true)
|
73
73
|
@new_resource.append(true)
|
74
74
|
@new_resource.excluded_members(["someone"])
|
75
75
|
expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider}")
|
@@ -68,8 +68,8 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
68
68
|
it "should add an interface if it does not exist" do
|
69
69
|
@new_resource.device "en10"
|
70
70
|
allow(@provider).to receive(:load_current_resource) do
|
71
|
-
@provider.instance_variable_set(
|
72
|
-
@provider.instance_variable_set(
|
71
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
72
|
+
@provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
|
73
73
|
end
|
74
74
|
command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}"
|
75
75
|
expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
|
@@ -82,8 +82,8 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
82
82
|
@new_resource.device "en0"
|
83
83
|
@new_resource.metric "1"
|
84
84
|
allow(@provider).to receive(:load_current_resource) do
|
85
|
-
@provider.instance_variable_set(
|
86
|
-
@provider.instance_variable_set(
|
85
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
86
|
+
@provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
|
87
87
|
end
|
88
88
|
|
89
89
|
expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric property cannot be set for :add action")
|
@@ -94,8 +94,8 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
94
94
|
it "should enable an interface if it does not exist" do
|
95
95
|
@new_resource.device "en10"
|
96
96
|
allow(@provider).to receive(:load_current_resource) do
|
97
|
-
@provider.instance_variable_set(
|
98
|
-
@provider.instance_variable_set(
|
97
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
98
|
+
@provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
|
99
99
|
end
|
100
100
|
command = "ifconfig #{@new_resource.device} #{@new_resource.name}"
|
101
101
|
expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
|
@@ -110,8 +110,8 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
110
110
|
it "should not disable an interface if it does not exist" do
|
111
111
|
@new_resource.device "en10"
|
112
112
|
allow(@provider).to receive(:load_current_resource) do
|
113
|
-
@provider.instance_variable_set(
|
114
|
-
@provider.instance_variable_set(
|
113
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
114
|
+
@provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
|
115
115
|
end
|
116
116
|
|
117
117
|
expect(@provider).not_to receive(:shell_out_compacted!)
|
@@ -124,10 +124,10 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
124
124
|
before do
|
125
125
|
@new_resource.device "en10"
|
126
126
|
allow(@provider).to receive(:load_current_resource) do
|
127
|
-
@provider.instance_variable_set(
|
127
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
128
128
|
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
|
129
129
|
current_resource.device @new_resource.device
|
130
|
-
@provider.instance_variable_set(
|
130
|
+
@provider.instance_variable_set(:@current_resource, current_resource)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -147,8 +147,8 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
147
147
|
it "should not delete an interface if it does not exist" do
|
148
148
|
@new_resource.device "en10"
|
149
149
|
allow(@provider).to receive(:load_current_resource) do
|
150
|
-
@provider.instance_variable_set(
|
151
|
-
@provider.instance_variable_set(
|
150
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
151
|
+
@provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
|
152
152
|
end
|
153
153
|
|
154
154
|
expect(@provider).not_to receive(:shell_out_compacted!)
|
@@ -161,10 +161,10 @@ describe Chef::Provider::Ifconfig::Aix do
|
|
161
161
|
before do
|
162
162
|
@new_resource.device "en10"
|
163
163
|
allow(@provider).to receive(:load_current_resource) do
|
164
|
-
@provider.instance_variable_set(
|
164
|
+
@provider.instance_variable_set(:@status, double("Status", exitstatus: 0))
|
165
165
|
current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
|
166
166
|
current_resource.device @new_resource.device
|
167
|
-
@provider.instance_variable_set(
|
167
|
+
@provider.instance_variable_set(:@current_resource, current_resource)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
@@ -42,7 +42,7 @@ describe Chef::Provider::Ifconfig::Debian do
|
|
42
42
|
let(:provider) do
|
43
43
|
status = double("Status", exitstatus: 0)
|
44
44
|
provider = Chef::Provider::Ifconfig::Debian.new(new_resource, run_context)
|
45
|
-
provider.instance_variable_set(
|
45
|
+
provider.instance_variable_set(:@status, status)
|
46
46
|
provider.current_resource = current_resource
|
47
47
|
allow(provider).to receive(:load_current_resource)
|
48
48
|
allow(provider).to receive(:shell_out!)
|
@@ -40,7 +40,7 @@ describe Chef::Provider::Ifconfig::Redhat do
|
|
40
40
|
@current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
|
41
41
|
|
42
42
|
status = double("Status", exitstatus: 0)
|
43
|
-
@provider.instance_variable_set(
|
43
|
+
@provider.instance_variable_set(:@status, status)
|
44
44
|
@provider.current_resource = @current_resource
|
45
45
|
|
46
46
|
config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
|
@@ -35,7 +35,7 @@ describe Chef::Provider::Ifconfig do
|
|
35
35
|
@current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
|
36
36
|
|
37
37
|
status = double("Status", exitstatus: 0)
|
38
|
-
@provider.instance_variable_set(
|
38
|
+
@provider.instance_variable_set(:@status, status)
|
39
39
|
@provider.current_resource = @current_resource
|
40
40
|
end
|
41
41
|
|
@@ -58,7 +58,7 @@ describe Chef::Provider::Ifconfig do
|
|
58
58
|
@provider.load_current_resource
|
59
59
|
end
|
60
60
|
it "should track state of ifconfig failure" do
|
61
|
-
expect(@provider.instance_variable_get(
|
61
|
+
expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0)
|
62
62
|
end
|
63
63
|
it "should thrown an exception when ifconfig fails" do
|
64
64
|
@provider.action = :add
|
@@ -79,7 +79,7 @@ describe Chef::Provider::Ifconfig do
|
|
79
79
|
@provider.load_current_resource
|
80
80
|
end
|
81
81
|
it "should track state of ifconfig failure" do
|
82
|
-
expect(@provider.instance_variable_get(
|
82
|
+
expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0)
|
83
83
|
end
|
84
84
|
it "should thrown an exception when ifconfig fails" do
|
85
85
|
@provider.action = :add
|
@@ -219,11 +219,11 @@ describe Chef::Provider::RemoteFile::CacheControlData do
|
|
219
219
|
let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) }
|
220
220
|
let(:truncated_file_cache_path) do
|
221
221
|
cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum)
|
222
|
-
cache_control_data_truncated.send(
|
222
|
+
cache_control_data_truncated.send(:sanitized_cache_file_basename)[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
|
223
223
|
end
|
224
224
|
|
225
225
|
it "truncates the file cache path to 102 characters" do
|
226
|
-
normalized_cache_path = cache_control_data.send(
|
226
|
+
normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename)
|
227
227
|
|
228
228
|
expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
|
229
229
|
|
@@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
|
|
233
233
|
end
|
234
234
|
|
235
235
|
it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do
|
236
|
-
normalized_cache_path = cache_control_data.send(
|
236
|
+
normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename)
|
237
237
|
|
238
238
|
expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH)
|
239
239
|
expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true)
|
@@ -49,13 +49,13 @@ describe Chef::Provider::Service::Gentoo do
|
|
49
49
|
|
50
50
|
it "should track when service file is not found in /etc/runlevels" do
|
51
51
|
@provider.load_current_resource
|
52
|
-
expect(@provider.instance_variable_get(
|
52
|
+
expect(@provider.instance_variable_get(:@found_script)).to be_falsey
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should track when service file is found in /etc/runlevels/**/" do
|
56
56
|
allow(Dir).to receive(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"])
|
57
57
|
@provider.load_current_resource
|
58
|
-
expect(@provider.instance_variable_get(
|
58
|
+
expect(@provider.instance_variable_get(:@found_script)).to be_truthy
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "when detecting the service enable state" do
|
@@ -160,7 +160,7 @@ describe Chef::Provider::Service::Upstart do
|
|
160
160
|
it "should track state when the upstart configuration file fails to load" do
|
161
161
|
expect(File).to receive(:exist?).and_return false
|
162
162
|
@provider.load_current_resource
|
163
|
-
expect(@provider.instance_variable_get(
|
163
|
+
expect(@provider.instance_variable_get(:@config_file_found)).to eq(false)
|
164
164
|
end
|
165
165
|
|
166
166
|
describe "when a status command has been specified" do
|
@@ -177,7 +177,7 @@ describe Chef::Provider::Service::Upstart do
|
|
177
177
|
it "should track state when the user-provided status command fails" do
|
178
178
|
allow(@provider).to receive(:shell_out!).and_raise(Errno::ENOENT)
|
179
179
|
@provider.load_current_resource
|
180
|
-
expect(@provider.instance_variable_get(
|
180
|
+
expect(@provider.instance_variable_get(:@command_success)).to eq(false)
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do
|
@@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do
|
|
190
190
|
it "should track state when we fail to obtain service status via upstart_goal_state" do
|
191
191
|
expect(@provider).to receive(:upstart_goal_state).and_raise Chef::Exceptions::Exec
|
192
192
|
@provider.load_current_resource
|
193
|
-
expect(@provider.instance_variable_get(
|
193
|
+
expect(@provider.instance_variable_get(:@command_success)).to eq(false)
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should return the current resource" do
|
@@ -74,7 +74,7 @@ describe Chef::Provider::User::Solaris do
|
|
74
74
|
allow(Tempfile).to receive(:new).with("shadow", "/etc").and_return(temp_file)
|
75
75
|
new_resource.password "verysecurepassword"
|
76
76
|
provider.manage_user
|
77
|
-
expect(::File.
|
77
|
+
expect(::File.read(password_file.path)).to match(/adam:verysecurepassword:/)
|
78
78
|
password_file.unlink
|
79
79
|
end
|
80
80
|
end
|
@@ -29,8 +29,7 @@ rescue LoadError
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
describe Chef::Resource::ArchiveFile, :libarchive_loading_broken do
|
32
|
+
describe Chef::Resource::ArchiveFile, :not_supported_on_aix do
|
34
33
|
let(:node) { Chef::Node.new }
|
35
34
|
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
36
35
|
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
@@ -59,7 +59,7 @@ describe Chef::Resource::Conditional do
|
|
59
59
|
|
60
60
|
describe "after running a negative/false command given as a string" do
|
61
61
|
before do
|
62
|
-
@status.send("success?=", false)
|
62
|
+
@status.send(:"success?=", false)
|
63
63
|
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false")
|
64
64
|
end
|
65
65
|
|
@@ -80,7 +80,7 @@ describe Chef::Resource::Conditional do
|
|
80
80
|
|
81
81
|
describe "after running a negative/false command given as an array" do
|
82
82
|
before do
|
83
|
-
@status.send("success?=", false)
|
83
|
+
@status.send(:"success?=", false)
|
84
84
|
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, ["false"])
|
85
85
|
end
|
86
86
|
|
@@ -162,7 +162,7 @@ describe Chef::Resource::Conditional do
|
|
162
162
|
|
163
163
|
describe "after running a failed/false command given as a string" do
|
164
164
|
before do
|
165
|
-
@status.send("success?=", false)
|
165
|
+
@status.send(:"success?=", false)
|
166
166
|
@conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false")
|
167
167
|
end
|
168
168
|
|
@@ -183,7 +183,7 @@ describe Chef::Resource::Conditional do
|
|
183
183
|
|
184
184
|
describe "after running a failed/false command given as an array" do
|
185
185
|
before do
|
186
|
-
@status.send("success?=", false)
|
186
|
+
@status.send(:"success?=", false)
|
187
187
|
@conditional = Chef::Resource::Conditional.not_if(@parent_resource, ["false"])
|
188
188
|
end
|
189
189
|
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -955,7 +955,7 @@ describe Chef::Resource do
|
|
955
955
|
node.name("bumblebee")
|
956
956
|
node.automatic[:platform] = "autobots"
|
957
957
|
node.automatic[:platform_version] = "6.1"
|
958
|
-
Object.const_set(
|
958
|
+
Object.const_set(:Soundwave, klz1)
|
959
959
|
klz1.provides :soundwave
|
960
960
|
end
|
961
961
|
|
@@ -978,7 +978,7 @@ describe Chef::Resource do
|
|
978
978
|
node.automatic[:platform] = "autobots"
|
979
979
|
node.automatic[:platform_version] = "6.1"
|
980
980
|
klz2.provides :dinobot, platform: ["autobots"]
|
981
|
-
Object.const_set(
|
981
|
+
Object.const_set(:Grimlock, klz2)
|
982
982
|
klz2.provides :grimlock
|
983
983
|
end
|
984
984
|
|
@@ -65,6 +65,52 @@ describe Chef::SecretFetcher::HashiVault do
|
|
65
65
|
fetcher.validate!
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
context "and using auth_method: :approle" do
|
70
|
+
it "raises ConfigurationInvalid message when :approle_name or :approle_id are not specified" do
|
71
|
+
fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :approle, vault_addr: "https://vault.example.com:8200" }, run_context)
|
72
|
+
expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "authenticates using the approle_id and approle_secret_id during validation when all configuration is correct" do
|
76
|
+
fetcher = Chef::SecretFetcher::HashiVault.new({
|
77
|
+
auth_method: :approle,
|
78
|
+
approle_id: "idguid",
|
79
|
+
approle_secret_id: "secretguid",
|
80
|
+
vault_addr: "https://vault.example.com:8200" },
|
81
|
+
run_context)
|
82
|
+
auth = instance_double(Vault::Authenticate)
|
83
|
+
allow(auth).to receive(:approle)
|
84
|
+
allow(Vault).to receive(:auth).and_return(auth)
|
85
|
+
expect(auth).to receive(:approle).with("idguid", "secretguid")
|
86
|
+
fetcher.validate!
|
87
|
+
end
|
88
|
+
|
89
|
+
it "looks up the :role_id and :secret_id when all configuration is correct" do
|
90
|
+
fetcher = Chef::SecretFetcher::HashiVault.new({
|
91
|
+
auth_method: :approle,
|
92
|
+
approle_name: "myapprole",
|
93
|
+
token: "t.1234abcd",
|
94
|
+
vault_addr: "https://vault.example.com:8200" },
|
95
|
+
run_context)
|
96
|
+
approle = instance_double(Vault::AppRole)
|
97
|
+
auth = instance_double(Vault::Authenticate)
|
98
|
+
allow(Vault).to receive(:approle).and_return(approle)
|
99
|
+
allow(approle).to receive(:role_id).with("myapprole").and_return("idguid")
|
100
|
+
allow(approle).to receive(:create_secret_id).with("myapprole").and_return(Vault::Secret.new({
|
101
|
+
data: {
|
102
|
+
secret_id: "secretguid",
|
103
|
+
secret_id_accessor: "accessor_guid",
|
104
|
+
secret_id_ttl: 0,
|
105
|
+
},
|
106
|
+
lease_duration: 0,
|
107
|
+
lease_id: "",
|
108
|
+
}))
|
109
|
+
allow(Vault).to receive(:auth).and_return(auth)
|
110
|
+
expect(auth).to receive(:approle).with("idguid", "secretguid")
|
111
|
+
fetcher.validate!
|
112
|
+
end
|
113
|
+
end
|
68
114
|
end
|
69
115
|
|
70
116
|
context "when fetching a secret from Hashi Vault" do
|