Sha256: 8918945f52c07ac8d485d022482b2bf731d9b0f1515665473112a89b847d817b

Contents?: true

Size: 1.33 KB

Versions: 25

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'
require 'smart_proxy_openscap'
require 'smart_proxy_openscap/openscap_api'

ENV['RACK_ENV'] = 'test'

class FetchTailoringApiTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def setup
    @foreman_url = 'https://foreman.example.com'
    Proxy::SETTINGS.stubs(:foreman_url).returns(@foreman_url)
    @results_path = ("#{Dir.getwd}/test/test_run_files")
    FileUtils.mkdir_p(@results_path)
    Proxy::OpenSCAP::Plugin.settings.stubs(:tailoring_dir).returns(@results_path)
    @tailoring_file = File.new("#{Dir.getwd}/test/data/tailoring.xml").read
    @digest = Digest::SHA256.hexdigest @tailoring_file
    @policy_id = 1
  end

  def teardown
    FileUtils.rm_rf(Dir.glob("#{@results_path}/*"))
  end

  def app
    ::Proxy::OpenSCAP::Api.new
  end

  def test_get_tailoring_file_from_file
    FileUtils.mkdir("#{@results_path}/#{@policy_id}")
    FileUtils.cp("#{Dir.getwd}/test/data/tailoring.xml", "#{@results_path}/#{@policy_id}/#{@policy_id}_#{@digest}.xml")
    get "/policies/#{@policy_id}/tailoring/#{@digest}"
    assert_equal("application/xml;charset=utf-8", last_response.header["Content-Type"], "Response header should be application/xml")
    assert_equal(@tailoring_file.length, last_response.length, "Scap content should be equal")
    assert(last_response.successful?, "Response should be success")
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
smart_proxy_openscap-0.12.0 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.11.1 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.11.0 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.9.2 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.9.1 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.9.0 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.5 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.8.1 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.8.0 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.4 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.3 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.2 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.1 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.7.0 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.11 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.10 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.9 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.8 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.7 test/fetch_tailoring_api_test.rb
smart_proxy_openscap-0.6.6 test/fetch_tailoring_api_test.rb