Debian Codegraph @

tests/schemas/all.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 # Author:
4 # Martin Preisler <[email protected]>
5
6 . $builddir/tests/test_common.sh
7
8 # Test Cases.
9
10 function test_no_external_imports {
11 # openscap XSD schemas shall NOT import other XSDs from external
12 # locations!
13
14 # We have to do this pathetic double grep because grep doesn't support
15 # multiline matching. Normally pcregrep could be used but since it's not
16 # installed very often we use this hack instead. It assumes that xsd:import
17 # declarations don't take more than 2 lines in total.
18 case $(uname) in
19 FreeBSD)
20 EXTERNAL_IMPORTS=$(grep -R -E 'schemaLocation=\"http*://' "${srcdir}/../../schemas/" -C 1 | grep -R -E '<xs.*:import')
21 ;;
22 *)
23 EXTERNAL_IMPORTS=$(grep -n -P "schemaLocation=\"http[s]?://[^\"]+\"" -C 1 -r "${srcdir}/../../schemas/" | grep -P "<[^:]+:import")
24 ;;
25 esac
26
27 if [ "$?x" != "1x" ]; then
28 echo "XSD schemas using external xsd:import found!:"
29 echo
30 echo "$EXTERNAL_IMPORTS"
31 echo
32
33 return 1
34 fi
35
36 return 0
37 }
38
39 # Testing.
40 test_init "test_schemas.log"
41
42 if [ -z ${CUSTOM_OSCAP+x} ] ; then
43 test_run "no_external_imports" test_no_external_imports
44 fi
45
46 test_exit