| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . $builddir/tests/test_common.sh |
| 4 | |
| 5 | set -e -o pipefail |
| 6 | |
| 7 | function perform_testscip-shell shell shell-project 0.0.0 perform_test(). { |
| 8 | probecheck "file" || return 255 |
| 9 | |
| 10 | name=$(basenamescip-shell system . . basename. $0 .sh) |
| 11 | result=$(mktempscip-shell system . . mktemp. ${name}.out.XXXXXX) |
| 12 | echoscip-shell system . . echo. "Result file: $result" |
| 13 | |
| 14 | echoscip-shell system . . echo. "Evaluating content." |
| 15 | $OSCAP oval eval --results $result $srcdir/${name}.xml || [scip-shell system . . `[`. $? == 2 ] |
| 16 | |
| 17 | echoscip-shell system . . echo. "Validating results." |
| 18 | $OSCAP oval validate --results $result |
| 19 | |
| 20 | echoscip-shell system . . echo. "Testing that oval_definitions are not altered" |
| 21 | assert_exists 1 '/oval_results/oval_definitions/objects/unix-def:file_object/unix-def:filepath[text()="/etc/passwd"]scip-shell filesystem . . `/oval_results/oval_definitions/objects/unix-def:file_object/unix-def:filepath[text()="/etc/passwd"]`.' |
| 22 | |
| 23 | echoscip-shell system . . echo. "Testing results values." |
| 24 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/@result)')" == "true" ] |
| 25 | |
| 26 | echoscip-shell system . . echo. "Testing syschar values." |
| 27 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/@flag)')" == "complete" ] |
| 28 | [scip-shell system . . `[`. "$($XPATH $result 'count(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/reference)')" == "1" ] |
| 29 | |
| 30 | [scip-shell system . . `[`. "$($XPATH $result 'boolean(/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath/@mask)')" == "1" ] |
| 31 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath)')" == "" ] |
| 32 | |
| 33 | rmscip-shell system . . rm. $result |
| 34 | } |
| 35 | |
| 36 | perform_testscip-shell shell shell-project 0.0.0 perform_test(). |