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-17.10.163-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.163 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.5.0-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.5.0 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.4.12-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.4.12 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.122-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.122 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.114-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.114 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.4.2-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.4.2 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.95-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.95 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.3.0-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.3.0 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-17.10.68-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.2.7-x64-mingw-ucrt spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.2.7 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-18.1.29 spec/unit/compliance/reporter/compliance_enforcer_spec.rb