Skip to content

Commit

Permalink
Modify tests to use the new OVAL bulder
Browse files Browse the repository at this point in the history
  • Loading branch information
Honny1 committed Nov 1, 2023
1 parent 32769d1 commit 66e4e20
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions tests/unit/ssg-module/test_build_ovals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import pytest
import tempfile
import xml.etree.ElementTree as ET

import ssg.build_ovals

Expand All @@ -12,22 +10,20 @@
SHARED_OVALS = os.path.join(DATADIR, "shared_ovals")
BUILD_OVALS_DIR = tempfile.mkdtemp()

shared_oval_1_def_tag = '<definition class="compliance" ' \
'id="tmux_conf_readable_by_others" version="1">'
benchmark_oval_1_def_tag = '<definition class="compliance" ' \
'id="selinux_state" version="1">'
shared_oval_1_def_id = "tmux_conf_readable_by_others"
benchmark_oval_1_def_id = "selinux_state"


def test_build_ovals():
env_yaml = {
"product": "rhel9",
"target_oval_version_str": "5.11",
}
obuilder = ssg.build_ovals.OVALBuilder(
oval_builder = ssg.build_ovals.OVALBuilder(
env_yaml, PRODUCT_YAML, [SHARED_OVALS], BUILD_OVALS_DIR)
shorthand = obuilder.build_shorthand(include_benchmark=False)
assert shared_oval_1_def_tag in shorthand
assert benchmark_oval_1_def_tag not in shorthand
oval_document = oval_builder.get_oval_document_from_shorthands(include_benchmark=False)
assert shared_oval_1_def_id in oval_document.definitions
assert benchmark_oval_1_def_id not in oval_document.definitions


def test_build_ovals_include_benchmark():
Expand All @@ -36,8 +32,8 @@ def test_build_ovals_include_benchmark():
"product": "rhel9",
"target_oval_version_str": "5.11",
}
obuilder = ssg.build_ovals.OVALBuilder(
oval_builder = ssg.build_ovals.OVALBuilder(
env_yaml, PRODUCT_YAML, [SHARED_OVALS], BUILD_OVALS_DIR)
shorthand = obuilder.build_shorthand(include_benchmark=True)
assert shared_oval_1_def_tag in shorthand
assert benchmark_oval_1_def_tag in shorthand
oval_document = oval_builder.get_oval_document_from_shorthands(include_benchmark=True)
assert shared_oval_1_def_id in oval_document.definitions
assert benchmark_oval_1_def_id in oval_document.definitions

0 comments on commit 66e4e20

Please sign in to comment.