chef 18.2.7-x64-mingw-ucrt → 18.3.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/chef-universal-mingw-ucrt.gemspec +1 -1
  3. data/lib/chef/application/base.rb +2 -0
  4. data/lib/chef/client.rb +2 -2
  5. data/lib/chef/cookbook/synchronizer.rb +20 -2
  6. data/lib/chef/cookbook_version.rb +1 -1
  7. data/lib/chef/http/ssl_policies.rb +2 -2
  8. data/lib/chef/mixin/homebrew_user.rb +12 -5
  9. data/lib/chef/monkey_patches/net-http.rb +127 -0
  10. data/lib/chef/node/attribute_collections.rb +8 -0
  11. data/lib/chef/node/immutable_collections.rb +5 -2
  12. data/lib/chef/node/mixin/state_tracking.rb +1 -1
  13. data/lib/chef/provider/launchd.rb +1 -1
  14. data/lib/chef/provider/mount/linux.rb +1 -1
  15. data/lib/chef/provider/mount/mount.rb +5 -5
  16. data/lib/chef/provider/package/chocolatey.rb +18 -1
  17. data/lib/chef/provider/package/zypper.rb +1 -0
  18. data/lib/chef/provider/remote_file/http.rb +1 -1
  19. data/lib/chef/provider/yum_repository.rb +1 -1
  20. data/lib/chef/resource/apt_repository.rb +25 -6
  21. data/lib/chef/resource/homebrew_cask.rb +6 -7
  22. data/lib/chef/resource/homebrew_package.rb +1 -1
  23. data/lib/chef/resource/homebrew_tap.rb +5 -5
  24. data/lib/chef/resource/launchd.rb +5 -1
  25. data/lib/chef/resource/windows_certificate.rb +1 -1
  26. data/lib/chef/resource/windows_security_policy.rb +2 -2
  27. data/lib/chef/resource.rb +11 -1
  28. data/lib/chef/version.rb +1 -1
  29. data/lib/chef/win32/security.rb +7 -1
  30. data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
  31. data/spec/functional/resource/execute_spec.rb +1 -1
  32. data/spec/functional/resource/windows_certificate_spec.rb +25 -0
  33. data/spec/unit/client_spec.rb +2 -2
  34. data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
  35. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  36. data/spec/unit/provider/apt_repository_spec.rb +17 -7
  37. data/spec/unit/provider/launchd_spec.rb +2 -2
  38. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  39. data/spec/unit/provider/mount/linux_spec.rb +6 -5
  40. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  41. data/spec/unit/provider/package/chocolatey_spec.rb +19 -3
  42. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  43. data/spec/unit/provider/package/zypper_spec.rb +10 -0
  44. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  45. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  46. data/spec/unit/resource_spec.rb +86 -0
  47. metadata +13 -12
  48. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
  49. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
  50. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
  51. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
@@ -49,6 +49,10 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
49
49
  allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0, 2], timeout: timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
+ after(:each) do
53
+ described_class.instance_variable_set(:@get_choco_version, nil)
54
+ end
55
+
52
56
  def allow_remote_list(package_names, args = nil)
53
57
  remote_list_stdout = <<~EOF
54
58
  Chocolatey v0.9.9.11
@@ -61,9 +65,9 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
61
65
  remote_list_obj = double(stdout: remote_list_stdout)
62
66
  package_names.each do |pkg|
63
67
  if args
64
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
68
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
65
69
  else
66
- allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
70
+ allow(provider).to receive(:shell_out_compacted!).with(choco_exe, described_class.query_command, "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
67
71
  end
68
72
  end
69
73
  end
@@ -78,6 +82,18 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
78
82
  end
79
83
  end
80
84
 
85
+ describe "choco searches change with the version" do
86
+ it "Choco V1 uses List" do
87
+ allow(described_class).to receive(:get_choco_version).and_return("1.4.0")
88
+ expect(provider.query_command).to eql("list")
89
+ end
90
+
91
+ it "Choco V2 uses Search" do
92
+ allow(described_class).to receive(:get_choco_version).and_return("2.1.0")
93
+ expect(provider.query_command).to eql("search")
94
+ end
95
+ end
96
+
81
97
  describe "#candidate_version" do
82
98
  it "should set the candidate_version to the latest version when not pinning" do
83
99
  allow_remote_list(["git"])
@@ -150,7 +166,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
150
166
  new_resource.package_name("package-does-not-exist")
151
167
  new_resource.returns([0])
152
168
  allow(provider).to receive(:shell_out_compacted!)
153
- .with(choco_exe, "list", "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
169
+ .with(choco_exe, described_class.query_command, "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
154
170
  .and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
155
171
  expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
156
172
  end
@@ -41,7 +41,7 @@ describe Chef::Provider::Package::Rpm do
41
41
  let(:rpm_q_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) }
42
42
 
43
43
  before(:each) do
44
- allow(::File).to receive(:exist?).with("PLEASE STUB File.exists? EXACTLY").and_return(true)
44
+ allow(::File).to receive(:exist?).with("PLEASE STUB File.exist? EXACTLY").and_return(true)
45
45
 
46
46
  # Ensure all shell out usage is stubbed with exact arguments
47
47
  allow(provider).to receive(:shell_out_compacted!).with("PLEASE STUB YOUR SHELLOUT CALLS").and_return(nil)
@@ -412,7 +412,7 @@ describe Chef::Provider::Package::Rpm do
412
412
 
413
413
  let(:new_resource) do
414
414
  # When we pass a source in as the name, then #initialize in the
415
- # provider will call File.exists?. Because of the ordering in our
415
+ # provider will call File.exist?. Because of the ordering in our
416
416
  # let() bindings and such, we have to set the stub here and not in a
417
417
  # before block.
418
418
  allow(::File).to receive(:exist?).with(package_source).and_return(true)
@@ -491,4 +491,14 @@ describe Chef::Provider::Package::Zypper do
491
491
  provider.remove_package(%w{emacs vim}, ["1.0", "2.0"])
492
492
  end
493
493
  end
494
+
495
+ describe "resolve_available_version" do
496
+ it "should return correct version if multiple packages are shown" do
497
+ status = double(stdout: "S | Name | Type | Version | Arch | Repository\n---+--------------------------+---------+---------------------+--------+-------------------------------------------------------------\n | apache2-mod_wsgi | package | 4.7.1-150400.3.3.1 | x86_64 | Update repository with updates from SUSE Linux Enterprise 15\n | apache2-mod_wsgi | package | 4.7.1-150400.1.52 | x86_64 | Main Repository\ni+ | apache2-mod_wsgi-python3 | package | 4.5.18-150000.4.6.1 | x86_64 | Update repository with updates from SUSE Linux Enterprise 15\nv | apache2-mod_wsgi-python3 | package | 4.5.18-4.3.1 | x86_64 | Main Repository\n", exitstatus: 0)
498
+
499
+ allow(provider).to receive(:shell_out_compacted!).and_return(status)
500
+ result = provider.send(:resolve_available_version, "apache2-mod_wsgi-python3", nil)
501
+ expect(result).to eq("4.5.18-150000.4.6.1")
502
+ end
503
+ end
494
504
  end
@@ -251,7 +251,7 @@ describe Chef::Provider::RemoteFile::HTTP do
251
251
  end
252
252
 
253
253
  context "and the response has no Date or Last-Modified header" do
254
- let(:last_response) { { "date" => nil, "last_modified" => nil } }
254
+ let(:last_response) { { "date" => nil, "last-modified" => nil } }
255
255
  it "does not set an mtime in the result" do
256
256
  # RFC 2616 suggests that servers that do not set a Date header do not
257
257
  # have a reliable clock, so no use in making them deal with dates.
@@ -265,19 +265,19 @@ describe Chef::Provider::RemoteFile::HTTP do
265
265
  context "and the response has a Last-Modified header" do
266
266
  let(:last_response) do
267
267
  # Last-Modified should be preferred to Date if both are set
268
- { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => "Fri, 17 May 2013 11:11:11 GMT" }
268
+ { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last-modified" => "Fri, 17 May 2013 11:11:11 GMT" }
269
269
  end
270
270
 
271
271
  it "sets the mtime to the Last-Modified time in the response" do
272
272
  fetcher.fetch
273
273
  expect(cache_control_data.etag).to be_nil
274
- expect(cache_control_data.mtime).to eq(last_response["last_modified"])
274
+ expect(cache_control_data.mtime).to eq(last_response["last-modified"])
275
275
  end
276
276
  end
277
277
 
278
278
  context "and the response has a Date header but no Last-Modified header" do
279
279
  let(:last_response) do
280
- { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => nil }
280
+ { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last-modified" => nil }
281
281
  end
282
282
 
283
283
  it "sets the mtime to the Date in the response" do
@@ -68,6 +68,11 @@ describe Chef::Resource::AptRepository do
68
68
  expect(resource.key).to eql(["key1"])
69
69
  end
70
70
 
71
+ it "allows setting options to a String and coerces it to an Array" do
72
+ resource.options = "by-hash=no"
73
+ expect(resource.options).to eql(["by-hash=no"])
74
+ end
75
+
71
76
  it "fails if the user provides a repo_name with a forward slash" do
72
77
  expect { resource.repo_name "foo/bar" }.to raise_error(ArgumentError)
73
78
  end
@@ -803,6 +803,92 @@ describe Chef::Resource do
803
803
  end
804
804
  end
805
805
 
806
+ describe "when using resource partials" do
807
+ let(:resource_using_core_partial) do
808
+ Class.new(Chef::Resource) do
809
+ use "core::core_partial"
810
+ end
811
+ end
812
+
813
+ let(:resource_using_cookbook_partial) do
814
+ Class.new(Chef::Resource) do
815
+ use "my_local_partial"
816
+ end
817
+ end
818
+
819
+ let(:resource_using_nested_partials) do
820
+ FakeCaller = Struct.new(:label, :path, keyword_init: true)
821
+ NonDynamicResource = Chef::Resource.dup
822
+
823
+ # Fake a caller_locations array, as RSpec uses a different execution path
824
+ NonDynamicResource.define_singleton_method(:caller_locations) do
825
+ [
826
+ FakeCaller.new(label: "use", path: File.join(__dir__, "resource.rb")),
827
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
828
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level3_partial.rb")),
829
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
830
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level2_partial.rb")),
831
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
832
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level1_partial.rb")),
833
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
834
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level0_partial.rb")),
835
+ ]
836
+ end
837
+
838
+ Class.new(NonDynamicResource) do
839
+ use "level3_partial"
840
+ end
841
+ end
842
+
843
+ it "correcly includes a core partial" do
844
+ expected_path = File.expand_path(File.join(__dir__, "../..", "lib/chef", "resource/_core_partial.rb"))
845
+ partial = "property :addon_property, default: true"
846
+
847
+ expect(IO).to receive(:read).with(expected_path).and_return(partial)
848
+ expect(resource_using_core_partial.properties.keys).to include(:addon_property)
849
+ end
850
+
851
+ it "correctly includes a cookbook partial" do
852
+ expected_path = File.expand_path(File.join(__dir__, "_my_local_partial.rb"))
853
+ partial = "property :addon_property, default: true"
854
+
855
+ expect(IO).to receive(:read).with(expected_path).and_return(partial)
856
+ expect(resource_using_cookbook_partial.properties.keys).to include(:addon_property)
857
+ end
858
+
859
+ it "correctly includes nested partials" do
860
+ level0_path = File.expand_path(File.join(__dir__, "_level0_partial.rb"))
861
+ level0_partial = "property :level0_property, default: true"
862
+ expect(IO).to receive(:read).with(level0_path).and_return(level0_partial)
863
+
864
+ level1_path = File.expand_path(File.join(__dir__, "_level1_partial.rb"))
865
+ level1_partial = <<-EOF
866
+ use 'level0_partial'
867
+ property :level1_property, default: true
868
+ EOF
869
+ expect(IO).to receive(:read).with(level1_path).and_return(level1_partial)
870
+
871
+ level2_path = File.expand_path(File.join(__dir__, "_level2_partial.rb"))
872
+ level2_partial = <<-EOF
873
+ use 'level1_partial'
874
+ property :level2_property, default: true
875
+ EOF
876
+ expect(IO).to receive(:read).with(level2_path).and_return(level2_partial)
877
+
878
+ level3_path = File.expand_path(File.join(__dir__, "_level3_partial.rb"))
879
+ level3_partial = <<-EOF
880
+ use 'level2_partial'
881
+ property :level3_property, default: true
882
+ EOF
883
+ expect(IO).to receive(:read).with(level3_path).and_return(level3_partial)
884
+
885
+ expect(resource_using_nested_partials.properties.keys).to include(:level0_property)
886
+ expect(resource_using_nested_partials.properties.keys).to include(:level1_property)
887
+ expect(resource_using_nested_partials.properties.keys).to include(:level2_property)
888
+ expect(resource_using_nested_partials.properties.keys).to include(:level3_property)
889
+ end
890
+ end
891
+
806
892
  describe "should_skip?" do
807
893
  before do
808
894
  resource = Chef::Resource::Cat.new("sugar", run_context)
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.2.7
4
+ version: 18.3.0
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-04 00:00:00.000000000 Z
11
+ date: 2023-08-25 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.2.7
19
+ version: 18.3.0
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.2.7
26
+ version: 18.3.0
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.2.7
33
+ version: 18.3.0
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.2.7
40
+ version: 18.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -710,14 +710,14 @@ dependencies:
710
710
  requirements:
711
711
  - - "~>"
712
712
  - !ruby/object:Gem::Version
713
- version: 18.0.0
713
+ version: 18.1.0
714
714
  type: :runtime
715
715
  prerelease: false
716
716
  version_requirements: !ruby/object:Gem::Requirement
717
717
  requirements:
718
718
  - - "~>"
719
719
  - !ruby/object:Gem::Version
720
- version: 18.0.0
720
+ version: 18.1.0
721
721
  description: A systems integration framework, built to bring the benefits of configuration
722
722
  management to your entire infrastructure.
723
723
  email: adam@chef.io
@@ -1650,6 +1650,7 @@ files:
1650
1650
  - lib/chef/mixin/windows_env_helper.rb
1651
1651
  - lib/chef/mixin/xml_escape.rb
1652
1652
  - lib/chef/mixins.rb
1653
+ - lib/chef/monkey_patches/net-http.rb
1653
1654
  - lib/chef/monkey_patches/webrick-utils.rb
1654
1655
  - lib/chef/monkey_patches/win32/registry.rb
1655
1656
  - lib/chef/monologger.rb
@@ -2506,10 +2507,10 @@ files:
2506
2507
  - spec/functional/assets/PkgA.1.0.0.0.bff
2507
2508
  - spec/functional/assets/PkgA.2.0.0.0.bff
2508
2509
  - spec/functional/assets/chefinittest
2509
- - spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg
2510
- - spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
2511
- - spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg
2512
- - spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg
2510
+ - spec/functional/assets/chocolatey_feed/test-A.1.0.0.nupkg
2511
+ - spec/functional/assets/chocolatey_feed/test-A.1.5.0.nupkg
2512
+ - spec/functional/assets/chocolatey_feed/test-A.2.0.0.nupkg
2513
+ - spec/functional/assets/chocolatey_feed/test-B.1.0.0.nupkg
2513
2514
  - spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
2514
2515
  - spec/functional/assets/dummy-2-0.aix6.1.noarch.rpm
2515
2516
  - spec/functional/assets/inittest