summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-01-12 12:11:37 -0800
committerGitHub <noreply@github.com>2021-01-12 12:11:37 -0800
commita9fe47503a49f013b428a128ef38f2279e5d7b80 (patch)
tree015d70f321eb1100df317af6926f2e8d3475f65e
parent474bea9632c6863aa05bc3689f8d4d8d54e72c13 (diff)
parent4fa2a2e7e18aa3e671a1afbdb990ace908475a6c (diff)
downloadchef-a9fe47503a49f013b428a128ef38f2279e5d7b80.tar.gz
Merge pull request #10864 from chef/lcg/fix-auditcb-checker
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/compliance/runner.rb8
-rw-r--r--spec/unit/compliance/runner_spec.rb11
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/chef/compliance/runner.rb b/lib/chef/compliance/runner.rb
index 86344367c2..5b7049e435 100644
--- a/lib/chef/compliance/runner.rb
+++ b/lib/chef/compliance/runner.rb
@@ -11,12 +11,12 @@ class Chef
class Runner < EventDispatch::Base
extend Forwardable
- attr_accessor :run_id, :recipes
+ attr_accessor :run_id
attr_reader :node
def_delegators :node, :logger
def enabled?
- audit_cookbook_present = recipes.include?("audit::default")
+ audit_cookbook_present = node["recipes"].include?("audit::default")
logger.info("#{self.class}##{__method__}: #{Inspec::Dist::PRODUCT_NAME} profiles? #{inspec_profiles.any?}")
logger.info("#{self.class}##{__method__}: audit cookbook? #{audit_cookbook_present}")
@@ -37,10 +37,6 @@ class Chef
self.run_id = run_status.run_id
end
- def run_list_expanded(run_list_expansion)
- self.recipes = run_list_expansion.recipes
- end
-
def run_completed(_node, _run_status)
return unless enabled?
diff --git a/spec/unit/compliance/runner_spec.rb b/spec/unit/compliance/runner_spec.rb
index d4d2ba563f..26c7008ccd 100644
--- a/spec/unit/compliance/runner_spec.rb
+++ b/spec/unit/compliance/runner_spec.rb
@@ -8,41 +8,40 @@ describe Chef::Compliance::Runner do
described_class.new.tap do |r|
r.node = node
r.run_id = "my_run_id"
- r.recipes = []
end
end
describe "#enabled?" do
it "is true if the node attributes have audit profiles and the audit cookbook is not present" do
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
- runner.recipes = %w{ fancy_cookbook::fanciness tacobell::nachos }
+ node.automatic["recipes"] = %w{ fancy_cookbook::fanciness tacobell::nachos }
expect(runner).to be_enabled
end
it "is false if the node attributes have audit profiles and the audit cookbook is present" do
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
- runner.recipes = %w{ audit::default fancy_cookbook::fanciness tacobell::nachos }
+ node.automatic["recipes"] = %w{ audit::default fancy_cookbook::fanciness tacobell::nachos }
expect(runner).not_to be_enabled
end
it "is false if the node attributes do not have audit profiles and the audit cookbook is not present" do
node.normal["audit"]["profiles"] = {}
- runner.recipes = %w{ fancy_cookbook::fanciness tacobell::nachos }
+ node.automatic["recipes"] = %w{ fancy_cookbook::fanciness tacobell::nachos }
expect(runner).not_to be_enabled
end
it "is false if the node attributes do not have audit profiles and the audit cookbook is present" do
node.normal["audit"]["profiles"] = {}
- runner.recipes = %w{ audit::default fancy_cookbook::fanciness tacobell::nachos }
+ node.automatic["recipes"] = %w{ audit::default fancy_cookbook::fanciness tacobell::nachos }
expect(runner).not_to be_enabled
end
it "is false if the node attributes do not have audit attributes and the audit cookbook is not present" do
- runner.recipes = %w{ fancy_cookbook::fanciness tacobell::nachos }
+ node.automatic["recipes"] = %w{ fancy_cookbook::fanciness tacobell::nachos }
expect(runner).not_to be_enabled
end
end