| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Author: |
| 4 | # Martin Preisler <[email protected]> |
| 5 | |
| 6 | set -e -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | . $srcdir/test_ds_common.sh |
| 10 | |
| 11 | # Test Cases. |
| 12 | function test_rds_index |
| 13 | { |
| 14 | local ret_val=0; |
| 15 | |
| 16 | local RDS_FILE="${srcdir}/$1" |
| 17 | local ASSETS="$2" |
| 18 | local REPORTS="$3" |
| 19 | local REQUESTS="$4" |
| 20 | |
| 21 | INDEX=$($OSCAP info "$RDS_FILE") |
| 22 | |
| 23 | for asset in "$ASSETS"; do |
| 24 | if ! echo $INDEX | grep --quiet "$asset"; then |
| 25 | ret_val=1 |
| 26 | echo "Asset $asset expected in index" |
| 27 | fi |
| 28 | done |
| 29 | |
| 30 | for report in "$REPORTS"; do |
| 31 | if ! echo $INDEX | grep --quiet "$report"; then |
| 32 | ret_val=1 |
| 33 | echo "Report $report expected in index" |
| 34 | fi |
| 35 | done |
| 36 | |
| 37 | for requests in "$REQUESTS"; do |
| 38 | if ! echo $INDEX | grep --quiet "$request"; then |
| 39 | ret_val=1 |
| 40 | echo "Report request $request expected in index" |
| 41 | fi |
| 42 | done |
| 43 | |
| 44 | return "$ret_val" |
| 45 | } |
| 46 | |
| 47 | |
| 48 | # Testing. |
| 49 | test_init |
| 50 | |
| 51 | test_run "rds_index_simple" test_rds_index rds_index_simple/arf.xml "asset0 asset1" "report0" "collection0" |
| 52 | |
| 53 | test_exit |
| 54 |