1# #-- ssl_req_timeout.test --# 2# source the master var file when it's there 3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4# use .tpkg.var.test for in test variable passing 5[ -f .tpkg.var.test ] && source .tpkg.var.test 6 7PRE="../.." 8. ../common.sh 9get_make 10(cd $PRE; $MAKE streamtcp) 11# check what sort of netcat we have 12if nc -h 2>&1 | grep "q secs"; then 13 ncopt="-q 3 -i 4" 14else 15 ncopt="-i 4" 16fi 17 18# this test query should just work (server is up) 19echo "> query www1.example.net." 20$PRE/streamtcp -s -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN >outfile 2>outerr 21cat outfile 22cat outerr 23if test "$?" -ne 0; then 24 echo "exit status not OK" 25 echo "> cat logfiles" 26 cat outfile 27 cat outerr 28 cat fwd.log 29 cat unbound.log 30 echo "Not OK" 31 exit 1 32fi 33if grep "www1.example.net" outfile | grep "1.2.3.1"; then 34 echo "content OK" 35else 36 echo "result contents not OK" 37 echo "> cat logfiles" 38 cat outfile 39 cat outerr 40 cat fwd.log 41 cat unbound.log 42 echo "result contents not OK" 43 exit 1 44fi 45echo "OK" 46 47# multiple requests that are answered immediately and then the timeout 48echo "> query www1.example.net. www2.example.net. www3.example.net. www.example.com." 49$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 50cat outfile 51cat outerr 52if test "$?" -ne 0; then 53 echo "exit status not OK" 54 echo "> cat logfiles" 55 cat outfile 56 cat outerr 57 cat fwd.log 58 cat unbound.log 59 echo "Not OK" 60 exit 1 61fi 62if grep "www1.example.net" outfile | grep "1.2.3.1"; then 63 echo "content OK" 64else 65 echo "result contents not OK" 66 echo "> cat logfiles" 67 cat outfile 68 cat outerr 69 cat fwd.log 70 cat unbound.log 71 echo "result contents not OK" 72 exit 1 73fi 74if grep "www2.example.net" outfile | grep "1.2.3.2"; then 75 echo "content OK" 76else 77 echo "result contents not OK" 78 echo "> cat logfiles" 79 cat outfile 80 cat outerr 81 cat fwd.log 82 cat unbound.log 83 echo "result contents not OK" 84 exit 1 85fi 86if grep "www3.example.net" outfile | grep "1.2.3.3"; then 87 echo "content OK" 88else 89 echo "result contents not OK" 90 echo "> cat logfiles" 91 cat outfile 92 cat outerr 93 cat fwd.log 94 cat unbound.log 95 echo "result contents not OK" 96 exit 1 97fi 98if grep "stream closed" outfile; then 99 echo "content OK" 100else 101 echo "result contents not OK" 102 echo "> cat logfiles" 103 cat outfile 104 cat outerr 105 cat fwd.log 106 cat unbound.log 107 echo "result contents not OK" 108 exit 1 109fi 110 111# multiple requests that are waiting for answers and then the timeout 112echo "> query www2.example.com. www2.example.com. www3.example.com." 113$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 114cat outfile 115cat outerr 116if test "$?" -ne 0; then 117 echo "exit status not OK" 118 echo "> cat logfiles" 119 cat outfile 120 cat outerr 121 cat fwd.log 122 cat unbound.log 123 echo "Not OK" 124 exit 1 125fi 126if grep "stream closed" outfile; then 127 echo "content OK" 128else 129 echo "result contents not OK" 130 echo "> cat logfiles" 131 cat outfile 132 cat outerr 133 cat fwd.log 134 cat unbound.log 135 echo "result contents not OK" 136 exit 1 137fi 138 139# wait a bit 140sleep 2 141 142# echo a couple requests to the other side and then wait for the timeout. 143# this creates waiting answers in the reply queue. 144echo "> nc www.example.net www2.example.net www3.example.net" 145( echo "0021eb410100000100000000000003777777076578616d706c65036e657400000100010022eb41010000010000000000000477777732076578616d706c65036e657400000100010022eb41010000010000000000000477777733076578616d706c65036e65740000010001" | xxd -r -p ; sleep 10 ; echo "") | nc $ncopt --ssl 127.0.0.1 $UNBOUND_PORT | xxd | tee outfile 146 147echo "OK" 148exit 0 149