2017-12-15 14:25:17 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# Do all integration tests for all protocols
|
2017-12-18 05:56:57 +00:00
|
|
|
# To add tests for a new protocol, run `./integration_tests/new.sh <new_protocol>` and implement the appropriate test scripts.
|
2017-12-15 14:25:17 +00:00
|
|
|
|
2017-12-18 05:34:04 +00:00
|
|
|
# Run from root of project
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
cd "$TEST_DIR/.."
|
|
|
|
|
2017-12-15 14:25:17 +00:00
|
|
|
# <protocol>_integration_tests.sh should drop its output into $ZGRAB_OUTPUT/<protocol>/* so that it can be validated
|
|
|
|
if [ -z $ZGRAB_OUTPUT ]; then
|
|
|
|
ZGRAB_OUTPUT="$(pwd)/zgrab-output"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export ZGRAB_OUTPUT=$ZGRAB_OUTPUT
|
|
|
|
export ZGRAB_ROOT=$(pwd)
|
|
|
|
|
|
|
|
pushd integration_tests
|
|
|
|
for mod in $(ls); do
|
|
|
|
if [ -d "$mod" ]; then
|
|
|
|
pushd $mod
|
|
|
|
for test in $(ls test*.sh); do
|
|
|
|
echo "Running integration_tests/$mod/$test"
|
|
|
|
./$test
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2017-12-15 21:57:04 +00:00
|
|
|
echo "Doing schema validation..."
|
|
|
|
for protocol in $(ls $ZGRAB_OUTPUT); do
|
|
|
|
for outfile in $(ls $ZGRAB_OUTPUT/$protocol); do
|
|
|
|
target="$ZGRAB_OUTPUT/$protocol/$outfile"
|
|
|
|
echo "Validating $target [{("
|
|
|
|
cat $target
|
|
|
|
echo ")}]:"
|
|
|
|
python -m zschema validate schemas/__init__.py:zgrab2 $target
|
|
|
|
echo "validation of $target succeeded."
|
2017-12-15 14:25:17 +00:00
|
|
|
done
|
2017-12-15 21:57:04 +00:00
|
|
|
done
|