chef 17.10.0-universal-mingw32 → 17.10.95-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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Rakefile +2 -2
  4. data/chef-universal-mingw32.gemspec +2 -2
  5. data/chef.gemspec +5 -5
  6. data/lib/chef/client.rb +17 -2
  7. data/lib/chef/compliance/input_collection.rb +1 -1
  8. data/lib/chef/compliance/profile_collection.rb +1 -1
  9. data/lib/chef/compliance/waiver_collection.rb +1 -1
  10. data/lib/chef/dsl/secret.rb +113 -5
  11. data/lib/chef/mixin/checksum.rb +6 -0
  12. data/lib/chef/mixin/properties.rb +6 -0
  13. data/lib/chef/node/attribute.rb +20 -3
  14. data/lib/chef/node/mixin/deep_merge_cache.rb +4 -4
  15. data/lib/chef/provider/file.rb +2 -2
  16. data/lib/chef/provider/package/chocolatey.rb +18 -1
  17. data/lib/chef/provider/package/powershell.rb +1 -1
  18. data/lib/chef/provider/package/windows.rb +1 -1
  19. data/lib/chef/provider/user.rb +5 -1
  20. data/lib/chef/resource/chef_client_config.rb +5 -0
  21. data/lib/chef/resource/locale.rb +5 -2
  22. data/lib/chef/resource/macos_userdefaults.rb +9 -5
  23. data/lib/chef/resource/rhsm_register.rb +19 -0
  24. data/lib/chef/resource/support/client.erb +1 -2
  25. data/lib/chef/resource/windows_certificate.rb +54 -43
  26. data/lib/chef/resource/windows_pagefile.rb +28 -21
  27. data/lib/chef/resource/windows_user_privilege.rb +36 -26
  28. data/lib/chef/resource.rb +2 -1
  29. data/lib/chef/run_context.rb +16 -0
  30. data/lib/chef/secret_fetcher/hashi_vault.rb +1 -1
  31. data/lib/chef/version.rb +1 -1
  32. data/lib/chef/win32/version.rb +2 -1
  33. data/spec/data/trusted_certs/example.crt +29 -20
  34. data/spec/data/trusted_certs/example_no_cn.crt +30 -34
  35. data/spec/data/trusted_certs/opscode.pem +33 -54
  36. data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
  37. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  38. data/spec/functional/resource/windows_certificate_spec.rb +41 -13
  39. data/spec/functional/resource/windows_font_spec.rb +1 -1
  40. data/spec/functional/resource/windows_pagefile_spec.rb +31 -4
  41. data/spec/functional/resource/yum_package_spec.rb +1 -1
  42. data/spec/functional/shell_spec.rb +6 -0
  43. data/spec/unit/client_spec.rb +6 -3
  44. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  45. data/spec/unit/daemon_spec.rb +1 -5
  46. data/spec/unit/dsl/secret_spec.rb +127 -23
  47. data/spec/unit/mixin/checksum_spec.rb +28 -0
  48. data/spec/unit/provider/package/chocolatey_spec.rb +19 -3
  49. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  50. data/spec/unit/provider/user/linux_spec.rb +55 -0
  51. data/spec/unit/resource/chef_client_config_spec.rb +8 -0
  52. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  53. data/spec/unit/resource_spec.rb +22 -1
  54. data/spec/unit/run_context_spec.rb +16 -0
  55. metadata +48 -54
  56. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
  57. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
  58. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
  59. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
  60. /data/spec/functional/assets/yumrepo/repodata/{4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2 → 01a3b-filelists.sqlite.bz2} +0 -0
  61. /data/spec/functional/assets/yumrepo/repodata/{bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz → 401dc-filelists.xml.gz} +0 -0
  62. /data/spec/functional/assets/yumrepo/repodata/{a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2 → 5dc1e-primary.sqlite.bz2} +0 -0
  63. /data/spec/functional/assets/yumrepo/repodata/{74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz → 6bf96-other.xml.gz} +0 -0
  64. /data/spec/functional/assets/yumrepo/repodata/{af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2 → 7c365-other.sqlite.bz2} +0 -0
  65. /data/spec/functional/assets/yumrepo/repodata/{c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz → dabe2-primary.xml.gz} +0 -0
@@ -1,57 +1,36 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG9w0BAQsFADBh
2
+ MIIGTjCCBTagAwIBAgIQBK55YGZmkBq5xX+mbFvczTANBgkqhkiG9w0BAQsFADBl
3
3
  MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
4
- d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
5
- QTAeFw0xMzAzMDgxMjAwMDBaFw0yMzAzMDgxMjAwMDBaME0xCzAJBgNVBAYTAlVT
6
- MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxJzAlBgNVBAMTHkRpZ2lDZXJ0IFNIQTIg
7
- U2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
8
- ANyuWJBNwcQwFZA1W248ghX1LFy949v/cUP6ZCWA1O4Yok3wZtAKc24RmDYXZK83
9
- nf36QYSvx6+M/hpzTc8zl5CilodTgyu5pnVILR1WN3vaMT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Package, :windows_only, :choco_installed do
22
22
  include Chef::Mixin::ShellOut
23
23
 
24
24
  let(:package_name) { "test-A" }
25
- let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
26
25
  let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
26
+ let(:package_list) do
27
+ if Chef::Provider::Package::Chocolatey.query_command == "list"
28
+ # using result of query_command because that indicates which "search" command to use
29
+ # which coincides with the package list output
30
+ proc { shell_out!("choco search -lo #{Array(package_name).join(" ")}").stdout.chomp }
31
+ else
32
+ proc { shell_out!("choco list #{Array(package_name).join(" ")}").stdout.chomp }
33
+ end
34
+ end
27
35
 
28
36
  let(:run_context) do
29
37
  Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
@@ -54,12 +62,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
54
62
  ENV["Path"] = ENV.delete("Path")
55
63
  end
56
64
 
65
+ after(:each) do
66
+ described_class.instance_variable_set(:@get_choco_version, nil)
67
+ end
68
+
57
69
  context "installing a package" do
58
70
  after { remove_package }
59
71
 
60
72
  it "installs the latest version" do
61
73
  subject.run_action(:install)
62
- expect(package_list.call).to eq("#{package_name}|2.0")
74
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
63
75
  end
64
76
 
65
77
  it "does not install if already installed" do
@@ -69,19 +81,19 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
69
81
  end
70
82
 
71
83
  it "installs version given" do
72
- subject.version "1.0"
84
+ subject.version "1.0.0"
73
85
  subject.run_action(:install)
74
- expect(package_list.call).to eq("#{package_name}|1.0")
86
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
75
87
  end
76
88
 
77
89
  it "installs new version if one is already installed" do
78
- subject.version "1.0"
90
+ subject.version "1.0.0"
79
91
  subject.run_action(:install)
80
- expect(package_list.call).to eq("#{package_name}|1.0")
92
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
81
93
 
82
- subject.version "2.0"
94
+ subject.version "2.0.0"
83
95
  subject.run_action(:install)
84
- expect(package_list.call).to eq("#{package_name}|2.0")
96
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
85
97
  end
86
98
 
87
99
  context "installing multiple packages" do
@@ -89,7 +101,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
89
101
 
90
102
  it "installs both packages" do
91
103
  subject.run_action(:install)
92
- expect(package_list.call).to eq("test-A|2.0\r\ntest-B|1.0")
104
+ expect(package_list.call).to match(/^test-A|2.0.0\r\ntest-B|1.0.0$/)
93
105
  end
94
106
  end
95
107
 
@@ -101,13 +113,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
101
113
  it "installs with an option as a string" do
102
114
  subject.options "--force --confirm"
103
115
  subject.run_action(:install)
104
- expect(package_list.call).to eq("#{package_name}|2.0")
116
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
105
117
  end
106
118
 
107
119
  it "installs with multiple options as a string" do
108
120
  subject.options "--force --confirm"
109
121
  subject.run_action(:install)
110
- expect(package_list.call).to eq("#{package_name}|2.0")
122
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
111
123
  end
112
124
 
113
125
  context "when multiple options passed as string" do
@@ -137,7 +149,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
137
149
  it "installs with multiple options as an array" do
138
150
  subject.options [ "--force", "--confirm" ]
139
151
  subject.run_action(:install)
140
- expect(package_list.call).to eq("#{package_name}|2.0")
152
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
141
153
  end
142
154
  end
143
155
 
@@ -145,24 +157,24 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
145
157
  after { remove_package }
146
158
 
147
159
  it "upgrades to a specific version" do
148
- subject.version "1.0"
160
+ subject.version "1.0.0"
149
161
  subject.run_action(:install)
150
- expect(package_list.call).to eq("#{package_name}|1.0")
162
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
151
163
 
152
- subject.version "1.5"
164
+ subject.version "1.5.0"
153
165
  subject.run_action(:upgrade)
154
- expect(package_list.call).to eq("#{package_name}|1.5")
166
+ expect(package_list.call).to match(/^#{package_name}|1.5.0$/)
155
167
  end
156
168
 
157
169
  it "upgrades to the latest version if no version given" do
158
- subject.version "1.0"
170
+ subject.version "1.0.0"
159
171
  subject.run_action(:install)
160
- expect(package_list.call).to eq("#{package_name}|1.0")
172
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
161
173
 
162
174
  subject2 = Chef::Resource::ChocolateyPackage.new("test-A", run_context)
163
175
  subject2.source package_source
164
176
  subject2.run_action(:upgrade)
165
- expect(package_list.call).to eq("#{package_name}|2.0")
177
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
166
178
  end
167
179
  end
168
180
 
@@ -170,7 +182,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
170
182
  it "removes an installed package" do
171
183
  subject.run_action(:install)
172
184
  remove_package
173
- expect(package_list.call).to eq("")
185
+ expect(package_list.call).to match(/0 packages installed/)
174
186
  end
175
187
  end
176
188
 
@@ -38,12 +38,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
38
38
  expect(resource.domain).to eq("NSGlobalDomain")
39
39
  end
40
40
 
41
- it "nil for the host property" do
42
- expect(resource.host).to be_nil
41
+ it ":all for the host property" do
42
+ expect(resource.host).to eq(:all)
43
43
  end
44
44
 
45
- it "nil for the user property" do
46
- expect(resource.user).to be_nil
45
+ it ":current for the user property" do
46
+ expect(resource.user).to eq(:current)
47
47
  end
48
48
 
49
49
  it ":write for resource action" do
@@ -56,10 +56,34 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
56
56
  let(:store) { "Chef-Functional-Test" }
57
57
  let(:store_name) { "MY" }
58
58
  let(:store_location) { "LocalMachine" }
59
- let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
59
+ let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VGqrrkwZzvxqyW+WJMB2shGNFw5J
77
+ mKYBiiXsHl4Bi7V4zhXssrLp877sqpNLeXloXBmAlT39SwQTP9ImZaV5R6udqlvo
78
+ Gfgm5PH/WeK6MV3n5ik0v1rS0LwR2o82WlIB6a4iSEbzY3qSLsWOwt8o5QjAVzCR
79
+ tNdbdS3U8nrG73iA2clmF57ARQWC
80
+ -----END CERTIFICATE-----
81
+ CERT
82
+ end
60
83
  let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
61
84
  let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
62
85
  let(:key_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.key") }
86
+ let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
63
87
  let(:cer_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.cer") }
64
88
  let(:base64_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "base64_test.cer") }
65
89
  let(:pem_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.pem") }
@@ -89,7 +113,9 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
89
113
 
90
114
  end
91
115
 
92
- after { delete_store }
116
+ after do
117
+ delete_store
118
+ end
93
119
 
94
120
  describe "action: create" do
95
121
  it "starts with no certificates" do
@@ -126,6 +152,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
126
152
  end
127
153
 
128
154
  it "can add a certificate from a valid url" do
155
+ stub_request(:get, download_cert_url).to_return(body: test_cert_body)
129
156
  resource.source = download_cert_url
130
157
  resource.run_action(:create)
131
158
 
@@ -195,7 +222,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
195
222
  create_store
196
223
  end
197
224
  it "fails with no certificates in the store" do
198
- expect(Chef::Log).to receive(:info).with("Certificate not found")
225
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
199
226
 
200
227
  resource.source = tests_thumbprint
201
228
  resource.run_action(:verify)
@@ -219,7 +246,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
219
246
  end
220
247
 
221
248
  it "fails with an invalid thumbprint" do
222
- expect(Chef::Log).to receive(:info).with("Certificate not found")
249
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
223
250
 
224
251
  resource.source = others_thumbprint
225
252
  resource.run_action(:verify)
@@ -253,7 +280,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
253
280
  end
254
281
 
255
282
  it "fails with an invalid thumbprint" do
256
- expect(Chef::Log).to receive(:info).with("Certificate not found")
283
+ expect(Chef::Log).to receive(:info).with("Certificate not valid")
257
284
 
258
285
  resource.source = others_thumbprint
259
286
  resource.run_action(:verify)
@@ -265,11 +292,11 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
265
292
 
266
293
  describe "action: fetch" do
267
294
  context "with no certificate in the store" do
268
- it "throws an error with no certificates in the store" do
269
- expect(Chef::Log).not_to receive(:info)
295
+ it "logs a debug error with no certificates in the store" do
296
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
270
297
  resource.source = others_thumbprint
271
298
  resource.output_path = cert_output_path
272
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
299
+ resource.run_action(:fetch)
273
300
  end
274
301
  end
275
302
 
@@ -288,7 +315,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
288
315
  end
289
316
 
290
317
  it "fails with an invalid thumbprint" do
291
- expect(Chef::Log).not_to receive(:info)
318
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
292
319
 
293
320
  resource.source = others_thumbprint
294
321
 
@@ -296,7 +323,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
296
323
  path = File.join(dir, "test.pem")
297
324
 
298
325
  resource.output_path = path
299
- expect { resource.run_action :fetch }.to raise_error(ArgumentError)
326
+ resource.run_action(:fetch)
300
327
  end
301
328
 
302
329
  end
@@ -340,9 +367,10 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
340
367
  end
341
368
 
342
369
  describe "action: delete" do
343
- it "throws an argument error when attempting to delete a certificate that doesn't exist" do
370
+ it "logs an error when attempting to delete a certificate that doesn't exist" do
371
+ expect(Chef::Log).to receive(:debug).with("Certificate Not Found")
344
372
  resource.source = tests_thumbprint
345
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
373
+ resource.run_action(:delete)
346
374
  end
347
375
 
348
376
  it "deletes an existing certificate while leaving other certificates alone" do
@@ -360,7 +388,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
360
388
  expect(certificate_count).to eq(1)
361
389
  expect(resource).to be_updated_by_last_action
362
390
 
363
- expect { resource.run_action :delete }.to raise_error(ArgumentError)
391
+ expect { resource.run_action :delete }.not_to raise_error
364
392
  expect(certificate_count).to eq(1)
365
393
  expect(resource).not_to be_updated_by_last_action
366
394
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  require "spec_helper"
20
20
 
21
- describe Chef::Resource::WindowsFont, :windows_only do
21
+ describe Chef::Resource::WindowsFont, :windows_only, :broken do # these tests hang on Chef-16 and Chef-17 in the verify-pipline.
22
22
  let(:resource_name) { "Playmaker.ttf" }
23
23
  let(:resource_source) { "https://www.wfonts.com/download/data/2020/05/06/playmaker/Playmaker.ttf" }
24
24
 
@@ -40,13 +40,32 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
40
40
  new_resource
41
41
  end
42
42
 
43
+ def set_automatic_managed_to_false
44
+ powershell_code = <<~EOH
45
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
46
+ $computersys.AutomaticManagedPagefile = $False;
47
+ $computersys.Put();
48
+ EOH
49
+ powershell_exec!(powershell_code)
50
+ end
51
+
52
+ def set_automatic_managed_to_true
53
+ powershell_code = <<~EOH
54
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
55
+ $computersys.AutomaticManagedPagefile = $True;
56
+ $computersys.Put();
57
+ EOH
58
+ powershell_exec!(powershell_code)
59
+ end
60
+
43
61
  describe "Setting Up Pagefile Management" do
44
62
  context "Disable Automatic Management" do
45
- it "Disables Automatic Management" do
63
+ it "Verifies Automatic Management is Disabled" do
64
+ set_automatic_managed_to_false
46
65
  subject.path c_path
47
66
  subject.automatic_managed false
48
67
  subject.run_action(:set)
49
- expect(subject).to be_updated_by_last_action
68
+ expect(subject).not_to be_updated_by_last_action
50
69
  end
51
70
 
52
71
  it "Enable Automatic Management " do
@@ -55,6 +74,14 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
55
74
  subject.run_action(:set)
56
75
  expect(subject).to be_updated_by_last_action
57
76
  end
77
+
78
+ it "Disables Automatic Management" do
79
+ set_automatic_managed_to_true
80
+ subject.path c_path
81
+ subject.automatic_managed false
82
+ subject.run_action(:set)
83
+ expect(subject).to be_updated_by_last_action
84
+ end
58
85
  end
59
86
  end
60
87
 
@@ -69,8 +96,8 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
69
96
  context "Update a pagefile" do
70
97
  it "Changes a pagefile to use custom sizes" do
71
98
  subject.path c_path
72
- subject.initial_size 20000
73
- subject.maximum_size 80000
99
+ subject.initial_size 128
100
+ subject.maximum_size 512
74
101
  subject.run_action(:set)
75
102
  expect(subject).to be_updated_by_last_action
76
103
  end
@@ -20,7 +20,7 @@ require "chef/mixin/shell_out"
20
20
 
21
21
  # run this test only for following platforms.
22
22
  exclude_test = !(%w{rhel fedora amazon}.include?(OHAI_SYSTEM[:platform_family]) && !File.exist?("/usr/bin/dnf"))
23
- describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
23
+ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not_rhel6: true do
24
24
  include RecipeDSLHelper
25
25
  include Chef::Mixin::ShellOut
26
26
 
@@ -80,6 +80,12 @@ describe Shell do
80
80
  # so hide the require here
81
81
 
82
82
  require "pty"
83
+
84
+ # FIXME this is temporary... Solaris envs have TERM set to unknown
85
+ # and the value isn't propagating from the build environment TERM
86
+ # variable
87
+ ENV["TERM"] = "vt100" if ["", "unknown"].include?(ENV["TERM"].to_s)
88
+
83
89
  config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA)
84
90
  reader, writer, pid = PTY.spawn("bundle exec chef-shell --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
85
91
  read_until(reader, "chef (#{Chef::VERSION})>")
@@ -311,14 +311,17 @@ describe Chef::Client do
311
311
  describe "eol release warning" do
312
312
  it "warns when running an EOL release" do
313
313
  stub_const("Chef::VERSION", 15)
314
- allow(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5))
315
- expect(logger).to receive(:warn).with(/This release of.*became end of life \(EOL\) on May 1st 2021/)
314
+ # added a call to client because Time.now gets invoked multiple times during instantiation. Don't mock Time until after client initialized
315
+ client
316
+ expect(Time).to receive(:now).and_return(Time.new(2021, 5, 1, 5))
317
+ allow(client).to receive(:eol_override).and_return(false)
318
+ expect(logger).to receive(:warn).with("This release of Chef Infra Client became end of life (EOL) on May 01, 2021. Please update to a supported release to receive new features, bug fixes, and security updates.")
316
319
  client.warn_if_eol
317
320
  end
318
321
 
319
322
  it "does not warn when running an non-EOL release" do
320
323
  stub_const("Chef::VERSION", 15)
321
- allow(Time).to receive(:now).and_return(Time.new(2021, 4, 31))
324
+ allow(Time).to receive(:now).and_return(Time.new(2021, 4, 30))
322
325
  expect(logger).to_not receive(:warn).with(/became end of life/)
323
326
  client.warn_if_eol
324
327
  end
@@ -170,7 +170,7 @@ describe Chef::Compliance::Reporter::ChefServerAutomate do
170
170
  "X-Ops-Userid" => "spec-node",
171
171
  "X-Remote-Request-Id" => /.+/,
172
172
  }
173
- ).to_return(status: 200)
173
+ ).to_return(status: 200, body: "OK")
174
174
 
175
175
  expect(reporter.send_report(inspec_report)).to eq(true)
176
176
 
@@ -170,11 +170,7 @@ describe Chef::Daemon do
170
170
 
171
171
  it "should log an appropriate error message and fail miserably" do
172
172
  allow(Process).to receive(:initgroups).and_raise(Errno::EPERM)
173
- error = "Operation not permitted"
174
- if RUBY_PLATFORM.match("solaris2") || RUBY_PLATFORM.match("aix")
175
- error = "Not owner"
176
- end
177
- expect(Chef::Application).to receive(:fatal!).with("Permission denied when trying to change 999:999 to 501:20. #{error}")
173
+ expect(Chef::Application).to receive(:fatal!).with(/Permission denied when trying to change 999:999 to 501:20/)
178
174
  Chef::Daemon._change_privilege(testuser)
179
175
  end
180
176
  end