Skip to content

Commit

Permalink
test: fix integration test script; add auth flow check
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm committed May 22, 2024
1 parent 03c0a80 commit a3ebe08
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions integration_tests/amqp091/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,37 @@ status=0

function doTest() {
MQ_VERSION=$1
CONTAINER_NAME="zgrab_amqp091-$MQ_VERSION"
OUTPUT_FILE="$ZGRAB_OUTPUT/amqp091/$MQ_VERSION.json"
echo "amqp091/test: Testing MySQL Version $MQ_VERSION..."
CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh amqp091 --timeout 10s >$OUTPUT_FILE

SUFFIX=""
AUTH_ARGS=""
if [[ -n "$2" ]]; then
AUTH_ARGS=$2
SUFFIX="-auth"
fi
CONTAINER_NAME="zgrab_amqp091-${MQ_VERSION}"
OUTPUT_FILE="$ZGRAB_OUTPUT/amqp091/${MQ_VERSION}${SUFFIX}.json"
echo "amqp091/test: Testing RabbitMQ Version ${MQ_VERSION}${SUFFIX}..."
CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh amqp091 $AUTH_ARGS --timeout 10s >$OUTPUT_FILE
SERVER_VERSION=$(jp -u data.amqp091.result.server_properties.version <$OUTPUT_FILE)
if [[ "$SERVER_VERSION" == "$MQ_VERSION."* ]]; then
echo "amqp091/test: Server version matches expected version: $SERVER_VERSION == $MQ_VERSION.*"
if [[ "$SERVER_VERSION" == "$MQ_VERSION" ]]; then
echo "amqp091/test: Server version matches expected version: $SERVER_VERSION == $MQ_VERSION"
else
echo "amqp091/test: Server version mismatch: Got $SERVER_VERSION, expected $MQ_VERSION.*. Full output: [["
echo "amqp091/test: Server version mismatch: Got $SERVER_VERSION, expected $MQ_VERSION. Full output: [["
cat $OUTPUT_FILE
echo "]]"
status=1
fi

if [[ -n "$AUTH_ARGS" ]]; then
AUTH_SUCCESS=$(jp -u data.amqp091.result.auth_success <$OUTPUT_FILE)
if [[ "$AUTH_SUCCESS" == "true" ]]; then
echo "amqp091/test: Auth test successful"
else
echo "amqp091/test: Auth test failed"
status=1
fi
fi

echo "amqp091/test: BEGIN docker+amqp091 logs from $CONTAINER_NAME [{("
docker logs --tail all $CONTAINER_NAME
echo ")}] END docker+amqp091 logs from $CONTAINER_NAME"
Expand All @@ -36,6 +54,7 @@ mkdir -p $ZGRAB_OUTPUT/amqp091

for version in $VERSIONS; do
doTest $version
doTest $version "--auth-user guest --auth-pass guest"
done

exit $status

0 comments on commit a3ebe08

Please sign in to comment.