From ac627aacf00c2f888f21c6f108931dea38260f73 Mon Sep 17 00:00:00 2001 From: varac Date: Tue, 3 Sep 2013 15:09:39 +0200 Subject: reorganized directory layout --- tests/test-postmap.sh | 17 ++++++++++++ tests/test-swaks.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100755 tests/test-postmap.sh create mode 100755 tests/test-swaks.sh (limited to 'tests') diff --git a/tests/test-postmap.sh b/tests/test-postmap.sh new file mode 100755 index 0000000..460e26b --- /dev/null +++ b/tests/test-postmap.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +test_postmap () { + echo -n "get $1, port 2244:" + postmap -v -q $1 tcp:localhost:2244 2>&1 |grep recv: + echo -n "get $1, port 4242:" + postmap -v -q $1 tcp:localhost:4242 2>&1 |grep recv: + echo +} + +test_postmap dummy +test_postmap dummy@dev.bitmask.net +test_postmap dummy@nowhe.re + +test_postmap fooooo +test_postmap fooooo@dev.bitmask.net +test_postmap fooooo@nowhe.re diff --git a/tests/test-swaks.sh b/tests/test-swaks.sh new file mode 100755 index 0000000..9f521b9 --- /dev/null +++ b/tests/test-swaks.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +local='dummy@bitmask.net' +nobody_local='fooooooo@bitmask.net' +external='dummy@leap.se' +server='leech.bitmask.net' +exit_code=0 + +# override $server with possible exported shell var +[ $SWAKS_SERVER ] && server=$SWAKS_SERVER + +swaks_options="--timeout 5 --server $server --hide-informational --suppress-data" +swaks_auth="--tlsc --tls-cert $HOME/leap/test/certs/cert.crt --tls-key $HOME/leap/test/certs/cert.key" + +echo "swaks_options: $swaks_options" +echo "swaks_auth : $swaks_auth" +echo + +test_swaks() { + local from=$1 + shift + local to=$1 + shift + local expected_repsonse_code=$1 + shift + local options="$@" + + response=`swaks -f $from -t $to $options | tail -3 | head -1` + response_code=`echo "$response"| cut -d' ' -f 2-|sed 's/^ //g'|cut -d' ' -f 1 ` + if [ "$response_code" == "$expected_repsonse_code" ] + then + echo -n 'OK: ' + else + echo -n 'WARNING: ' + exit_code=1 + fi + + [[ "$options" == *--tls* ]] && authentication='authenticated ' || authentication='no authentication' + [ ] + echo "From $from, to $to, $authentication: $response" +} + + +test_delivery() { + local from=$1 + local to=$2 + local unauth_repsonse_code=$3 + local auth_response_code=$4 + + test_swaks $from $to $unauth_repsonse_code $swaks_options + test_swaks $from $to $auth_response_code $swaks_options $swaks_auth + + echo +} + + +test_delivery $local $local 250 250 +test_delivery $local $nobody_local 550 550 +test_delivery $local $external 554 250 + +echo + +test_delivery $nobody_local $local 250 250 +test_delivery $nobody_local $nobody_local 550 550 +test_delivery $nobody_local $external 554 250 + +echo + +test_delivery $external $local 250 250 +test_delivery $external $nobody_local 550 550 +test_delivery $external $external 554 250 + +exit $exit_code -- cgit v1.2.3