Sha256: 44f9ca3ac3aa6b8aef6a123e4594660b0589fb1eea78b38ace5647393673aea7

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

require 'test_plugin_helper'

class MessageCleanerTest < ActiveSupport::TestCase
  setup do
    ForemanOpenscap::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
  end

  test "should clean up messages" do
    host = FactoryGirl.create(:compliance_host)
    policy = FactoryGirl.create(:policy)
    reports = []
    source = FactoryGirl.create(:source, :value => "xccdf_org.ssgproject.content_rule_firefox_preferences-lock_settings_obscure")
    2.times do
      report = FactoryGirl.create(:arf_report, :host_id => host.id)
      message = FactoryGirl.create(:compliance_message, :value => "Disable Firefox Configuration File ROT-13 Encoding")
      FactoryGirl.create(:policy_arf_report, :policy_id => policy.id, :arf_report_id => report.id)
      FactoryGirl.create(:compliance_log, :source_id => source.id, :message_id => message.id, :report_id => report.id)
      report.reload
      reports << report
    end

    assert_equal 2, reports.flat_map(&:logs).map(&:message).uniq.count

    ForemanOpenscap::MessageCleaner.new.clean
    reports.map(&:reload)

    assert_equal 1, reports.flat_map(&:logs).map(&:message).uniq.count
    log_a, log_b = reports.flat_map(&:logs)
    assert_equal log_a.message, log_b.message
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_openscap-0.7.13 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.12 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.11 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.10 test/unit/message_cleaner_test.rb
foreman_openscap-0.8.3 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.9 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.8 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.7 test/unit/message_cleaner_test.rb
foreman_openscap-0.8.2 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.6 test/unit/message_cleaner_test.rb
foreman_openscap-0.8.1 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.5 test/unit/message_cleaner_test.rb
foreman_openscap-0.8.0 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.4 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.3 test/unit/message_cleaner_test.rb
foreman_openscap-0.7.2 test/unit/message_cleaner_test.rb