chef 17.3.48-universal-mingw32 → 17.6.15-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.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/chef.gemspec +2 -0
  4. data/lib/chef/application/base.rb +11 -1
  5. data/lib/chef/application.rb +3 -1
  6. data/lib/chef/client.rb +1 -2
  7. data/lib/chef/compliance/default_attributes.rb +5 -3
  8. data/lib/chef/compliance/input.rb +115 -0
  9. data/lib/chef/compliance/input_collection.rb +139 -0
  10. data/lib/chef/compliance/profile.rb +122 -0
  11. data/lib/chef/compliance/profile_collection.rb +109 -0
  12. data/lib/chef/compliance/reporter/automate.rb +1 -1
  13. data/lib/chef/compliance/runner.rb +62 -6
  14. data/lib/chef/compliance/waiver.rb +115 -0
  15. data/lib/chef/compliance/waiver_collection.rb +143 -0
  16. data/lib/chef/dsl/compliance.rb +38 -0
  17. data/lib/chef/dsl/reader_helpers.rb +51 -0
  18. data/lib/chef/dsl/recipe.rb +4 -2
  19. data/lib/chef/dsl/secret.rb +5 -7
  20. data/lib/chef/dsl/universal.rb +2 -0
  21. data/lib/chef/event_dispatch/base.rb +44 -2
  22. data/lib/chef/exceptions.rb +0 -2
  23. data/lib/chef/formatters/doc.rb +60 -13
  24. data/lib/chef/formatters/error_mapper.rb +2 -2
  25. data/lib/chef/formatters/minimal.rb +6 -5
  26. data/lib/chef/http/basic_client.rb +15 -7
  27. data/lib/chef/http.rb +12 -8
  28. data/lib/chef/provider/execute.rb +1 -1
  29. data/lib/chef/provider/file.rb +2 -0
  30. data/lib/chef/provider/group/dscl.rb +1 -1
  31. data/lib/chef/provider/launchd.rb +6 -6
  32. data/lib/chef/provider/link.rb +2 -2
  33. data/lib/chef/provider/registry_key.rb +3 -2
  34. data/lib/chef/provider/remote_file/http.rb +1 -1
  35. data/lib/chef/provider/subversion.rb +4 -4
  36. data/lib/chef/provider/support/yum_repo.erb +1 -1
  37. data/lib/chef/provider/systemd_unit.rb +17 -16
  38. data/lib/chef/provider/template.rb +1 -1
  39. data/lib/chef/provider/user/mac.rb +3 -3
  40. data/lib/chef/provider/yum_repository.rb +27 -43
  41. data/lib/chef/provider/zypper_repository.rb +3 -3
  42. data/lib/chef/provider.rb +26 -1
  43. data/lib/chef/provider_resolver.rb +8 -2
  44. data/lib/chef/resource/archive_file.rb +17 -14
  45. data/lib/chef/resource/chef_client_scheduled_task.rb +45 -2
  46. data/lib/chef/resource/chocolatey_config.rb +13 -13
  47. data/lib/chef/resource/execute.rb +2 -2
  48. data/lib/chef/resource/file/verification/json.rb +50 -0
  49. data/lib/chef/resource/file/verification/yaml.rb +52 -0
  50. data/lib/chef/resource/homebrew_cask.rb +1 -1
  51. data/lib/chef/resource/inspec_input.rb +127 -0
  52. data/lib/chef/resource/inspec_waiver.rb +184 -0
  53. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -2
  54. data/lib/chef/resource/launchd.rb +3 -3
  55. data/lib/chef/resource/mount.rb +1 -1
  56. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  57. data/lib/chef/resource/powershell_package_source.rb +234 -70
  58. data/lib/chef/resource/registry_key.rb +36 -48
  59. data/lib/chef/resource/remote_file.rb +99 -3
  60. data/lib/chef/resource/rhsm_subscription.rb +5 -5
  61. data/lib/chef/resource/ruby_block.rb +100 -0
  62. data/lib/chef/resource/scm/subversion.rb +1 -1
  63. data/lib/chef/resource/sysctl.rb +2 -2
  64. data/lib/chef/resource/systemd_unit.rb +3 -3
  65. data/lib/chef/resource/timezone.rb +2 -2
  66. data/lib/chef/resource/user_ulimit.rb +1 -0
  67. data/lib/chef/resource/windows_printer.rb +1 -1
  68. data/lib/chef/resource/windows_uac.rb +3 -1
  69. data/lib/chef/resource/windows_user_privilege.rb +1 -1
  70. data/lib/chef/resource/yum_package.rb +1 -5
  71. data/lib/chef/resource.rb +13 -17
  72. data/lib/chef/resource_inspector.rb +6 -2
  73. data/lib/chef/resources.rb +2 -0
  74. data/lib/chef/run_context/cookbook_compiler.rb +112 -28
  75. data/lib/chef/run_context.rb +31 -1
  76. data/lib/chef/secret_fetcher/akeyless_vault.rb +57 -0
  77. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +17 -5
  78. data/lib/chef/secret_fetcher/azure_key_vault.rb +32 -10
  79. data/lib/chef/secret_fetcher/base.rb +6 -2
  80. data/lib/chef/secret_fetcher/hashi_vault.rb +100 -0
  81. data/lib/chef/secret_fetcher.rb +13 -6
  82. data/lib/chef/version.rb +1 -1
  83. data/lib/chef/win32/version.rb +2 -1
  84. data/spec/data/archive_file/test_archive.tar.gz +0 -0
  85. data/spec/functional/resource/archive_file_spec.rb +87 -0
  86. data/spec/functional/resource/group_spec.rb +5 -1
  87. data/spec/functional/resource/link_spec.rb +8 -0
  88. data/spec/functional/resource/powershell_package_source_spec.rb +5 -6
  89. data/spec/integration/compliance/compliance_spec.rb +61 -0
  90. data/spec/integration/recipes/resource_action_spec.rb +2 -2
  91. data/spec/spec_helper.rb +3 -0
  92. data/spec/support/platform_helpers.rb +4 -0
  93. data/spec/support/ruby_installer.rb +51 -0
  94. data/spec/unit/compliance/input_spec.rb +104 -0
  95. data/spec/unit/compliance/profile_spec.rb +120 -0
  96. data/spec/unit/compliance/runner_spec.rb +46 -2
  97. data/spec/unit/compliance/waiver_spec.rb +104 -0
  98. data/spec/unit/dsl/secret_spec.rb +8 -2
  99. data/spec/unit/formatters/doc_spec.rb +1 -1
  100. data/spec/unit/http/basic_client_spec.rb +30 -0
  101. data/spec/unit/http_spec.rb +8 -2
  102. data/spec/unit/provider/link_spec.rb +13 -7
  103. data/spec/unit/provider/remote_file/http_spec.rb +10 -0
  104. data/spec/unit/provider/template_spec.rb +2 -2
  105. data/spec/unit/provider_spec.rb +23 -0
  106. data/spec/unit/resource/archive_file_spec.rb +414 -3
  107. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +69 -0
  108. data/spec/unit/resource/file/verification/json_spec.rb +72 -0
  109. data/spec/unit/resource/file/verification/yaml_spec.rb +67 -0
  110. data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
  111. data/spec/unit/resource/inspec_input_spec.rb +300 -0
  112. data/spec/unit/resource/inspec_waiver_spec.rb +312 -0
  113. data/spec/unit/resource/mount_spec.rb +10 -0
  114. data/spec/unit/resource/powershell_package_source_spec.rb +63 -62
  115. data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
  116. data/spec/unit/resource/systemd_unit_spec.rb +1 -1
  117. data/spec/unit/resource/user_ulimit_spec.rb +14 -1
  118. data/spec/unit/resource_spec.rb +19 -8
  119. data/spec/unit/secret_fetcher/akeyless_vault_spec.rb +37 -0
  120. data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
  121. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +23 -16
  122. data/spec/unit/secret_fetcher/hashi_vault_spec.rb +80 -0
  123. data/spec/unit/secret_fetcher_spec.rb +9 -9
  124. data/tasks/rspec.rb +2 -1
  125. metadata +61 -6
@@ -202,6 +202,16 @@ describe Chef::Compliance::Runner do
202
202
  expect { runner.load_and_validate! }.to raise_error(/^CMPL002:/)
203
203
  end
204
204
 
205
+ it "raises CMPL004 if both the inputs and attributes node attributes are set" do
206
+ node.normal["audit"]["attributes"] = {
207
+ "tacos" => "lunch",
208
+ }
209
+ node.normal["audit"]["inputs"] = {
210
+ "tacos" => "lunch",
211
+ }
212
+ expect { runner.load_and_validate! }.to raise_error(/^CMPL011:/)
213
+ end
214
+
205
215
  it "validates configured reporters" do
206
216
  node.normal["audit"]["reporter"] = [ "chef-automate" ]
207
217
  reporter_double = double("reporter", validate_config!: nil)
@@ -212,6 +222,40 @@ describe Chef::Compliance::Runner do
212
222
  end
213
223
 
214
224
  describe "#inspec_opts" do
225
+ it "pulls inputs from the attributes setting" do
226
+ node.normal["audit"]["attributes"] = {
227
+ "tacos" => "lunch",
228
+ }
229
+
230
+ inputs = runner.inspec_opts[:inputs]
231
+
232
+ expect(inputs["tacos"]).to eq("lunch")
233
+ end
234
+
235
+ it "pulls inputs from the inputs setting" do
236
+ node.normal["audit"]["inputs"] = {
237
+ "tacos" => "lunch",
238
+ }
239
+
240
+ inputs = runner.inspec_opts[:inputs]
241
+
242
+ expect(inputs["tacos"]).to eq("lunch")
243
+ end
244
+
245
+ it "favors inputs over attributes" do
246
+ node.normal["audit"]["attributes"] = {
247
+ "tacos" => "dinner",
248
+ }
249
+
250
+ node.normal["audit"]["inputs"] = {
251
+ "tacos" => "lunch",
252
+ }
253
+
254
+ inputs = runner.inspec_opts[:inputs]
255
+
256
+ expect(inputs["tacos"]).to eq("lunch")
257
+ end
258
+
215
259
  it "does not include chef_node in inputs by default" do
216
260
  node.normal["audit"]["attributes"] = {
217
261
  "tacos" => "lunch",
@@ -221,7 +265,7 @@ describe Chef::Compliance::Runner do
221
265
  inputs = runner.inspec_opts[:inputs]
222
266
 
223
267
  expect(inputs["tacos"]).to eq("lunch")
224
- expect(inputs.key?("chef_node")).to eq(false)
268
+ expect(inputs.key?("chef_node")).to eq(true)
225
269
  end
226
270
 
227
271
  it "includes chef_node in inputs with chef_node_attribute_enabled set" do
@@ -234,7 +278,7 @@ describe Chef::Compliance::Runner do
234
278
  inputs = runner.inspec_opts[:inputs]
235
279
 
236
280
  expect(inputs["tacos"]).to eq("lunch")
237
- expect(inputs["chef_node"]["audit"]["reporter"]).to eq(%w{json-file cli})
281
+ expect(inputs["chef_node"]["audit"]["reporter"]).to eq("cli")
238
282
  expect(inputs["chef_node"]["chef_environment"]).to eq("_default")
239
283
  end
240
284
  end
@@ -0,0 +1,104 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "tempfile"
20
+
21
+ describe Chef::Compliance::Waiver do
22
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
23
+ let(:data) { { "ssh-01" => { "expiration_date" => Date.jd(2463810), "justification" => "waived, yo", "run" => false } } }
24
+ let(:path) { "/var/chef/cache/cookbooks/acme_compliance/compliance/waivers/default.yml" }
25
+ let(:cookbook_name) { "acme_compliance" }
26
+ let(:waiver) { Chef::Compliance::Waiver.new(events, data, path, cookbook_name) }
27
+
28
+ it "has a cookbook_name" do
29
+ expect(waiver.cookbook_name).to eql(cookbook_name)
30
+ end
31
+
32
+ it "has a path" do
33
+ expect(waiver.path).to eql(path)
34
+ end
35
+
36
+ it "has a pathname based on the path" do
37
+ expect(waiver.pathname).to eql("default")
38
+ end
39
+
40
+ it "is disabled" do
41
+ expect(waiver.enabled).to eql(false)
42
+ expect(waiver.enabled?).to eql(false)
43
+ end
44
+
45
+ it "has an event handler" do
46
+ expect(waiver.events).to eql(events)
47
+ end
48
+
49
+ it "can be enabled by enable!" do
50
+ waiver.enable!
51
+ expect(waiver.enabled).to eql(true)
52
+ expect(waiver.enabled?).to eql(true)
53
+ end
54
+
55
+ it "enabling sends an event" do
56
+ expect(events).to receive(:compliance_waiver_enabled).with(waiver)
57
+ waiver.enable!
58
+ end
59
+
60
+ it "can be disabled by disable!" do
61
+ waiver.enable!
62
+ waiver.disable!
63
+ expect(waiver.enabled).to eql(false)
64
+ expect(waiver.enabled?).to eql(false)
65
+ end
66
+
67
+ it "has a #inspec_data method that renders the data" do
68
+ expect(waiver.inspec_data).to eql(data)
69
+ end
70
+
71
+ it "doesn't render the events in the inspect output" do
72
+ expect(waiver.inspect).not_to include("events")
73
+ end
74
+
75
+ it "inflates objects from YAML" do
76
+ string = <<~EOH
77
+ ssh-01:
78
+ expiration_date: 2033-07-31
79
+ run: false
80
+ justification: "waived, yo"
81
+ EOH
82
+ newwaiver = Chef::Compliance::Waiver.from_yaml(events, string, path, cookbook_name)
83
+ expect(newwaiver.data).to eql(data)
84
+ end
85
+
86
+ it "inflates objects from files" do
87
+ string = <<~EOH
88
+ ssh-01:
89
+ expiration_date: 2033-07-31
90
+ run: false
91
+ justification: "waived, yo"
92
+ EOH
93
+ tempfile = Tempfile.new("chef-compliance-test")
94
+ tempfile.write string
95
+ tempfile.close
96
+ newwaiver = Chef::Compliance::Waiver.from_file(events, tempfile.path, cookbook_name)
97
+ expect(newwaiver.data).to eql(data)
98
+ end
99
+
100
+ it "inflates objects from hashes" do
101
+ newwaiver = Chef::Compliance::Waiver.from_hash(events, data, path, cookbook_name)
102
+ expect(newwaiver.data).to eql(data)
103
+ end
104
+ end
@@ -21,6 +21,12 @@ require "chef/dsl/secret"
21
21
  require "chef/secret_fetcher/base"
22
22
  class SecretDSLTester
23
23
  include Chef::DSL::Secret
24
+ # Because DSL is invoked in the context of a recipe,
25
+ # we expect run_context to always be available when SecretFetcher::Base
26
+ # requests it - making it safe to mock here
27
+ def run_context
28
+ nil
29
+ end
24
30
  end
25
31
 
26
32
  class SecretFetcherImpl < Chef::SecretFetcher::Base
@@ -36,8 +42,8 @@ describe Chef::DSL::Secret do
36
42
  end
37
43
 
38
44
  it "uses SecretFetcher.for_service to find the fetcher" do
39
- substitute_fetcher = SecretFetcherImpl.new({})
40
- expect(Chef::SecretFetcher).to receive(:for_service).with(:example, {}).and_return(substitute_fetcher)
45
+ substitute_fetcher = SecretFetcherImpl.new({}, nil)
46
+ expect(Chef::SecretFetcher).to receive(:for_service).with(:example, {}, nil).and_return(substitute_fetcher)
41
47
  expect(substitute_fetcher).to receive(:fetch).with("key1", nil)
42
48
  dsl.secret(name: "key1", service: :example, config: {})
43
49
  end
@@ -40,7 +40,7 @@ describe Chef::Formatters::Base do
40
40
  }
41
41
 
42
42
  formatter.policyfile_loaded(minimal_policyfile)
43
- expect(out.string).to include("Using policy 'jenkins' at revision '613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073'")
43
+ expect(out.string).to include("Using Policyfile 'jenkins' at revision '613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073'")
44
44
  end
45
45
 
46
46
  it "prints cookbook name and version" do
@@ -47,6 +47,36 @@ describe "HTTP Connection" do
47
47
  expect(Net::HTTP).to receive(:new).and_return(net_http_mock)
48
48
  expect(basic_client.http_client).to eql(net_http_mock)
49
49
  end
50
+
51
+ it "allows setting net-http accessor options" do
52
+ basic_client = Chef::HTTP::BasicClient.new(uri, nethttp_opts: {
53
+ "continue_timeout" => 5,
54
+ "max_retries" => 5,
55
+ "read_timeout" => 5,
56
+ "write_timeout" => 5,
57
+ "ssl_timeout" => 5,
58
+ })
59
+ expect(basic_client.http_client.continue_timeout).to eql(5)
60
+ expect(basic_client.http_client.max_retries).to eql(5)
61
+ expect(basic_client.http_client.read_timeout).to eql(5)
62
+ expect(basic_client.http_client.write_timeout).to eql(5)
63
+ expect(basic_client.http_client.ssl_timeout).to eql(5)
64
+ end
65
+
66
+ it "allows setting net-http accssor options as symbols" do
67
+ basic_client = Chef::HTTP::BasicClient.new(uri, nethttp_opts: {
68
+ continue_timeout: 5,
69
+ max_retries: 5,
70
+ read_timeout: 5,
71
+ write_timeout: 5,
72
+ ssl_timeout: 5,
73
+ })
74
+ expect(basic_client.http_client.continue_timeout).to eql(5)
75
+ expect(basic_client.http_client.max_retries).to eql(5)
76
+ expect(basic_client.http_client.read_timeout).to eql(5)
77
+ expect(basic_client.http_client.write_timeout).to eql(5)
78
+ expect(basic_client.http_client.ssl_timeout).to eql(5)
79
+ end
50
80
  end
51
81
 
52
82
  describe "#build_http_client" do
@@ -46,13 +46,19 @@ describe Chef::HTTP do
46
46
  describe "#initialize" do
47
47
  it "accepts a keepalive option and passes it to the http_client" do
48
48
  http = Chef::HTTP.new(uri, keepalives: true)
49
- expect(Chef::HTTP::BasicClient).to receive(:new).with(uri, ssl_policy: Chef::HTTP::APISSLPolicy, keepalives: true).and_call_original
49
+ expect(Chef::HTTP::BasicClient).to receive(:new).with(uri, ssl_policy: Chef::HTTP::APISSLPolicy, nethttp_opts: {}, keepalives: true).and_call_original
50
50
  expect(http.http_client).to be_a_kind_of(Chef::HTTP::BasicClient)
51
51
  end
52
52
 
53
53
  it "the default is not to use keepalives" do
54
54
  http = Chef::HTTP.new(uri)
55
- expect(Chef::HTTP::BasicClient).to receive(:new).with(uri, ssl_policy: Chef::HTTP::APISSLPolicy, keepalives: false).and_call_original
55
+ expect(Chef::HTTP::BasicClient).to receive(:new).with(uri, ssl_policy: Chef::HTTP::APISSLPolicy, nethttp_opts: {}, keepalives: false).and_call_original
56
+ expect(http.http_client).to be_a_kind_of(Chef::HTTP::BasicClient)
57
+ end
58
+
59
+ it "allows setting the nethttp options hash" do
60
+ http = Chef::HTTP.new(uri, { nethttp: { "continue_timeout" => 5 } })
61
+ expect(Chef::HTTP::BasicClient).to receive(:new).with(uri, ssl_policy: Chef::HTTP::APISSLPolicy, nethttp_opts: { "continue_timeout" => 5 }, keepalives: false).and_call_original
56
62
  expect(http.http_client).to be_a_kind_of(Chef::HTTP::BasicClient)
57
63
  end
58
64
  end
@@ -125,7 +125,7 @@ describe Chef::Resource::Link do
125
125
 
126
126
  describe "when the target doesn't exist" do
127
127
  before do
128
- allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
128
+ allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
129
129
  allow(provider.file_class).to receive(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
130
130
  provider.load_current_resource
131
131
  end
@@ -152,13 +152,16 @@ describe Chef::Resource::Link do
152
152
  allow(stat).to receive(:mode).and_return(0755)
153
153
  allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(stat)
154
154
 
155
- allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
155
+ # XXX: this might be broken? it preserves prior behavior in the specs caused by File.exist?/exists? interactions
156
+ allow(Chef::ScanAccessControl).to receive(:new).and_return(instance_double(Chef::ScanAccessControl, set_all!: nil))
157
+
158
+ allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
156
159
  allow(provider.file_class).to receive(:symlink?).with("#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
157
160
  end
158
161
 
159
162
  describe "and the source does not exist" do
160
163
  before do
161
- allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false)
164
+ expect(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(false)
162
165
  provider.load_current_resource
163
166
  end
164
167
 
@@ -185,7 +188,7 @@ describe Chef::Resource::Link do
185
188
 
186
189
  allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
187
190
 
188
- allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
191
+ allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
189
192
  provider.load_current_resource
190
193
  end
191
194
 
@@ -212,7 +215,7 @@ describe Chef::Resource::Link do
212
215
 
213
216
  allow(provider.file_class).to receive(:stat).with("#{CHEF_SPEC_DATA}/fofile").and_return(stat)
214
217
 
215
- allow(File).to receive(:exists?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
218
+ allow(File).to receive(:exist?).with("#{CHEF_SPEC_DATA}/fofile").and_return(true)
216
219
  provider.load_current_resource
217
220
  end
218
221
 
@@ -262,6 +265,9 @@ describe Chef::Resource::Link do
262
265
  "#{CHEF_SPEC_DATA}/fofile-link"
263
266
  ).and_return(stat)
264
267
 
268
+ # XXX: this might be broken? it preserves prior behavior in the specs caused by File.exist?/exists? interactions
269
+ allow(Chef::ScanAccessControl).to receive(:new).and_return(instance_double(Chef::ScanAccessControl, set_all!: nil))
270
+
265
271
  provider.load_current_resource
266
272
  end
267
273
 
@@ -336,10 +342,10 @@ describe Chef::Resource::Link do
336
342
  "#{CHEF_SPEC_DATA}/fofile-link"
337
343
  ).and_return(false)
338
344
 
339
- allow(File).to receive(:exists?).with(
345
+ allow(File).to receive(:exist?).with(
340
346
  "#{CHEF_SPEC_DATA}/fofile-link"
341
347
  ).and_return(true)
342
- allow(File).to receive(:exists?).with(
348
+ allow(File).to receive(:exist?).with(
343
349
  "#{CHEF_SPEC_DATA}/fofile"
344
350
  ).and_return(true)
345
351
 
@@ -321,4 +321,14 @@ describe Chef::Provider::RemoteFile::HTTP do
321
321
 
322
322
  end
323
323
 
324
+ describe "#http_client_opts" do
325
+ before do
326
+ new_resource.http_options({ retries: 2, retry_delay: 3 })
327
+ end
328
+
329
+ it "should set http client options" do
330
+ expect(fetcher.send(:http_client_opts)).to eq({ retries: 2, retry_delay: 3 })
331
+ end
332
+ end
333
+
324
334
  end
@@ -50,7 +50,7 @@ describe Chef::Provider::Template do
50
50
 
51
51
  let(:content) do
52
52
  content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz")
53
- allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true)
53
+ allow(File).to receive(:exist?).with("/foo/bar/baz").and_return(true)
54
54
  content
55
55
  end
56
56
 
@@ -76,7 +76,7 @@ describe Chef::Provider::Template do
76
76
  it "stops executing when the local template source can't be found" do
77
77
  setup_normal_file
78
78
  allow(content).to receive(:template_location).and_return("/baz/bar/foo")
79
- allow(File).to receive(:exists?).with("/baz/bar/foo").and_return(false)
79
+ allow(File).to receive(:exist?).with("/baz/bar/foo").and_return(false)
80
80
  expect { provider.run_action(:create) }.to raise_error Chef::Mixin::WhyRun::ResourceRequirements::Assertion::AssertionFailure
81
81
  end
82
82
 
@@ -32,6 +32,21 @@ class NoWhyrunDemonstrator < Chef::Provider
32
32
  end
33
33
  end
34
34
 
35
+ class ActionDescriptionDemonstrator < Chef::Provider
36
+ def load_current_resource; end
37
+
38
+ action :foo, description: "foo described" do
39
+ true
40
+ end
41
+
42
+ action :foo2 do
43
+ true
44
+ end
45
+
46
+ end
47
+
48
+ context "blah" do
49
+ end
35
50
  class ConvergeActionDemonstrator < Chef::Provider
36
51
  attr_reader :system_state_altered
37
52
 
@@ -98,6 +113,14 @@ describe Chef::Provider do
98
113
  expect(@provider.action_nothing).to eql(true)
99
114
  end
100
115
 
116
+ it "should return an action description for action_description when one is available" do
117
+ expect(ActionDescriptionDemonstrator.action_description(:foo)).to eq "foo described"
118
+ end
119
+
120
+ it "should return nil for action_description when no description is available" do
121
+ expect(ActionDescriptionDemonstrator.action_description(:none)).to eq nil
122
+ end
123
+
101
124
  it "evals embedded recipes with a pristine resource collection" do
102
125
  @provider.run_context.instance_variable_set(:@resource_collection, "doesn't matter what this is")
103
126
  temporary_collection = nil