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