File: test_sds_fix_from_results.sh

package info (click to toggle)
openscap 1.4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 125,060 kB
  • sloc: xml: 527,109; ansic: 91,402; sh: 19,789; python: 2,515; perl: 444; makefile: 49
file content (37 lines) | stat: -rwxr-xr-x 1,066 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

# Author:
#   Martin Preisler <mpreisle@redhat.com>

set -e -o pipefail

. $builddir/tests/test_common.sh

# Test Cases.

function test_generate_fix_results {
    local fixfile=$(mktemp -t ${name}.out.XXXXXX)
    local results=$(mktemp -t ${name}.out.XXXXXX)

    # generate all from results
    $OSCAP xccdf eval --results $results "${srcdir}/$1" || ret=$?
    $OSCAP xccdf generate fix --output $fixfile $results
    grep -q remediation_rule_applicable_pass $fixfile
    grep -q remediation_rule_applicable_fail $fixfile
    grep -q remediation_rule_notapplicable $fixfile
    rm $fixfile

    # generate based on TestResult
    $OSCAP xccdf generate fix --output $fixfile --result-id xccdf_org.open-scap_testresult_default-profile $results
    grep -qv remediation_rule_applicable_pass $fixfile
    grep -q remediation_rule_applicable_fail $fixfile
    grep -qv remediation_rule_notapplicable $fixfile
    rm $fixfile $results
}

# Testing.
test_init

test_run "generate_fix_cpe_results" test_generate_fix_results eval_cpe/sds.xml

test_exit