Sha256: 0cc4e8e7be9638abbf5b739d3baafeeff6d4dd0dc4bacdaecb348f02c2d2ea25

Contents?: true

Size: 1.22 KB

Versions: 71

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 = FactoryBot.create(:compliance_host)
    policy = FactoryBot.create(:policy)
    reports = []
    source = FactoryBot.create(:source, :value => "xccdf_org.ssgproject.content_rule_firefox_preferences-lock_settings_obscure")
    2.times do
      report = FactoryBot.create(:arf_report, :host_id => host.id)
      message = FactoryBot.create(:compliance_message, :value => "Disable Firefox Configuration File ROT-13 Encoding")
      FactoryBot.create(:policy_arf_report, :policy_id => policy.id, :arf_report_id => report.id)
      FactoryBot.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

71 entries across 71 versions & 1 rubygems

Version Path
foreman_openscap-9.0.4 test/unit/message_cleaner_test.rb
foreman_openscap-9.0.3 test/unit/message_cleaner_test.rb
foreman_openscap-9.0.2 test/unit/message_cleaner_test.rb
foreman_openscap-9.0.1 test/unit/message_cleaner_test.rb
foreman_openscap-9.0.0 test/unit/message_cleaner_test.rb
foreman_openscap-8.0.0 test/unit/message_cleaner_test.rb
foreman_openscap-7.1.1 test/unit/message_cleaner_test.rb
foreman_openscap-7.1.0 test/unit/message_cleaner_test.rb
foreman_openscap-7.0.0 test/unit/message_cleaner_test.rb
foreman_openscap-6.0.0 test/unit/message_cleaner_test.rb
foreman_openscap-5.2.3 test/unit/message_cleaner_test.rb
foreman_openscap-5.2.2 test/unit/message_cleaner_test.rb
foreman_openscap-5.1.1 test/unit/message_cleaner_test.rb
foreman_openscap-5.2.1 test/unit/message_cleaner_test.rb
foreman_openscap-5.2.0 test/unit/message_cleaner_test.rb
foreman_openscap-5.1.0 test/unit/message_cleaner_test.rb
foreman_openscap-5.0.0 test/unit/message_cleaner_test.rb
foreman_openscap-4.3.3 test/unit/message_cleaner_test.rb
foreman_openscap-4.3.2 test/unit/message_cleaner_test.rb
foreman_openscap-4.3.1 test/unit/message_cleaner_test.rb