chef 17.2.29-universal-mingw32 → 17.3.48-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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/chef.gemspec +1 -0
  4. data/lib/chef/client.rb +1 -1
  5. data/lib/chef/data_bag.rb +1 -2
  6. data/lib/chef/data_bag_item.rb +1 -2
  7. data/lib/chef/deprecated.rb +10 -4
  8. data/lib/chef/dsl.rb +1 -0
  9. data/lib/chef/dsl/render_helpers.rb +44 -0
  10. data/lib/chef/dsl/secret.rb +64 -0
  11. data/lib/chef/dsl/toml.rb +116 -0
  12. data/lib/chef/dsl/universal.rb +5 -0
  13. data/lib/chef/exceptions.rb +22 -0
  14. data/lib/chef/handler/slow_report.rb +1 -1
  15. data/lib/chef/json_compat.rb +1 -1
  16. data/lib/chef/policy_builder/policyfile.rb +88 -45
  17. data/lib/chef/provider/file.rb +2 -2
  18. data/lib/chef/provider/lwrp_base.rb +1 -1
  19. data/lib/chef/provider/package/habitat.rb +168 -0
  20. data/lib/chef/provider/package/powershell.rb +5 -0
  21. data/lib/chef/providers.rb +1 -0
  22. data/lib/chef/resource/chef_client_config.rb +7 -2
  23. data/lib/chef/resource/chef_client_cron.rb +1 -1
  24. data/lib/chef/resource/chef_client_launchd.rb +1 -1
  25. data/lib/chef/resource/chef_client_scheduled_task.rb +1 -1
  26. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
  27. data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
  28. data/lib/chef/resource/chef_vault_secret.rb +2 -2
  29. data/lib/chef/resource/dsc_resource.rb +1 -1
  30. data/lib/chef/resource/execute.rb +3 -3
  31. data/lib/chef/resource/gem_package.rb +2 -1
  32. data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
  33. data/lib/chef/resource/habitat/habitat_package.rb +129 -0
  34. data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
  35. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
  36. data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
  37. data/lib/chef/resource/habitat_config.rb +107 -0
  38. data/lib/chef/resource/habitat_install.rb +247 -0
  39. data/lib/chef/resource/habitat_service.rb +451 -0
  40. data/lib/chef/resource/habitat_user_toml.rb +92 -0
  41. data/lib/chef/resource/lwrp_base.rb +1 -1
  42. data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
  43. data/lib/chef/resource/support/client.erb +8 -1
  44. data/lib/chef/resource/support/sup.toml.erb +179 -0
  45. data/lib/chef/resource/windows_defender.rb +163 -0
  46. data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
  47. data/lib/chef/resource/windows_printer.rb +78 -44
  48. data/lib/chef/resource/windows_printer_port.rb +1 -1
  49. data/lib/chef/resource/windows_update_settings.rb +259 -0
  50. data/lib/chef/resources.rb +12 -1
  51. data/lib/chef/secret_fetcher.rb +54 -0
  52. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +53 -0
  53. data/lib/chef/secret_fetcher/azure_key_vault.rb +56 -0
  54. data/lib/chef/secret_fetcher/base.rb +72 -0
  55. data/lib/chef/secret_fetcher/example.rb +46 -0
  56. data/lib/chef/version.rb +1 -1
  57. data/spec/functional/mixin/from_file_spec.rb +1 -1
  58. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  59. data/spec/integration/recipes/resource_action_spec.rb +4 -4
  60. data/spec/support/shared/unit/provider/file.rb +2 -8
  61. data/spec/unit/data_bag_item_spec.rb +2 -2
  62. data/spec/unit/data_bag_spec.rb +1 -1
  63. data/spec/unit/dsl/render_helpers_spec.rb +102 -0
  64. data/spec/unit/dsl/secret_spec.rb +65 -0
  65. data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
  66. data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
  67. data/spec/unit/provider/apt_update_spec.rb +3 -1
  68. data/spec/unit/provider/mount/aix_spec.rb +1 -1
  69. data/spec/unit/provider/package/powershell_spec.rb +74 -12
  70. data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
  71. data/spec/unit/resource/windows_defender_spec.rb +71 -0
  72. data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
  73. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +63 -0
  74. data/spec/unit/secret_fetcher_spec.rb +82 -0
  75. metadata +51 -7
@@ -73,11 +73,11 @@ describe Chef::DataBagItem do
73
73
  end
74
74
 
75
75
  it "should accept alphanum.alphanum for the id" do
76
- expect { data_bag_item.raw_data = { "id" => "foo.bar" } }.to raise_error(ArgumentError)
76
+ expect { data_bag_item.raw_data = { "id" => "foo.bar" } }.not_to raise_error
77
77
  end
78
78
 
79
79
  it "should accept .alphanum for the id" do
80
- expect { data_bag_item.raw_data = { "id" => ".bozo" } }.to raise_error(ArgumentError)
80
+ expect { data_bag_item.raw_data = { "id" => ".bozo" } }.not_to raise_error
81
81
  end
82
82
 
83
83
  it "should raise an exception if the id contains anything but alphanum/-/_" do
@@ -49,7 +49,7 @@ describe Chef::DataBag do
49
49
  expect { @data_bag.name({}) }.to raise_error(ArgumentError)
50
50
  end
51
51
 
52
- ["-", "_", "1"].each do |char|
52
+ [ ".", "-", "_", "1"].each do |char|
53
53
  it "should allow a '#{char}' character in the data bag name" do
54
54
  expect(@data_bag.name("clown#{char}clown")).to eq("clown#{char}clown")
55
55
  end
@@ -0,0 +1,102 @@
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 "chef/dsl/render_helpers"
20
+
21
+ describe Chef::DSL::RenderHelpers do
22
+
23
+ hash = {
24
+ "golf": "hotel",
25
+ "kilo": %w{lima mike},
26
+ "india": {
27
+ "juliett": "blue",
28
+ },
29
+ "alpha": {
30
+ "charlie": true,
31
+ "bravo": 10,
32
+ },
33
+ "echo": "foxtrot",
34
+ }
35
+
36
+ context "render_json" do
37
+ json = Chef::DSL::RenderHelpers.render_json(hash)
38
+ describe "JSON content" do
39
+ it "expected JSON output" do
40
+ expected = <<-EXPECTED
41
+ {
42
+ "golf": "hotel",
43
+ "kilo": [
44
+ "lima",
45
+ "mike"
46
+ ],
47
+ "india": {
48
+ "juliett": "blue"
49
+ },
50
+ "alpha": {
51
+ "charlie": true,
52
+ "bravo": 10
53
+ },
54
+ "echo": "foxtrot"
55
+ }
56
+ EXPECTED
57
+ expect(json).to eq(expected)
58
+ end
59
+ end
60
+ end
61
+
62
+ context "render_toml" do
63
+ toml = Chef::DSL::RenderHelpers.render_toml(hash)
64
+ describe "TOML content" do
65
+ it "expected TOML output" do
66
+ expected = <<-EXPECTED
67
+ echo = "foxtrot"
68
+ golf = "hotel"
69
+ kilo = ["lima", "mike"]
70
+ [alpha]
71
+ bravo = 10
72
+ charlie = true
73
+ [india]
74
+ juliett = "blue"
75
+ EXPECTED
76
+ expect(toml).to eq(expected)
77
+ end
78
+ end
79
+ end
80
+
81
+ context "render_yaml" do
82
+ yaml = Chef::DSL::RenderHelpers.render_yaml(hash)
83
+ describe "YAML content" do
84
+ it "expected YAML output" do
85
+ expected = <<-EXPECTED
86
+ ---
87
+ golf: hotel
88
+ kilo:
89
+ - lima
90
+ - mike
91
+ india:
92
+ juliett: blue
93
+ alpha:
94
+ charlie: true
95
+ bravo: 10
96
+ echo: foxtrot
97
+ EXPECTED
98
+ expect(yaml).to eq(expected)
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Author:: Marc Paradise <marc@chef.io>
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+ require "chef/dsl/secret"
21
+ require "chef/secret_fetcher/base"
22
+ class SecretDSLTester
23
+ include Chef::DSL::Secret
24
+ end
25
+
26
+ class SecretFetcherImpl < Chef::SecretFetcher::Base
27
+ def do_fetch(name, version)
28
+ name
29
+ end
30
+ end
31
+
32
+ describe Chef::DSL::Secret do
33
+ let(:dsl) { SecretDSLTester.new }
34
+ it "responds to 'secret'" do
35
+ expect(dsl.respond_to?(:secret)).to eq true
36
+ end
37
+
38
+ 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)
41
+ expect(substitute_fetcher).to receive(:fetch).with("key1", nil)
42
+ dsl.secret(name: "key1", service: :example, config: {})
43
+ end
44
+
45
+ it "resolves a secret when using the example fetcher" do
46
+ secret_value = dsl.secret(name: "test1", service: :example, config: { "test1" => "secret value" })
47
+ expect(secret_value).to eq "secret value"
48
+ end
49
+
50
+ context "when used within a resource" do
51
+ let(:run_context) {
52
+ Chef::RunContext.new(Chef::Node.new,
53
+ Chef::CookbookCollection.new(Chef::CookbookLoader.new(File.join(CHEF_SPEC_DATA, "cookbooks"))),
54
+ Chef::EventDispatch::Dispatcher.new)
55
+ }
56
+
57
+ it "marks that resource as 'sensitive'" do
58
+ recipe = Chef::Recipe.new("secrets", "test", run_context)
59
+ recipe.zen_master "secret_test" do
60
+ peace secret(name: "test1", service: :example, config: { "test1" => true })
61
+ end
62
+ expect(run_context.resource_collection.lookup("zen_master[secret_test]").sensitive).to eql(true)
63
+ end
64
+ end
65
+ end
@@ -55,11 +55,6 @@ describe Chef::PolicyBuilder::Dynamic do
55
55
  expect(policy_builder).to respond_to(:load_node)
56
56
  end
57
57
 
58
- it "forwards #original_runlist" do
59
- expect(implementation).to receive(:original_runlist)
60
- policy_builder.original_runlist
61
- end
62
-
63
58
  it "forwards #run_context" do
64
59
  expect(implementation).to receive(:run_context)
65
60
  policy_builder.run_context
@@ -72,40 +72,40 @@ describe Chef::PolicyBuilder::Policyfile do
72
72
 
73
73
  let(:policyfile_default_attributes) do
74
74
  {
75
- "policyfile_default_attr" => "policyfile_default_value",
76
- "top_level_attr" => "hat",
77
- "baseline_attr" => {
78
- "one" => 1,
79
- "two" => 2,
80
- "deep" => {
81
- "three" => 3,
82
- "four" => [4],
83
- "five" => [5],
84
- },
75
+ "policyfile_default_attr" => "policyfile_default_value",
76
+ "top_level_attr" => "hat",
77
+ "baseline_attr" => {
78
+ "one" => 1,
79
+ "two" => 2,
80
+ "deep" => {
81
+ "three" => 3,
82
+ "four" => [4],
83
+ "five" => [5],
85
84
  },
86
- "policy_group_value" => {
87
- "baseline_attr" => {
88
- "one" => 111,
89
- },
85
+ },
86
+ "policy_group_value" => {
87
+ "baseline_attr" => {
88
+ "one" => 111,
90
89
  },
91
- }
90
+ },
91
+ }
92
92
  end
93
93
 
94
94
  let(:policyfile_override_attributes) do
95
95
  {
96
- "policyfile_override_attr" => "policyfile_override_value",
97
- "baseline_attr" => {
98
- "deep" => {
99
- "three" => 333 },
100
- },
101
- "policy_group_value" => {
102
- "top_level_attr" => "cat",
103
- "baseline_attr" => {
104
- "deep" => {
105
- "four" => [444],
106
- },
107
- },
108
- },
96
+ "policyfile_override_attr" => "policyfile_override_value",
97
+ "baseline_attr" => {
98
+ "deep" => {
99
+ "three" => 333 },
100
+ },
101
+ "policy_group_value" => {
102
+ "top_level_attr" => "cat",
103
+ "baseline_attr" => {
104
+ "deep" => {
105
+ "four" => [444],
106
+ },
107
+ },
108
+ },
109
109
  }
110
110
  end
111
111
 
@@ -146,10 +146,6 @@ describe Chef::PolicyBuilder::Policyfile do
146
146
  Chef::PolicyBuilder::Policyfile.new(node_name, ohai_data, json_attribs, override_runlist, events)
147
147
  end
148
148
 
149
- it "always gives `false` for #temporary_policy?" do
150
- expect(initialize_pb.temporary_policy?).to be_falsey
151
- end
152
-
153
149
  context "chef-solo" do
154
150
  before { Chef::Config[:solo_legacy_mode] = true }
155
151
 
@@ -161,16 +157,8 @@ describe Chef::PolicyBuilder::Policyfile do
161
157
  context "when given an override run_list" do
162
158
  let(:override_runlist) { "recipe[foo],recipe[bar]" }
163
159
 
164
- it "errors on create" do
165
- expect { initialize_pb }.to raise_error(err_namespace::UnsupportedFeature)
166
- end
167
- end
168
-
169
- context "when json_attribs contains a run_list" do
170
- let(:json_attribs) { { "run_list" => [] } }
171
-
172
- it "errors on create" do
173
- expect { initialize_pb }.to raise_error(err_namespace::UnsupportedFeature)
160
+ it "does not error" do
161
+ expect { initialize_pb }.not_to raise_error
174
162
  end
175
163
  end
176
164
 
@@ -206,7 +194,7 @@ describe Chef::PolicyBuilder::Policyfile do
206
194
  end
207
195
 
208
196
  before do
209
- Chef::Config[:policy_document_native_api] = false
197
+ Chef::Config[:policy_document_native_api] = true
210
198
  Chef::Config[:deployment_group] = "example-policy-stage"
211
199
  allow(policy_builder).to receive(:api_service).and_return(api_service)
212
200
  end
@@ -214,6 +202,8 @@ describe Chef::PolicyBuilder::Policyfile do
214
202
  describe "when using compatibility mode (policy_document_native_api == false)" do
215
203
 
216
204
  before do
205
+ Chef::Config[:policy_document_native_api] = false
206
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
217
207
  Chef::Config[:deployment_group] = "example-policy-stage"
218
208
  end
219
209
 
@@ -323,7 +313,7 @@ describe Chef::PolicyBuilder::Policyfile do
323
313
  "example2::server@4.2.0 (feab40e)",
324
314
  ]
325
315
 
326
- expect(policy_builder.run_list_with_versions_for_display).to eq(expected)
316
+ expect(policy_builder.run_list_with_versions_for_display(policy_builder.run_list)).to eq(expected)
327
317
  end
328
318
 
329
319
  it "generates a RunListExpansion-alike object for feeding to the CookbookCompiler" do
@@ -339,15 +329,19 @@ describe Chef::PolicyBuilder::Policyfile do
339
329
  end
340
330
 
341
331
  describe "validating the Policyfile.lock" do
332
+ before do
333
+ Chef::Config[:policy_group] = "policy-stage"
334
+ Chef::Config[:policy_name] = "example"
335
+ end
342
336
 
343
337
  it "errors if the policyfile json contains any non-recipe items" do
344
338
  parsed_policyfile_json["run_list"] = ["role[foo]"]
345
339
  expect { policy_builder.validate_policyfile }.to raise_error(err_namespace::PolicyfileError)
346
340
  end
347
341
 
348
- it "errors if the policyfile json contains non-fully qualified recipe items" do
342
+ it "does not error if the policyfile json contains non-fully qualified recipe items" do
349
343
  parsed_policyfile_json["run_list"] = ["recipe[foo]"]
350
- expect { policy_builder.validate_policyfile }.to raise_error(err_namespace::PolicyfileError)
344
+ expect { policy_builder.validate_policyfile }.not_to raise_error
351
345
  end
352
346
 
353
347
  it "errors if the policyfile doesn't have a run_list key" do
@@ -395,8 +389,8 @@ describe Chef::PolicyBuilder::Policyfile do
395
389
  {
396
390
  id: "_policy_node",
397
391
  run_list: [
398
- { type: "recipe", name: "test::default", skipped: false, version: nil },
399
- { type: "recipe", name: "test::other", skipped: false, version: nil },
392
+ { type: "recipe", name: "test::default", skipped: false, version: nil },
393
+ { type: "recipe", name: "test::other", skipped: false, version: nil },
400
394
  ],
401
395
  }
402
396
  end
@@ -577,11 +571,9 @@ describe Chef::PolicyBuilder::Policyfile do
577
571
  expect(node.automatic_attrs[:policy_name]).to eq("policy_name_from_node_json")
578
572
  expect(node.automatic_attrs[:policy_group]).to eq("policy_group_from_node_json")
579
573
  expect(node.automatic_attrs[:chef_environment]).to eq("policy_group_from_node_json")
580
-
581
574
  end
582
575
 
583
576
  end
584
-
585
577
  end
586
578
 
587
579
  it "resets default and override data" do
@@ -664,18 +656,29 @@ describe Chef::PolicyBuilder::Policyfile do
664
656
  expect(policy_builder.run_list).to eq([ "recipe[example1::default]" ])
665
657
  expected_expansion = Chef::PolicyBuilder::Policyfile::RunListExpansionIsh.new([ "example1::default" ], [])
666
658
  expect(policy_builder.run_list_expansion).to eq(expected_expansion)
667
- expect(policy_builder.run_list_with_versions_for_display).to eq(["example1::default@2.3.5 (168d210)"])
659
+ expect(policy_builder.run_list_with_versions_for_display(policy_builder.run_list)).to eq(["example1::default@2.3.5 (168d210)"])
668
660
  expect(node.run_list).to eq([ Chef::RunList::RunListItem.new("recipe[example1::default]") ])
669
661
  expect(node[:roles]).to eq( [] )
670
662
  expect(node[:recipes]).to eq( ["example1::default"] )
671
663
  end
672
664
 
673
- it "disables the cookbook cache cleaner" do
674
- expect(Chef::CookbookCacheCleaner.instance.skip_removal).to be(true)
675
- end
665
+ end
666
+ end
667
+
668
+ context "when an override run_list is given" do
669
+ let(:override_runlist) { [ "recipe[example2::server]" ] }
676
670
 
671
+ before do
672
+ policy_builder.build_node
677
673
  end
678
674
 
675
+ it "gives `true` for #temporary_policy?" do
676
+ expect(policy_builder.temporary_policy?).to be true
677
+ end
678
+
679
+ it "returns the override_runlist for the run_list" do
680
+ expect(policy_builder.run_list).to eql override_runlist
681
+ end
679
682
  end
680
683
 
681
684
  describe "hoisting attribute values" do
@@ -806,6 +809,10 @@ describe Chef::PolicyBuilder::Policyfile do
806
809
  context "when using compatibility mode (policy_document_native_api == false)" do
807
810
  let(:cookbook1_url) { "cookbooks/example1/#{example1_xyz_version}" }
808
811
  let(:cookbook2_url) { "cookbooks/example2/#{example2_xyz_version}" }
812
+ before do
813
+ Chef::Config[:policy_document_native_api] = false
814
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
815
+ end
809
816
 
810
817
  context "when the cookbooks don't exist on the server" do
811
818
  include_examples "fetching cookbooks when they don't exist"
@@ -826,6 +833,7 @@ describe Chef::PolicyBuilder::Policyfile do
826
833
  end
827
834
 
828
835
  include_examples "fetching cookbooks when they exist"
836
+
829
837
  end
830
838
  end
831
839
 
@@ -863,10 +871,90 @@ describe Chef::PolicyBuilder::Policyfile do
863
871
  end
864
872
 
865
873
  end
874
+ end
866
875
 
876
+ describe "selecting the run_list" do
877
+ let(:node) do
878
+ node = Chef::Node.new
879
+ node.name(node_name)
880
+ node
881
+ end
882
+
883
+ before do
884
+ allow(policy_builder).to receive(:node).and_return(node)
885
+ end
886
+
887
+ context "when json_attribs contains a run_list" do
888
+ let(:json_attribs) { { "run_list" => [ "recipe[something::default]" ] } }
889
+
890
+ it "reads the run_list from the json_attribs" do
891
+ expect(policy_builder.run_list).to eql(json_attribs["run_list"])
892
+ end
893
+
894
+ it "ignores the node.run_list" do
895
+ node.run_list.reset!("recipe[incorrect::incorrect]")
896
+ expect(policy_builder.run_list).to eql(json_attribs["run_list"])
897
+ end
898
+
899
+ it "ignores the node.run_list if the Chef::Config value is set" do
900
+ Chef::Config[:policy_persist_run_list] = true
901
+ node.run_list.reset!("recipe[incorrect::incorrect]")
902
+ expect(policy_builder.run_list).to eql(json_attribs["run_list"])
903
+ end
904
+ end
905
+
906
+ it "reads the run_list from the policyfile" do
907
+ expect(policy_builder.run_list).to eql(policyfile_run_list)
908
+ end
909
+
910
+ it "ignores the node.run_list by default" do
911
+ node.run_list.reset!("recipe[incorrect::incorrect]")
912
+ expect(policy_builder.run_list).to eql(policyfile_run_list)
913
+ end
914
+
915
+ it "uses the node.run_list if the Chef::Config value is set" do
916
+ Chef::Config[:policy_persist_run_list] = true
917
+ node.run_list.reset!("recipe[correct::default]")
918
+ expect(policy_builder.run_list).to eql(node.run_list)
919
+ end
920
+
921
+ it "does not use an empty node.run_list" do
922
+ Chef::Config[:policy_persist_run_list] = true
923
+ node.run_list.reset!
924
+ expect(policy_builder.run_list).to eql(policyfile_run_list)
925
+ end
926
+
927
+ context "with a valid named_run_list" do
928
+ let(:parsed_policyfile_json) do
929
+ basic_valid_policy_data.dup.tap do |p|
930
+ p["named_run_lists"] = {
931
+ "deploy-app" => [ "recipe[example1::default]" ],
932
+ }
933
+ end
934
+ end
935
+
936
+ it "uses the named_run_list over the policyfile" do
937
+ Chef::Config[:named_run_list] = "deploy-app"
938
+ expect(policy_builder.run_list).to eq([ "recipe[example1::default]" ])
939
+ end
940
+
941
+ it "is overridden if the run_list is persistent" do
942
+ Chef::Config[:named_run_list] = "deploy-app"
943
+ Chef::Config[:policy_persist_run_list] = true
944
+ node.run_list.reset!("recipe[correct::default]")
945
+ expect(policy_builder.run_list).to eql(node.run_list)
946
+ end
947
+
948
+ context "when json_attribs contains a run_list" do
949
+ let(:json_attribs) { { "run_list" => [ "recipe[something::default]" ] } }
950
+
951
+ it "overrides the named_run_list" do
952
+ expect(policy_builder.run_list).to eql(json_attribs["run_list"])
953
+ end
954
+ end
955
+
956
+ end
867
957
  end
868
958
  end
869
-
870
959
  end
871
-
872
960
  end