| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . $builddir/tests/test_common.sh |
| 4 | |
| 5 | function test_probes_behaviour_setupscip-shell shell shell-project 0.0.0 test_probes_behaviour_setup(). { |
| 6 | rmscip-shell system . . rm. -rf /tmp/scapValscip-shell filesystem . . `/tmp/scapVal`. && mkdirscip-shell system . . mkdir. /tmp/scapValscip-shell filesystem . . `/tmp/scapVal`. |
| 7 | |
| 8 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2`. |
| 9 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder010scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010`. |
| 10 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder020scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder020`. |
| 11 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder030scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder030`. |
| 12 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder040scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder040`. |
| 13 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder050scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder050`. |
| 14 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011`. |
| 15 | mkdirscip-shell system . . mkdir. /tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012scip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012`. |
| 16 | |
| 17 | echoscip-shell system . . echo. "This is a Level3-File scap validation test file.">>/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level3-File010.txtscip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level3-File010.txt`. |
| 18 | echoscip-shell system . . echo. "This is a Level5-File 0121 test file for the scap validation program.">/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012/Level5-File0121.txtscip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012/Level5-File0121.txt`. |
| 19 | echoscip-shell system . . echo. "This is a Level5-File 0122 test file for the scap validation program.">/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012/Level5-File0122.logscip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder010/Level4-Folder011/Level5-Folder012/Level5-File0122.log`. |
| 20 | |
| 21 | rmscip-shell system . . rm. -rf /tmp/scapVal-Symscip-shell filesystem . . `/tmp/scapVal-Sym`. && mkdirscip-shell system . . mkdir. /tmp/scapVal-Symscip-shell filesystem . . `/tmp/scapVal-Sym`. |
| 22 | mkdirscip-shell system . . mkdir. /tmp/scapVal-Sym/File-Test-Level2-SymLinkedscip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked`. |
| 23 | mkdirscip-shell system . . mkdir. /tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010scip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010`. |
| 24 | echoscip-shell system . . echo. "This is a Level3-File test file for the scap validation program.">/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level3-File.txtscip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level3-File.txt`. |
| 25 | mkdirscip-shell system . . mkdir. /tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level4-Folderscip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level4-Folder`. |
| 26 | echoscip-shell system . . echo. "This is a Level4-File test file for the scap validation program.">/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level4-Folder/Level4-File.txtscip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/Level3-SymLinked-Folder010/Level4-Folder/Level4-File.txt`. |
| 27 | |
| 28 | lnscip-shell system . . ln. -s /tmp/scapVal-Sym/File-Test-Level2-SymLinked/scip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/`. /tmp/scapVal/File-Test-Level2/Level3-Folder040/this_is_a_symlinkscip-shell filesystem . . `/tmp/scapVal/File-Test-Level2/Level3-Folder040/this_is_a_symlink`. |
| 29 | lnscip-shell system . . ln. -s /optscip-shell filesystem . . `/opt`. /tmp/scapVal-Sym/this_is_a_symlink_to_optscip-shell filesystem . . `/tmp/scapVal-Sym/this_is_a_symlink_to_opt`. |
| 30 | echoscip-shell system . . echo. "This is a Level2-File test file for the scap validation program.">/tmp/scapVal-Sym/File-Test-Level2-SymLinked/File-Test-Sym-Level2.txtscip-shell filesystem . . `/tmp/scapVal-Sym/File-Test-Level2-SymLinked/File-Test-Sym-Level2.txt`. |
| 31 | } |
| 32 | |
| 33 | function test_probes_behaviour_cleanupscip-shell shell shell-project 0.0.0 test_probes_behaviour_cleanup(). { |
| 34 | rmscip-shell system . . rm. -rf /tmp/scapValscip-shell filesystem . . `/tmp/scapVal`. |
| 35 | rmscip-shell system . . rm. -rf /tmp/scapVal-Symscip-shell filesystem . . `/tmp/scapVal-Sym`. |
| 36 | } |
| 37 | |
| 38 | function test_probes_file_behaviourscip-shell shell shell-project 0.0.0 test_probes_file_behaviour(). { |
| 39 | probecheck "file" || return 255 |
| 40 | |
| 41 | local ret_val=0 |
| 42 | local DF="$srcdir/test_probes_file_behaviour.xml" |
| 43 | result="results.xml" |
| 44 | |
| 45 | test_probes_behaviour_setupscip-shell shell shell-project 0.0.0 test_probes_behaviour_setup(). |
| 46 | |
| 47 | $OSCAP oval eval --results $result $DF || ret_val=1 |
| 48 | $OSCAP oval validate $result || ret_val=1 |
| 49 | |
| 50 | assert_exists 11 '//results//criterion' || ret_val=1 |
| 51 | assert_exists 11 '//results//criterion[@result="true"]' || ret_val=1 |
| 52 | |
| 53 | test_probes_behaviour_cleanupscip-shell shell shell-project 0.0.0 test_probes_behaviour_cleanup(). |
| 54 | |
| 55 | return $ret_val |
| 56 | } |
| 57 | |
| 58 | test_init |
| 59 | |
| 60 | test_run "test_probes_file_behaviour" test_probes_file_behaviour |
| 61 | |
| 62 | test_exit |