| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -e -o pipefail |
| 4 | |
| 5 | . $builddir/tests/test_common.sh |
| 6 | |
| 7 | function test_validation { |
| 8 | local TYPE=$1 |
| 9 | local FILE=${srcdir}/$2 |
| 10 | local EXPECTED_CODE=$3 |
| 11 | local ret=0 |
| 12 | $OSCAP ds $TYPE-validate $FILE || ret=$? |
| 13 | if [ $ret -eq $EXPECTED_CODE ]; then |
| 14 | return 0 |
| 15 | fi |
| 16 | return 1 |
| 17 | } |
| 18 | |
| 19 | test_init test_validation.log |
| 20 | test_run "valid-sds" test_validation sds sds-valid.xml 0 |
| 21 | test_run "valid-1.3-sds" test_validation sds sds-1.3-valid.xml 0 |
| 22 | test_run "invalid-sds" test_validation sds sds-invalid.xml 1 |
| 23 | test_run "invalid-1.3-sds" test_validation sds sds-1.3-invalid.xml 1 |
| 24 | test_run "invalid-xccdf-sds" test_validation sds sds-invalid-xccdf.xml 1 |
| 25 | test_run "invalid-oval-sds" test_validation sds sds-invalid-oval.xml 1 |
| 26 | |
| 27 | test_run "valid-rds" test_validation rds rds-valid.xml 0 |
| 28 | test_run "invalid-rds" test_validation rds rds-invalid.xml 1 |
| 29 | test_exit |