Merge remote-tracking branch 'origin/aps/feature/addMySQLZGrabModule' into feature/addMySQLZGrabModule

This commit is contained in:
Justin Bastress 2017-12-18 09:10:43 -05:00
commit 031129c45c
6 changed files with 66 additions and 4 deletions

9
.gitignore vendored Normal file

@ -0,0 +1,9 @@
# macOS
.DS_Store
# zgrab
cmd/zgrab2/zgrab2
zgrab-output/
# CI dependencies
jp

@ -9,14 +9,14 @@ before_install:
# JMESPath is used to do context-specific validation of results
- go get github.com/jmespath/jp && go build github.com/jmespath/jp
- pip install --user zschema
- ./setup_integration_tests.sh
- ./integration_tests/setup.sh
- docker ps -a
install:
- pushd cmd/zgrab2 && go build && popd
script:
- ./integration_tests.sh
- ./integration_tests/test.sh
after_script:
- ./cleanup_integration_tests.sh
- ./integration_tests/cleanup.sh
notifications:
email:
- dev@censys.io

@ -6,6 +6,10 @@ set +e
# Clean up after running the integration tests.
# Drop your cleanup script(s) in integration_tests/<protocol>/cleanup(.*).sh
# Run from root of project
TEST_DIR=$(dirname "$0")
cd "$TEST_DIR/.."
echo "Cleaning up integration tests..."
pushd integration_tests

41
integration_tests/new.sh Executable file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Utility script for scaffolding stub test files for a new protocol
# Run from root of project
TEST_DIR=$(dirname "$0")
cd "$TEST_DIR/.."
if [ "$#" -ne 1 ]
then
echo "Usage: ./integration_tests/new.sh <new_protocol_name>"
exit 1
fi
module_name="$1"
module_path="integration_tests/$module_name"
mkdir -p $module_path
cat << EOF > $module_path/setup.sh
#!/usr/bin/env bash
echo "Tests setup for $module_name"
EOF
chmod +x $module_path/setup.sh
cat << EOF > $module_path/test.sh
#!/usr/bin/env bash
echo "Tests runner for $module_name"
EOF
chmod +x $module_path/test.sh
cat << EOF > $module_path/cleanup.sh
#!/usr/bin/env bash
echo "Tests cleanup for $module_name"
EOF
chmod +x $module_path/cleanup.sh
echo "Test files scafollded in $module_path"

@ -3,6 +3,10 @@
# Set up the integration tests for all modules.
# Drop your setup script(s) in integration_tests/<protocol>/setup(.*).sh
# Run from root of project
TEST_DIR=$(dirname "$0")
cd "$TEST_DIR/.."
echo "Setting up integration tests..."
pushd integration_tests

@ -1,7 +1,11 @@
#!/bin/bash -e
# Do all integration tests for all protocols
# To add tests for a new protocol, create a directory integration_tests/<new_protocol>, and drop its setup.sh, test.sh, and cleanup.sh there.
# To add tests for a new protocol, run `./integration_tests/new.sh <new_protocol>` and implement the appropriate test scripts.
# Run from root of project
TEST_DIR=$(dirname "$0")
cd "$TEST_DIR/.."
# <protocol>_integration_tests.sh should drop its output into $ZGRAB_OUTPUT/<protocol>/* so that it can be validated
if [ -z $ZGRAB_OUTPUT ]; then