summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-03-17 15:06:27 -0700
committerGitHub <noreply@github.com>2021-03-17 15:06:27 -0700
commit74f42dcf618c79b04b4cb23a0f96a9047a077ba5 (patch)
tree75e8ddc487cda24b977f5a291aa0b5cc383211a6
parent81f2f6eceb2411fa718c05ca3970f564fe997a6d (diff)
parent597ac4329aea2766cf432d0078afeb5f1a147103 (diff)
downloadchef-74f42dcf618c79b04b4cb23a0f96a9047a077ba5.tar.gz
Merge pull request #11199 from chef/fix_specs_16
Fix compliance phase specs
-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