unbound/testdata/ssl_req_timeout.tdir/ssl_req_timeout.test
W.C.A. Wijngaards bbba236a36 - Fix stream_ssl, ssl_req_order and ssl_req_timeout tests for
alloc check debug output.
2020-09-30 11:29:57 +02:00

149 lines
3.6 KiB
Plaintext

# #-- ssl_req_timeout.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
PRE="../.."
. ../common.sh
get_make
(cd $PRE; $MAKE streamtcp)
# check what sort of netcat we have
if nc -h 2>&1 | grep "q secs"; then
ncopt="-q 3 -i 4"
else
ncopt="-i 4"
fi
# this test query should just work (server is up)
echo "> query www1.example.net."
$PRE/streamtcp -s -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN >outfile 2>outerr
cat outfile
cat outerr
if test "$?" -ne 0; then
echo "exit status not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "Not OK"
exit 1
fi
if grep "www1.example.net" outfile | grep "1.2.3.1"; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
echo "OK"
# multiple requests that are answered immediately and then the timeout
echo "> query www1.example.net. www2.example.net. www3.example.net. www.example.com."
$PRE/streamtcp -a -s -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN www2.example.net A IN www3.example.net A IN www.example.com. A IN >outfile 2>outerr
cat outfile
cat outerr
if test "$?" -ne 0; then
echo "exit status not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "Not OK"
exit 1
fi
if grep "www1.example.net" outfile | grep "1.2.3.1"; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
if grep "www2.example.net" outfile | grep "1.2.3.2"; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
if grep "www3.example.net" outfile | grep "1.2.3.3"; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
if grep "stream closed" outfile; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
# multiple requests that are waiting for answers and then the timeout
echo "> query www2.example.com. www2.example.com. www3.example.com."
$PRE/streamtcp -a -s -f 127.0.0.1@$UNBOUND_PORT www2.example.com. A IN www2.example.com A IN www3.example.com A IN >outfile 2>outerr
cat outfile
cat outerr
if test "$?" -ne 0; then
echo "exit status not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "Not OK"
exit 1
fi
if grep "stream closed" outfile; then
echo "content OK"
else
echo "result contents not OK"
echo "> cat logfiles"
cat outfile
cat outerr
cat fwd.log
cat unbound.log
echo "result contents not OK"
exit 1
fi
# wait a bit
sleep 2
# echo a couple requests to the other side and then wait for the timeout.
# this creates waiting answers in the reply queue.
echo "> nc www.example.net www2.example.net www3.example.net"
( echo "0021eb410100000100000000000003777777076578616d706c65036e657400000100010022eb41010000010000000000000477777732076578616d706c65036e657400000100010022eb41010000010000000000000477777733076578616d706c65036e65740000010001" | xxd -r -p ; sleep 10 ; echo "") | nc $ncopt --ssl 127.0.0.1 $UNBOUND_PORT | xxd | tee outfile
echo "OK"
exit 0