X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Ftests.sh;h=7794f80dc28babe905fc23efc08c72e26dddeeca;hb=c98db32cbc4a3f7e4b655aacfbc503639bb8379c;hp=13735a0e42b983bad5365310c56b0a7c08dfd71e;hpb=437bffbf713d55d6a92bef3e27878c36fb6f6414;p=tlsproxy%2Ftlsproxy.git diff --git a/tests/tests.sh b/tests/tests.sh index 13735a0..7794f80 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -2,7 +2,7 @@ # tlsproxy test "suite". # -# Copyright (C) 2011 Simon Ruderich +# Copyright (C) 2011-2013 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,119 +21,10 @@ # Handle empty $srcdir. [ "x$srcdir" = x ] && srcdir=. -abort() { - echo abort - pkill -n gnutls-serv - pkill -n tlsproxy - exit 1 -} -server() { - gnutls-serv --http --port 4712 "$@" >/dev/null 2>/dev/null & -} -client() { - ./client ./proxy-ca.pem "$@" > tmp 2>&1 -} +echo "RUNNING NORMAL TESTS" +"$srcdir/tests-normal.sh" || exit 1 -test_proxy_failure() { - grep 'proxy failure' tmp >/dev/null || abort - grep 'response: HTTP/1.0 503 Forwarding failure' tmp >/dev/null \ - || abort -} -test_proxy_successful() { - grep 'response: HTTP/1.0 200 Connection established' tmp >/dev/null \ - || abort -} -test_invalid_certificate() { - grep 'certificate invalid' tmp >/dev/null || abort -} -test_no_invalid_certificate() { - grep 'certificate invalid' tmp >/dev/null && abort -} - - -# Create necessary files. -$srcdir/../src/tlsproxy-setup >/dev/null 2>/dev/null - -# Normal tests. -../src/tlsproxy -d2 4711 >/dev/null & -server --x509certfile $srcdir/server.pem \ - --x509keyfile $srcdir/server-key.pem -sleep 1 - - -echo invalid hostname -client unknown-host 80 - && abort -test_proxy_failure -test_no_invalid_certificate - -echo missing proxy and server certificate -client localhost 4712 invalid || abort -test_proxy_successful -test_invalid_certificate - -# Create the proxy certificate. -$srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \ - >/dev/null 2>/dev/null -rm -f certificate-localhost-server.pem - -echo missing server certificate -client localhost 4712 invalid || abort -test_proxy_successful -test_invalid_certificate - -# Create the proxy and server certificate. -$srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \ - >/dev/null 2>/dev/null - -echo normal connection -client localhost 4712 localhost || abort -test_proxy_successful -test_no_invalid_certificate - - -# Stop server and try a "MITM" with a bad certificate. echo -pkill -n gnutls-serv -server --x509certfile $srcdir/server-bad.pem \ - --x509keyfile $srcdir/server-key.pem -sleep 1 - - -echo mitm invalid hostname -client unknown-host 80 - && abort -test_proxy_failure -test_no_invalid_certificate - -echo mitm missing proxy and server certificate -client localhost 4712 invalid || abort -test_proxy_successful -test_invalid_certificate - -# Create the proxy certificate. -$srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \ - >/dev/null 2>/dev/null -rm -f certificate-localhost-server.pem - -echo mitm missing server certificate -client localhost 4712 invalid || abort -test_proxy_successful -test_invalid_certificate - -# Create the proxy and server certificate. -$srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \ - >/dev/null 2>/dev/null - -echo mitm normal connection -client localhost 4712 invalid || abort -test_proxy_successful -test_invalid_certificate - - -pkill -n gnutls-serv -pkill -n tlsproxy - -rm -f tmp \ - certificate-localhost-proxy.pem certificate-localhost-server.pem \ - proxy-ca-key.pem proxy-ca.pem proxy-invalid.pem proxy-key.pem -exit 0 +echo "RUNNING PASSTHROUGH (-u) TESTS" +"$srcdir/tests-passthrough.sh" || exit 1