summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-08-30 12:52:52 +0200
committervarac <varacanero@zeromail.org>2013-08-30 12:52:52 +0200
commita17deeca5f62079810146cae37c5860ce3bed86e (patch)
tree152d1dd95d1ce43b94a7dee43794f600159114bf
parenta39a01484807b4cd69570d6a8aba87da0ebc6192 (diff)
added check for expected response code
-rwxr-xr-xtest-swaks.sh60
1 files changed, 41 insertions, 19 deletions
diff --git a/test-swaks.sh b/test-swaks.sh
index e699f07..242e6e2 100755
--- a/test-swaks.sh
+++ b/test-swaks.sh
@@ -1,9 +1,10 @@
-#!/bin/sh
+#!/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
@@ -13,35 +14,56 @@ swaks_auth="--tlsc --tls-cert $HOME/leap/test/certs/cert.crt --tls-key $HOME/lea
echo "swaks_options: $swaks_options"
echo "swaks_auth : $swaks_auth"
+echo
test_swaks() {
- from=$1
- to=$2
+ 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
+ echo "From $from, to $to, no authentication: $response"
+}
+
- echo -n "From $from, to $to, no authentication:"
- swaks -f $from -t $to $swaks_options | tail -3 | head -1
+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 -n "From $from, to $to, with authentication:"
- swaks -f $from -t $to $swaks_options $swaks_auth | tail -3 | head -1
echo
}
-test_swaks $local $local
-test_swaks $local $nobody_local
-test_swaks $local $external
+test_delivery $local $local 250 250
+test_delivery $local $nobody_local 550 550
+test_delivery $local $external 554 250
echo
-test_swaks $nobody_local $local
-test_swaks $nobody_local $nobody_local
-test_swaks $nobody_local $external
+test_delivery $nobody_local $local 250 250
+test_delivery $nobody_local $nobody_local 550 550
+test_delivery $nobody_local $external 554 250
echo
-test_swaks $external $local
-test_swaks $external $nobody_local
-test_swaks $external $external
-
-
+test_delivery $external $local 250 250
+test_delivery $external $nobody_local 550 550
+test_delivery $external $external 554 250
-
+exit $exit_code