Sha256: 00cdaf30a145cd1019e45463d67af3445b91b2abe01025343eeb9c5880cd1e3b

Contents?: true

Size: 1.87 KB

Versions: 73

Compression:

Stored size: 1.87 KB

Contents

require 'test_plugin_helper'

class Api::V2::Compliance::ScapContentsControllerTest < ActionController::TestCase
  test "should get index" do
    FactoryBot.create(:scap_content)
    get :index, :session => set_session_user
    response = ActiveSupport::JSON.decode(@response.body)
    assert response['results'].any?
    assert_response :success
  end

  test "should return xml of scap content" do
    scap_content = FactoryBot.create(:scap_content)
    get :show, :params => { :id => scap_content.id }, :session => set_session_user
    assert(@response.header['Content-Type'], 'application/xml')
    assert_response :success
  end

  test "should not create invalid scap content" do
    post :create, :session => set_session_user
    assert_response :unprocessable_entity
  end

  test "should create scap content" do
    # Skipped as API does not support uploading files
  end

  test "should update scap content" do
    scap_content = FactoryBot.create(:scap_content)
    put :update, :params => { :id => scap_content.id, :scap_content => { :title => 'RHEL7 SCAP' } }, :session => set_session_user
    assert_response :success
    assert scap_content.title, 'RHEL7 SCAP'
  end

  test "should not update invalid scap content" do
    skip("Solve 'ActiveRecord::RecordInvalid' error")
    ProxyAPI::Openscap.any_instance.stubs(:validate_scap_content).returns({ 'errors' => ['Invalid file'] })
    scap_content = FactoryBot.create(:scap_content)
    put :update, :params => { :id => scap_content.id, :scap_content => { :scap_file => '<xml>blah</xml>' } }, :session => set_session_user
    assert_response :unprocessable_entity
  end

  test "should destory scap content" do
    scap_content = FactoryBot.create(:scap_content)
    delete :destroy, :params => { :id => scap_content.id }, :session => set_session_user
    assert_response :ok
    refute ForemanOpenscap::ScapContent.exists?(scap_content.id)
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
foreman_openscap-10.1.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-10.0.3 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-10.0.2 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-10.0.1 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-10.0.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-9.0.4 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-9.0.3 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-9.0.2 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-9.0.1 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-9.0.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-8.0.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-7.1.1 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-7.1.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-7.0.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-6.0.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-5.2.3 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-5.2.2 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-5.1.1 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-5.2.1 test/functional/api/v2/compliance/scap_contents_controller_test.rb
foreman_openscap-5.2.0 test/functional/api/v2/compliance/scap_contents_controller_test.rb