-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.