Sha256: bf02e931e1b1611b0d9e5587bfc9e6284fc3ee93ba196ef88e158924a752ca8b

Contents?: true

Size: 1.41 KB

Versions: 31

Compression:

Stored size: 1.41 KB

Contents

require "spec_helper"
require "chef/compliance/reporter/compliance_enforcer"

describe Chef::Compliance::Reporter::ComplianceEnforcer do
  let(:reporter) { Chef::Compliance::Reporter::ComplianceEnforcer.new }

  it "does not raise error for a successful InSpec report" do
    report = {
      "profiles": [
        {
          "controls": [
            { "id": "c1", "results": [{ "status": "passed" }] },
            { "id": "c2", "results": [{ "status": "passed" }] },
          ],
        },
      ],
    }

    expect(reporter.send_report(report)).to eq(true)
  end

  it "does not raise error for an InSpec report with no controls" do
    report = { "profiles": [{ "name": "empty" }] }

    expect(reporter.send_report(report)).to eq(true)
  end

  it "does not raise error for an InSpec report with controls but no results" do
    report = { "profiles": [{ "controls": [{ "id": "empty" }] }] }
    expect(reporter.send_report(report)).to eq(true)
  end

  it "raises an error for a failed InSpec report" do
    report = {
      "profiles": [
        {
          "controls": [
            { "id": "c1", "results": [{ "status": "passed" }] },
            { "id": "c2", "results": [{ "status": "failed" }] },
          ],
        },
      ],
    }

    expect {
      reporter.send_report(report)
    }.to raise_error(Chef::Compliance::Reporter::ComplianceEnforcer::ControlFailure, "Audit c2 has failed. Aborting chef-client run.")
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
chef-18.1.29-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.1.0-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.1.0 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.0.185-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.0.185 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.0.169-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.0.169 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.0-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.0 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.9.52-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.9.52 spec/unit/compliance/reporter/compliance_enforcer_spec.rb