Example #1
0
def test_archive_content_paths():
    data = PolicyData()
    data.content_type = "archive"
    data.content_url = "http://example.com/oscap_content.tar"
    data.content_path = "oscap/xccdf.xml"
    data.profile_id = "Web Server"
    data.content_path = "oscap/xccdf.xml"
    data.tailoring_path = "oscap/tailoring.xml"

    assert common.get_content_name(data) == "oscap_content.tar"

    expected_path = "/tmp/openscap_data/oscap_content.tar"
    assert common.get_raw_preinst_content_path(data) == expected_path

    expected_path = "/tmp/openscap_data/oscap/xccdf.xml"
    assert common.get_preinst_content_path(data) == expected_path

    expected_path = "/root/openscap_data/oscap/xccdf.xml"
    assert common.get_postinst_content_path(data) == expected_path

    expected_path = "/tmp/openscap_data/oscap/tailoring.xml"
    assert common.get_preinst_tailoring_path(data) == expected_path

    expected_path = "/root/openscap_data/oscap/tailoring.xml"
    assert common.get_postinst_tailoring_path(data) == expected_path
Example #2
0
def test_datastream_content_paths():
    data = PolicyData()
    data.content_type = "datastream"
    data.content_url = "https://example.com/hardening.xml"
    data.datastream_id = "id_datastream_1"
    data.xccdf_id = "id_xccdf_new"
    data.content_path = "/usr/share/oscap/testing_ds.xml"
    data.cpe_path = "/usr/share/oscap/cpe.xml"
    data.tailoring_path = "/usr/share/oscap/tailoring.xml"
    data.profile_id = "Web Server"

    assert common.get_content_name(data) == "hardening.xml"

    expected_path = "/tmp/openscap_data/hardening.xml"
    assert common.get_raw_preinst_content_path(data) == expected_path

    expected_path = "/tmp/openscap_data/hardening.xml"
    assert common.get_preinst_content_path(data) == expected_path

    expected_path = "/root/openscap_data/hardening.xml"
    assert common.get_postinst_content_path(data) == expected_path

    expected_path = "/tmp/openscap_data/usr/share/oscap/tailoring.xml"
    assert common.get_preinst_tailoring_path(data) == expected_path

    expected_path = "/root/openscap_data/usr/share/oscap/tailoring.xml"
    assert common.get_postinst_tailoring_path(data) == expected_path
Example #3
0
def test_scap_security_guide_paths():
    data = PolicyData()
    data.content_type = "scap-security-guide"
    data.profile_id = "Web Server"
    data.content_path = "/usr/share/xml/scap/ssg/content.xml"

    expected_msg = "Using scap-security-guide, no single content file"
    with pytest.raises(ValueError, match=expected_msg):
        common.get_content_name(data)

    expected_path = None
    assert common.get_raw_preinst_content_path(data) == expected_path

    expected_path = "/usr/share/xml/scap/ssg/content.xml"
    assert common.get_preinst_content_path(data) == expected_path

    expected_path = "/usr/share/xml/scap/ssg/content.xml"
    assert common.get_postinst_content_path(data) == expected_path

    expected_path = ""
    assert common.get_preinst_tailoring_path(data) == expected_path

    expected_path = ""
    assert common.get_postinst_tailoring_path(data) == expected_path