summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-03-17 14:57:57 -0700
committerGitHub <noreply@github.com>2021-03-17 14:57:57 -0700
commitf339cdcdc461cad2c4c100582829b9a277157589 (patch)
tree145e2331379306592831fe3280acb4e9e962df0d
parent5881879a660bb5a328935ea6022c0ffdb1127f33 (diff)
parent4d61a6e7a930af66c7e5c2032cfa4be85d703e14 (diff)
downloadchef-f339cdcdc461cad2c4c100582829b9a277157589.tar.gz
Merge pull request #11198 from chef/fix_specs_compliance
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--spec/integration/compliance/compliance_spec.rb3
-rw-r--r--spec/unit/compliance/runner_spec.rb23
2 files changed, 20 insertions, 6 deletions
diff --git a/spec/integration/compliance/compliance_spec.rb b/spec/integration/compliance/compliance_spec.rb
index 98776308de..effc9ab87d 100644
--- a/spec/integration/compliance/compliance_spec.rb
+++ b/spec/integration/compliance/compliance_spec.rb
@@ -4,7 +4,7 @@ require "support/shared/integration/integration_helper"
require "chef/mixin/shell_out"
require "chef-utils/dist"
-describe "chef-client with audit mode" do
+describe "chef-client with compliance phase" do
include IntegrationSupport
include Chef::Mixin::ShellOut
@@ -46,6 +46,7 @@ describe "chef-client with audit mode" do
file "attributes.json", <<~FILE
{
"audit": {
+ "compliance_phase": true,
"json_file": {
"location": "#{report_file}"
},
diff --git a/spec/unit/compliance/runner_spec.rb b/spec/unit/compliance/runner_spec.rb
index d166f467c8..66e21eb12e 100644
--- a/spec/unit/compliance/runner_spec.rb
+++ b/spec/unit/compliance/runner_spec.rb
@@ -13,8 +13,16 @@ describe Chef::Compliance::Runner do
describe "#enabled?" do
- it "is true if the node attributes have audit profiles and the audit cookbook is not present" do
+ 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" }
+ node.normal["audit"]["compliance_phase"] = nil
+
+ expect(runner).to be_enabled
+ end
+
+ it "is true if the node attributes have audit profiles and the audit cookbook is not present, and the compliance mode attribute is true" do
+ node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
+ node.normal["audit"]["compliance_phase"] = true
expect(runner).to be_enabled
end
@@ -26,9 +34,10 @@ describe Chef::Compliance::Runner do
expect(runner).not_to be_enabled
end
- it "is false if the node attributes have audit profiles and the audit cookbook is present" do
+ it "is false if the node attributes have audit profiles and the audit cookbook is present, and the complince mode attribute is nil" do
stub_const("::Reporter::ChefAutomate", true)
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
+ node.normal["audit"]["compliance_phase"] = nil
expect(runner).not_to be_enabled
end
@@ -41,21 +50,25 @@ describe Chef::Compliance::Runner do
expect(runner).to be_enabled
end
- it "is false if the node attributes do not have audit profiles and the audit cookbook is not present" do
+ it "is false if the node attributes do not have audit profiles and the audit cookbook is not present, and the complince mode attribute is nil" do
node.normal["audit"]["profiles"] = {}
+ node.normal["audit"]["compliance_phase"] = nil
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
+ it "is false if the node attributes do not have audit profiles and the audit cookbook is present, and the complince mode attribute is nil" do
stub_const("::Reporter::ChefAutomate", true)
node.automatic["recipes"] = %w{ audit::default fancy_cookbook::fanciness tacobell::nachos }
+ node.normal["audit"]["compliance_phase"] = nil
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
+ it "is false if the node attributes do not have audit attributes and the audit cookbook is not present, and the complince mode attribute is nil" do
node.automatic["recipes"] = %w{ fancy_cookbook::fanciness tacobell::nachos }
+ node.normal["audit"]["compliance_phase"] = nil
+
expect(runner).not_to be_enabled
end