Skip to content

Commit

Permalink
ci: Add tests for post step (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
larose authored Jul 4, 2024
1 parent 13fe985 commit 2b35ab7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -x
# Stop on failure
set -e

POST_WARNINGS_FILEPATH=/tmp/post.warnings

sudo pkill --signal 9 agent || true
sudo pkill --signal 9 tetragon || true

Expand All @@ -16,10 +18,23 @@ sudo systemctl restart docker

sudo rm -f /var/run/bullfrog/agent-ready
# sudo rm -f /tmp/tetragon.tar.gz
sudo rm -f $POST_WARNINGS_FILEPATH

sudo NODE_OPTIONS=--enable-source-maps node --require /vagrant/test/block.env.js /vagrant/action/dist/main.js
sudo NODE_OPTIONS=--enable-source-maps node \
--require /vagrant/test/block.env.js \
/vagrant/action/dist/main.js

source /vagrant/test/make_http_requests.sh
source /vagrant/test/make_dns_requests.sh

sudo NODE_OPTIONS=--enable-source-maps node \
--require /vagrant/test/block.env.js \
/vagrant/action/dist/post.js | grep "^::warning::" | sed 's/%0A/\n/g' > $POST_WARNINGS_FILEPATH

grep --quiet 'Blocked DNS request to www.bing.com from unknown process' $POST_WARNINGS_FILEPATH
grep --quiet 'Blocked request to 93.184.215.14:443 from processs `/usr/bin/curl https://93.184.215.14 --output /dev/null' $POST_WARNINGS_FILEPATH
grep --quiet 'Blocked DNS request to registry-1.docker.io from unknown process' $POST_WARNINGS_FILEPATH
grep --quiet 'Blocked DNS request to www.wikipedia.org from unknown process' $POST_WARNINGS_FILEPATH
grep --quiet 'Blocked DNS request to www.google.com from unknown process' $POST_WARNINGS_FILEPATH

echo "Tests passed successfully"
5 changes: 5 additions & 0 deletions test/make_http_requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ if timeout 5 curl https://www.bing.com --output /dev/null; then
exit 1;
fi;

if timeout 5 curl https://93.184.215.14 --output /dev/null; then
echo 'Expected curl to 93.184.215.14 to fail, but it succeeded';
exit 1;
fi;

if timeout 5 docker pull alpine:3.14; then
echo "Expected docker pull to fail, but it succeeded"
exit 1;
Expand Down

0 comments on commit 2b35ab7

Please sign in to comment.