Sha256: 5f8f015b982fb6fe3d20e696a5ce3562f77e4e7aaa6fcbcd223982d353deede3

Contents?: true

Size: 1.34 KB

Versions: 44

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe Chef::Compliance::Reporter::AuditEnforcer do
  let(:reporter) { Chef::Compliance::Reporter::AuditEnforcer.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::AuditEnforcer::ControlFailure, "Audit c2 has failed. Aborting chef-client run.")
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
chef-16.18.30-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.18.30 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.18.0-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.18.0 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.51-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.51 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.39-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.39 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.18-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.18 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.4-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.17.4 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.16.13-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.16.13 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.16.7-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.16.7 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.15.22-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.15.22 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.14.1-universal-mingw32 spec/unit/compliance/reporter/compliance_enforcer_spec.rb
chef-16.14.1 spec/unit/compliance/reporter/compliance_enforcer_spec.rb