From 37066a4cabadbd94258b636f38b949dab8c8c731 Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Tue, 26 Mar 2024 15:24:28 +0100 Subject: [PATCH 1/2] Add test for thin ds --- tests/test_thin_ds.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_thin_ds.py diff --git a/tests/test_thin_ds.py b/tests/test_thin_ds.py new file mode 100644 index 00000000000..94c94789a4f --- /dev/null +++ b/tests/test_thin_ds.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# Usage (Execute in root project directory): python3 -m pytest -n auto tests/test_thin_ds.py + +import pytest + +from lxml import etree + +from pathlib import Path + + +THIN_DS_PATHS = [] +for path in Path("./build/thin_ds").glob("*.xml"): + THIN_DS_PATHS.append(path) + + +@pytest.mark.parametrize("path", THIN_DS_PATHS) +def test_thin_ds(path): + root = etree.parse(path) + + rules = root.findall(".//{http://checklists.nist.gov/xccdf/1.2}Rule") + assert len(rules) == 1 + + rule_id = rules[0].get("id", "NoID").removeprefix("xccdf_org.ssgproject.content_rule_") + assert rule_id in str(path) + + profiles = root.findall(".//{http://checklists.nist.gov/xccdf/1.2}Profile") + assert len(profiles) == 1 + + profile_id = ( + profiles[0].get("id", "NoID").removeprefix("xccdf_org.ssgproject.content_profile_") + ) + assert profile_id in str(path) From 0d535501d05d6b58af0eb1e894167366757b92ed Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Tue, 26 Mar 2024 15:25:05 +0100 Subject: [PATCH 2/2] Add workflow for thin ds test --- .github/workflows/gate_thin_ds.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/gate_thin_ds.yml diff --git a/.github/workflows/gate_thin_ds.yml b/.github/workflows/gate_thin_ds.yml new file mode 100644 index 00000000000..5a709f9d2db --- /dev/null +++ b/.github/workflows/gate_thin_ds.yml @@ -0,0 +1,29 @@ +name: Gate Thin DS +on: + merge_group: + branches: [ 'master' ] + push: + branches: ['*', '!stabilization*', '!stable*', 'master' ] + pull_request: + branches: [ 'master', 'stabilization*' ] +concurrency: + group: ${{ github.workflow }}-fedora-${{ github.event.number || github.run_id }} + cancel-in-progress: true +jobs: + build-and-test-thin-ds: + name: Build, Test on Fedora Latest (Container) + runs-on: ubuntu-latest + container: + image: fedora:latest + steps: + - name: Install Deps + run: dnf install -y cmake make openscap-utils python3-pyyaml bats ansible python3-pip ShellCheck git gcc gcc-c++ python3-devel python3-lxml python3-pytest + - name: Checkout + uses: actions/checkout@v4 + - name: Install deps python + # pytest-xdist is used for parallel execution of thin ds test + run: pip install pcre2 pytest-xdist -r requirements.txt -r test-requirements.txt + - name: Build + run: ./build_product rhel9 --thin + - name: Test + run: python3 -m pytest -n auto tests/test_thin_ds.py