diff options
author | Tim Smith <tsmith@chef.io> | 2021-04-02 14:13:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 14:13:14 -0700 |
commit | a3dea5bd3a50bff8d651f6ec7e8d47c18bd20da4 (patch) | |
tree | b9d3bf5004f30e4fca719a0722dce37812b7a7a1 | |
parent | 287076d99649a107370719850df8ef667220c2d5 (diff) | |
parent | 28b72c7b232ed273311e12b934f712e312a55437 (diff) | |
download | chef-a3dea5bd3a50bff8d651f6ec7e8d47c18bd20da4.tar.gz |
Merge pull request #11290 from chef/mp/chef-11289
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/compliance/runner.rb | 2 | ||||
-rw-r--r-- | spec/unit/compliance/runner_spec.rb | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/compliance/runner.rb b/lib/chef/compliance/runner.rb index 50b8ff561a..c083109875 100644 --- a/lib/chef/compliance/runner.rb +++ b/lib/chef/compliance/runner.rb @@ -17,6 +17,8 @@ class Chef def_delegators :node, :logger def enabled? + return false if @node.nil? + # Did we parse the libraries file from the audit cookbook? This class dates back to when Chef Automate was # renamed from Chef Visibility in 2017, so should capture all modern versions of the audit cookbook. audit_cookbook_present = defined?(::Reporter::ChefAutomate) diff --git a/spec/unit/compliance/runner_spec.rb b/spec/unit/compliance/runner_spec.rb index 66e21eb12e..c100029a2c 100644 --- a/spec/unit/compliance/runner_spec.rb +++ b/spec/unit/compliance/runner_spec.rb @@ -12,6 +12,12 @@ describe Chef::Compliance::Runner do end describe "#enabled?" do + context "when the node is not available" do + let(:runner) { described_class.new } + it "is false because it needs the node to answer that question" do + expect(runner).not_to be_enabled + end + end it "is true if the node attributes have audit profiles and the audit cookbook is not present, and the compliance mode attribute is nil" do node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" } |