chef 18.6.2 → 18.7.3

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/chef.gemspec +17 -13
  4. data/lib/chef/compliance/default_attributes.rb +2 -2
  5. data/lib/chef/compliance/runner.rb +6 -1
  6. data/lib/chef/cookbook/metadata.rb +1 -1
  7. data/lib/chef/cookbook/remote_file_vendor.rb +1 -4
  8. data/lib/chef/event_dispatch/dispatcher.rb +0 -1
  9. data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
  10. data/lib/chef/provider/package/snap.rb +1 -1
  11. data/lib/chef/provider/registry_key.rb +6 -0
  12. data/lib/chef/resource/apt_repository.rb +85 -12
  13. data/lib/chef/resource/registry_key.rb +18 -0
  14. data/lib/chef/resource.rb +1 -0
  15. data/lib/chef/resource_reporter.rb +1 -0
  16. data/lib/chef/util/powershell/ps_credential.rb +10 -0
  17. data/lib/chef/version.rb +1 -1
  18. data/lib/chef/win32/registry.rb +0 -1
  19. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +6 -6
  20. data/spec/functional/resource/registry_spec.rb +276 -609
  21. data/spec/tiny_server.rb +5 -2
  22. data/spec/unit/provider/apt_repository_spec.rb +13 -8
  23. data/spec/unit/provider/registry_key_spec.rb +18 -17
  24. data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
  25. metadata +22 -22
  26. /data/spec/functional/assets/yumrepo-empty/repodata/{01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 → 01a3b-filelists.sqlite.bz2} +0 -0
  27. /data/spec/functional/assets/yumrepo-empty/repodata/{401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz → 401dc-filelists.xml.gz} +0 -0
  28. /data/spec/functional/assets/yumrepo-empty/repodata/{5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 → 5dc1e-primary.sqlite.bz2} +0 -0
  29. /data/spec/functional/assets/yumrepo-empty/repodata/{6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz → 6bf96-other.xml.gz} +0 -0
  30. /data/spec/functional/assets/yumrepo-empty/repodata/{7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 → 7c365-other.sqlite.bz2} +0 -0
  31. /data/spec/functional/assets/yumrepo-empty/repodata/{dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz → dabe2-primary.xml.gz} +0 -0
data/spec/tiny_server.rb CHANGED
@@ -19,6 +19,7 @@
19
19
  require "webrick"
20
20
  require "webrick/https"
21
21
  require "rack"
22
+ require "rackup"
22
23
  require "singleton"
23
24
  require "open-uri"
24
25
  require "chef/config"
@@ -91,7 +92,7 @@ module TinyServer
91
92
 
92
93
  def create_server(**extra_options)
93
94
  server = WEBrick::HTTPServer.new(**options, **extra_options)
94
- server.mount("/", Rack::Handler::WEBrick, API.instance)
95
+ server.mount("/", Rackup::Handler::WEBrick, API.instance)
95
96
  server
96
97
  end
97
98
  end
@@ -172,7 +173,9 @@ module TinyServer
172
173
 
173
174
  def initialize(response_code = 200, data = nil, headers = nil, &block)
174
175
  @response_code, @data = response_code, data
175
- @response_headers = headers ? HEADERS.merge(headers) : HEADERS
176
+ # .merge creates a new hash, headers is sometimes passed as nil, @response_headers gets mutated somewhere
177
+ # in processing
178
+ @response_headers = HEADERS.merge(headers || {})
176
179
  @block = block_given? ? block : nil
177
180
  end
178
181
 
@@ -246,43 +246,48 @@ C5986B4F1257FFA86632CBA746181433FBB75451
246
246
  describe "#build_repo" do
247
247
  it "creates a repository string" do
248
248
  target = "deb http://test/uri unstable main\n"
249
- expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, [])).to eql(target)
249
+ expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, nil, [])).to eql(target)
250
250
  end
251
251
 
252
252
  it "creates a repository string with spaces" do
253
253
  target = "deb http://test/uri%20with%20spaces unstable main\n"
254
- expect(provider.build_repo("http://test/uri with spaces", "unstable", "main", false, nil, [])).to eql(target)
254
+ expect(provider.build_repo("http://test/uri with spaces", "unstable", "main", false, nil, nil, [])).to eql(target)
255
255
  end
256
256
 
257
257
  it "creates a repository string with no distribution" do
258
258
  target = "deb http://test/uri main\n"
259
- expect(provider.build_repo("http://test/uri", nil, "main", false, nil, [])).to eql(target)
259
+ expect(provider.build_repo("http://test/uri", nil, "main", false, nil, nil, [])).to eql(target)
260
260
  end
261
261
 
262
262
  it "creates a repository string with source" do
263
263
  target = "deb http://test/uri unstable main\ndeb-src http://test/uri unstable main\n"
264
- expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, [], true)).to eql(target)
264
+ expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, nil, [], true)).to eql(target)
265
265
  end
266
266
 
267
267
  it "creates a repository string with trusted" do
268
268
  target = "deb [trusted=yes] http://test/uri unstable main\n"
269
- expect(provider.build_repo("http://test/uri", "unstable", "main", true, nil, [])).to eql(target)
269
+ expect(provider.build_repo("http://test/uri", "unstable", "main", true, nil, nil, [])).to eql(target)
270
+ end
271
+
272
+ it "creates a repository string with signed-by" do
273
+ target = "deb [signed-by=/etc/apt/keyrings/test.gpg] http://test/uri unstable main\n"
274
+ expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, "/etc/apt/keyrings/test.gpg", [])).to eql(target)
270
275
  end
271
276
 
272
277
  it "creates a repository string with custom options" do
273
278
  target = "deb [by-hash=no] http://test/uri unstable main\n"
274
- expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, ["by-hash=no"])).to eql(target)
279
+ expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, nil, ["by-hash=no"])).to eql(target)
275
280
  end
276
281
 
277
282
  it "creates a repository string with trusted, arch, and custom options" do
278
283
  target = "deb [arch=amd64 trusted=yes by-hash=no] http://test/uri unstable main\n"
279
- expect(provider.build_repo("http://test/uri", "unstable", "main", true, "amd64", ["by-hash=no"])).to eql(target)
284
+ expect(provider.build_repo("http://test/uri", "unstable", "main", true, "amd64", nil, ["by-hash=no"])).to eql(target)
280
285
  end
281
286
 
282
287
  it "handles a ppa repo" do
283
288
  target = "deb http://ppa.launchpad.net/chef/main/ubuntu unstable main\n"
284
289
  expect(provider).to receive(:make_ppa_url).with("ppa:chef/main").and_return("http://ppa.launchpad.net/chef/main/ubuntu")
285
- expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil, [])).to eql(target)
290
+ expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil, nil, [])).to eql(target)
286
291
  end
287
292
  end
288
293
  end
@@ -26,7 +26,8 @@ shared_examples_for "a registry key" do
26
26
  describe "when the key exists" do
27
27
  before(:each) do
28
28
  expect(@double_registry).to receive(:key_exists?).with(keyname).and_return(true)
29
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval2 )
29
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval2] )
30
+ @new_resource.only_record_changes false
30
31
  @provider.load_current_resource
31
32
  end
32
33
 
@@ -66,7 +67,7 @@ shared_examples_for "a registry key" do
66
67
  end
67
68
  it "should do nothing if the if a case insensitive key and the value both exist" do
68
69
  @provider.new_resource.key(keyname.downcase)
69
- expect(@double_registry).to receive(:get_values).with(keyname.downcase).and_return( testval1 )
70
+ expect(@double_registry).to receive(:get_values).with(keyname.downcase).and_return( [testval1 ])
70
71
  expect(@double_registry).not_to receive(:set_value)
71
72
  @provider.load_current_resource
72
73
  @provider.action_create
@@ -77,25 +78,25 @@ shared_examples_for "a registry key" do
77
78
  expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
78
79
  end
79
80
  it "should do nothing if the key and the value both exist" do
80
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1 )
81
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1] )
81
82
  expect(@double_registry).not_to receive(:set_value)
82
83
  @provider.load_current_resource
83
84
  @provider.action_create
84
85
  end
85
86
  it "should create the value if the key exists but the value does not" do
86
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval2 )
87
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval2] )
87
88
  expect(@double_registry).to receive(:set_value).with(keyname, testval1)
88
89
  @provider.load_current_resource
89
90
  @provider.action_create
90
91
  end
91
92
  it "should set the value if the key exists but the data does not match" do
92
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_data )
93
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_data] )
93
94
  expect(@double_registry).to receive(:set_value).with(keyname, testval1)
94
95
  @provider.load_current_resource
95
96
  @provider.action_create
96
97
  end
97
98
  it "should set the value if the key exists but the type does not match" do
98
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_type )
99
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_type] )
99
100
  expect(@double_registry).to receive(:set_value).with(keyname, testval1)
100
101
  @provider.load_current_resource
101
102
  @provider.action_create
@@ -105,7 +106,7 @@ shared_examples_for "a registry key" do
105
106
  it "when a value is in the key, it should do nothing" do
106
107
  @provider.new_resource.values([])
107
108
  expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
108
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1 )
109
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1] )
109
110
  expect(@double_registry).not_to receive(:create_key)
110
111
  expect(@double_registry).not_to receive(:set_value)
111
112
  @provider.load_current_resource
@@ -150,25 +151,25 @@ shared_examples_for "a registry key" do
150
151
  expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
151
152
  end
152
153
  it "should do nothing if the key and the value both exist" do
153
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1 )
154
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1] )
154
155
  expect(@double_registry).not_to receive(:set_value)
155
156
  @provider.load_current_resource
156
157
  @provider.action_create_if_missing
157
158
  end
158
159
  it "should create the value if the key exists but the value does not" do
159
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval2 )
160
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval2] )
160
161
  expect(@double_registry).to receive(:set_value).with(keyname, testval1)
161
162
  @provider.load_current_resource
162
163
  @provider.action_create_if_missing
163
164
  end
164
165
  it "should not set the value if the key exists but the data does not match" do
165
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_data )
166
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_data] )
166
167
  expect(@double_registry).not_to receive(:set_value)
167
168
  @provider.load_current_resource
168
169
  @provider.action_create_if_missing
169
170
  end
170
171
  it "should not set the value if the key exists but the type does not match" do
171
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_type )
172
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_type] )
172
173
  expect(@double_registry).not_to receive(:set_value)
173
174
  @provider.load_current_resource
174
175
  @provider.action_create_if_missing
@@ -193,25 +194,25 @@ shared_examples_for "a registry key" do
193
194
  expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
194
195
  end
195
196
  it "deletes the value when the value exists" do
196
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1 )
197
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1] )
197
198
  expect(@double_registry).to receive(:delete_value).with(keyname, testval1)
198
199
  @provider.load_current_resource
199
200
  @provider.action_delete
200
201
  end
201
202
  it "deletes the value when the value exists, but the type is wrong" do
202
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_type )
203
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_type] )
203
204
  expect(@double_registry).to receive(:delete_value).with(keyname, testval1)
204
205
  @provider.load_current_resource
205
206
  @provider.action_delete
206
207
  end
207
208
  it "deletes the value when the value exists, but the data is wrong" do
208
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1_wrong_data )
209
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1_wrong_data] )
209
210
  expect(@double_registry).to receive(:delete_value).with(keyname, testval1)
210
211
  @provider.load_current_resource
211
212
  @provider.action_delete
212
213
  end
213
214
  it "does not delete the value when the value does not exist" do
214
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval2 )
215
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval2] )
215
216
  expect(@double_registry).not_to receive(:delete_value)
216
217
  @provider.load_current_resource
217
218
  @provider.action_delete
@@ -235,7 +236,7 @@ shared_examples_for "a registry key" do
235
236
  expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
236
237
  end
237
238
  it "deletes the key" do
238
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( testval1 )
239
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [testval1] )
239
240
  expect(@double_registry).to receive(:delete_key).with(keyname, false)
240
241
  @provider.load_current_resource
241
242
  @provider.action_delete_key
@@ -303,7 +304,7 @@ describe Chef::Provider::RegistryKey do
303
304
  end
304
305
 
305
306
  it "does not make a change for datatype of data value differing" do
306
- expect(@double_registry).to receive(:get_values).with(keyname).and_return( dword_passed_as_integer )
307
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( [dword_passed_as_integer] )
307
308
  expect(@double_registry).not_to receive(:set_value)
308
309
  @provider.load_current_resource
309
310
  @provider.action_create
@@ -35,6 +35,12 @@ describe Chef::Util::Powershell::PSCredential do
35
35
  end
36
36
  end
37
37
 
38
+ context "when inspect is called" do
39
+ it "should not contain the password" do
40
+ expect(ps_credential.inspect).not_to match(/#{password}/)
41
+ end
42
+ end
43
+
38
44
  context "when to_text is called" do
39
45
  it "should not contain the password" do
40
46
  allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.6.2
4
+ version: 18.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 18.6.2
19
+ version: 18.7.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 18.6.2
26
+ version: 18.7.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 18.6.2
33
+ version: 18.7.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 18.6.2
40
+ version: 18.7.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -62,16 +62,16 @@ dependencies:
62
62
  name: train-winrm
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.2.5
67
+ version: 0.2.17
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.2.5
74
+ version: 0.2.17
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: train-rest
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -133,9 +133,9 @@ dependencies:
133
133
  - - ">="
134
134
  - !ruby/object:Gem::Version
135
135
  version: 2.0.3
136
- - - "<"
136
+ - - "<="
137
137
  - !ruby/object:Gem::Version
138
- version: '4.0'
138
+ version: 3.1.1
139
139
  type: :runtime
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
@@ -143,9 +143,9 @@ dependencies:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: 2.0.3
146
- - - "<"
146
+ - - "<="
147
147
  - !ruby/object:Gem::Version
148
- version: '4.0'
148
+ version: 3.1.1
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: mixlib-authentication
151
151
  requirement: !ruby/object:Gem::Requirement
@@ -374,14 +374,14 @@ dependencies:
374
374
  requirements:
375
375
  - - ">="
376
376
  - !ruby/object:Gem::Version
377
- version: 14.0.11
377
+ version: 15.0.17
378
378
  type: :runtime
379
379
  prerelease: false
380
380
  version_requirements: !ruby/object:Gem::Requirement
381
381
  requirements:
382
382
  - - ">="
383
383
  - !ruby/object:Gem::Version
384
- version: 14.0.11
384
+ version: 15.0.17
385
385
  - !ruby/object:Gem::Dependency
386
386
  name: chef-vault
387
387
  requirement: !ruby/object:Gem::Requirement
@@ -1745,12 +1745,12 @@ files:
1745
1745
  - spec/functional/assets/mytest-1.0-1.noarch.rpm
1746
1746
  - spec/functional/assets/mytest-2.0-1.noarch.rpm
1747
1747
  - spec/functional/assets/testchefsubsys
1748
- - spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2
1749
- - spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
1750
- - spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2
1751
- - spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
1752
- - spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
1753
- - spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
1748
+ - spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2
1749
+ - spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz
1750
+ - spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2
1751
+ - spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz
1752
+ - spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2
1753
+ - spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz
1754
1754
  - spec/functional/assets/yumrepo-empty/repodata/repomd.xml
1755
1755
  - spec/functional/assets/yumrepo/chef_rpm-1.10-1.aarch64.rpm
1756
1756
  - spec/functional/assets/yumrepo/chef_rpm-1.10-1.i686.rpm