Sha256: 3434c2bf25cbd3ffd615ab591b81841342da8021fe82106e945339bc121558ff

Contents?: true

Size: 995 Bytes

Versions: 7

Compression:

Stored size: 995 Bytes

Contents

require 'test_helper'
require 'smart_proxy_openscap/arf_html'
require 'smart_proxy_openscap/policy_guide'

class ScriptClassTest < Test::Unit::TestCase
  def test_arf_generate_html
    carry_out do |tmp|
      Proxy::OpenSCAP::ArfHtml.new.generate_html("#{Dir.getwd}/test/data/arf_report", tmp.path)
      content = File.read tmp
      assert content.start_with?('<!DOCTYPE'), "File should be html"
    end
  end

  def test_policy_guide
    carry_out do |tmp|
      profile = "xccdf_org.ssgproject.content_profile_rht-ccp"
      Proxy::OpenSCAP::PolicyGuide.new.generate_guide("#{Dir.getwd}/test/data/ssg-rhel7-ds.xml", tmp.path, profile)
      guide = read_json tmp
      assert guide['html'].start_with?('<!DOCTYPE'), "File should be html"
    end
  end

  private

  def carry_out
    tmp = Tempfile.new('test')
    begin
      yield tmp if block_given?
    ensure
      tmp.close
      tmp.unlink
    end
  end

  def read_json(file)
    file.flush
    JSON.parse(File.read file)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_proxy_openscap-0.11.1 test/script_class_test.rb
smart_proxy_openscap-0.11.0 test/script_class_test.rb
smart_proxy_openscap-0.9.2 test/script_class_test.rb
smart_proxy_openscap-0.9.1 test/script_class_test.rb
smart_proxy_openscap-0.9.0 test/script_class_test.rb
smart_proxy_openscap-0.8.1 test/script_class_test.rb
smart_proxy_openscap-0.8.0 test/script_class_test.rb