1# #-- doh_downstream.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 9if grep "define HAVE_NGHTTP2 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi 10get_make 11(cd $PRE; $MAKE dohclient) 12 13 14# this test query should just work (server is up) 15echo "> query www1.example.net." 16$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN >outfile 2>&1 17cat outfile 18if test "$?" -ne 0; then 19 echo "exit status not OK" 20 echo "> cat logfiles" 21 cat outfile 22 cat fwd.log 23 cat unbound.log 24 echo "Not OK" 25 exit 1 26fi 27if grep "www1.example.net" outfile | grep "1.2.3.1"; then 28 echo "content OK" 29else 30 echo "result contents not OK" 31 echo "> cat logfiles" 32 cat outfile 33 cat fwd.log 34 cat unbound.log 35 echo "result contents not OK" 36 exit 1 37fi 38echo "OK" 39 40# multiple requests (from localdata) 41echo "> query www1.example.net. www2.example.net. www3.example.net." 42$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www2.example.net A IN www3.example.net A IN >outfile 2>&1 43cat outfile 44if test "$?" -ne 0; then 45 echo "exit status not OK" 46 echo "> cat logfiles" 47 cat outfile 48 cat fwd.log 49 cat unbound.log 50 echo "Not OK" 51 exit 1 52fi 53if grep "www1.example.net" outfile | grep "1.2.3.1"; then 54 echo "content OK" 55else 56 echo "result contents not OK" 57 echo "> cat logfiles" 58 cat outfile 59 cat fwd.log 60 cat unbound.log 61 echo "result contents not OK" 62 exit 1 63fi 64if grep "www2.example.net" outfile | grep "1.2.3.2"; then 65 echo "content OK" 66else 67 echo "result contents not OK" 68 echo "> cat logfiles" 69 cat outfile 70 cat fwd.log 71 cat unbound.log 72 echo "result contents not OK" 73 exit 1 74fi 75if grep "www3.example.net" outfile | grep "1.2.3.3"; then 76 echo "content OK" 77else 78 echo "result contents not OK" 79 echo "> cat logfiles" 80 cat outfile 81 cat fwd.log 82 cat unbound.log 83 echo "result contents not OK" 84 exit 1 85fi 86 87# out of order requests, the example.com elements take 2 seconds to wait. 88echo "" 89echo "> query www1.example.net. www.example.com. www2.example.net. www2.example.com. www3.example.net." 90$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www.example.com. A IN www2.example.net A IN www2.example.com. A IN www3.example.net A IN >outfile 2>&1 91cat outfile 92if test "$?" -ne 0; then 93 echo "exit status not OK" 94 echo "> cat logfiles" 95 cat outfile 96 cat fwd.log 97 cat unbound.log 98 echo "Not OK" 99 exit 1 100fi 101if grep "www1.example.net" outfile | grep "1.2.3.1"; then 102 echo "content OK" 103else 104 echo "result contents not OK" 105 echo "> cat logfiles" 106 cat outfile 107 cat fwd.log 108 cat unbound.log 109 echo "result contents not OK" 110 exit 1 111fi 112if grep "www2.example.net" outfile | grep "1.2.3.2"; then 113 echo "content OK" 114else 115 echo "result contents not OK" 116 echo "> cat logfiles" 117 cat outfile 118 cat fwd.log 119 cat unbound.log 120 echo "result contents not OK" 121 exit 1 122fi 123if grep "www3.example.net" outfile | grep "1.2.3.3"; then 124 echo "content OK" 125else 126 echo "result contents not OK" 127 echo "> cat logfiles" 128 cat outfile 129 cat fwd.log 130 cat unbound.log 131 echo "result contents not OK" 132 exit 1 133fi 134if grep "www.example.com" outfile | grep "10.20.30.40"; then 135 echo "content OK" 136else 137 echo "result contents not OK" 138 echo "> cat logfiles" 139 cat outfile 140 cat fwd.log 141 cat unbound.log 142 echo "result contents not OK" 143 exit 1 144fi 145if grep "www2.example.com" outfile | grep "10.20.30.42"; then 146 echo "content OK" 147else 148 echo "result contents not OK" 149 echo "> cat logfiles" 150 cat outfile 151 cat fwd.log 152 cat unbound.log 153 echo "result contents not OK" 154 exit 1 155fi 156 157# out of order requests, the example.com elements take 2 seconds to wait. 158# www.example.com present twice, answered twice. 159echo "" 160echo "> query www1.example.net. www.example.com. www2.example.net. www.example.com. www3.example.net." 161$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www.example.com. A IN www2.example.net A IN www.example.com. A IN www3.example.net A IN >outfile 2>&1 162cat outfile 163if test "$?" -ne 0; then 164 echo "exit status not OK" 165 echo "> cat logfiles" 166 cat outfile 167 cat fwd.log 168 cat unbound.log 169 echo "Not OK" 170 exit 1 171fi 172if grep "www1.example.net" outfile | grep "1.2.3.1"; then 173 echo "content OK" 174else 175 echo "result contents not OK" 176 echo "> cat logfiles" 177 cat outfile 178 cat fwd.log 179 cat unbound.log 180 echo "result contents not OK" 181 exit 1 182fi 183if grep "www2.example.net" outfile | grep "1.2.3.2"; then 184 echo "content OK" 185else 186 echo "result contents not OK" 187 echo "> cat logfiles" 188 cat outfile 189 cat fwd.log 190 cat unbound.log 191 echo "result contents not OK" 192 exit 1 193fi 194if grep "www3.example.net" outfile | grep "1.2.3.3"; then 195 echo "content OK" 196else 197 echo "result contents not OK" 198 echo "> cat logfiles" 199 cat outfile 200 cat fwd.log 201 cat unbound.log 202 echo "result contents not OK" 203 exit 1 204fi 205if grep "www.example.com" outfile | grep "10.20.30.40"; then 206 echo "content OK" 207else 208 echo "result contents not OK" 209 echo "> cat logfiles" 210 cat outfile 211 cat fwd.log 212 cat unbound.log 213 echo "result contents not OK" 214 exit 1 215fi 216 217# out of order requests, the example.com elements take 2 seconds to wait. 218# www3.example.com present twice, answered twice. 219echo "" 220echo "> query www1.example.net. www3.example.com. www2.example.net. www3.example.com. www3.example.net." 221$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www3.example.com. A IN www2.example.net A IN www3.example.com. A IN www3.example.net A IN >outfile 2>&1 222cat outfile 223if test "$?" -ne 0; then 224 echo "exit status not OK" 225 echo "> cat logfiles" 226 cat outfile 227 cat fwd.log 228 cat unbound.log 229 echo "Not OK" 230 exit 1 231fi 232if grep "www1.example.net" outfile | grep "1.2.3.1"; then 233 echo "content OK" 234else 235 echo "result contents not OK" 236 echo "> cat logfiles" 237 cat outfile 238 cat fwd.log 239 cat unbound.log 240 echo "result contents not OK" 241 exit 1 242fi 243if grep "www2.example.net" outfile | grep "1.2.3.2"; then 244 echo "content OK" 245else 246 echo "result contents not OK" 247 echo "> cat logfiles" 248 cat outfile 249 cat fwd.log 250 cat unbound.log 251 echo "result contents not OK" 252 exit 1 253fi 254if grep "www3.example.net" outfile | grep "1.2.3.3"; then 255 echo "content OK" 256else 257 echo "result contents not OK" 258 echo "> cat logfiles" 259 cat outfile 260 cat fwd.log 261 cat unbound.log 262 echo "result contents not OK" 263 exit 1 264fi 265if grep "www3.example.com" outfile | grep "10.20.30.43"; then 266 echo "content OK" 267else 268 echo "result contents not OK" 269 echo "> cat logfiles" 270 cat outfile 271 cat fwd.log 272 cat unbound.log 273 echo "result contents not OK" 274 exit 1 275fi 276 277echo "" 278echo "> query www4.example.com. www3.example.net." 279$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www4.example.com. A IN www3.example.net A IN >outfile 2>&1 280cat outfile 281if test "$?" -ne 0; then 282 echo "exit status not OK" 283 echo "> cat logfiles" 284 cat outfile 285 cat fwd.log 286 cat unbound.log 287 echo "Not OK" 288 exit 1 289fi 290if grep "www3.example.net" outfile | grep "1.2.3.3"; then 291 echo "content OK" 292else 293 echo "result contents not OK" 294 echo "> cat logfiles" 295 cat outfile 296 cat fwd.log 297 cat unbound.log 298 echo "result contents not OK" 299 exit 1 300fi 301if grep "www4.example.com" outfile | grep "10.20.30.44"; then 302 echo "content OK" 303else 304 echo "result contents not OK" 305 echo "> cat logfiles" 306 cat outfile 307 cat fwd.log 308 cat unbound.log 309 echo "result contents not OK" 310 exit 1 311fi 312 313 314echo "" 315echo "> query a1.example.com. - a90.example.com." 316$PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www6.example.com. A IN a1.a.example.com. A IN a2.a.example.com. A IN a3.a.example.com. A IN a4.a.example.com. A IN a5.a.example.com. A IN a6.a.example.com. A IN a7.a.example.com. A IN a8.a.example.com. A IN a9.a.example.com. A IN a10.a.example.com. A IN a11.a.example.com. A IN a12.a.example.com. A IN a13.a.example.com. A IN a14.a.example.com. A IN a15.a.example.com. A IN a16.a.example.com. A IN a17.a.example.com. A IN a18.a.example.com. A IN a19.a.example.com. A IN a20.a.example.com. A IN a21.a.example.com. A IN a22.a.example.com. A IN a23.a.example.com. A IN a24.a.example.com. A IN a25.a.example.com. A IN a26.a.example.com. A IN a27.a.example.com. A IN a28.a.example.com. A IN a29.a.example.com. A IN a30.a.example.com. A IN a31.a.example.com. A IN a32.a.example.com. A IN a33.a.example.com. A IN a34.a.example.com. A IN a35.a.example.com. A IN a36.a.example.com. A IN a37.a.example.com. A IN a38.a.example.com. A IN a39.a.example.com. A IN a40.a.example.com. A IN a41.a.example.com. A IN a42.a.example.com. A IN a43.a.example.com. A IN a44.a.example.com. A IN a45.a.example.com. A IN a46.a.example.com. A IN a47.a.example.com. A IN a48.a.example.com. A IN a49.a.example.com. A IN a50.a.example.com. A IN a51.a.example.com. A IN a52.a.example.com. A IN a53.a.example.com. A IN a54.a.example.com. A IN a55.a.example.com. A IN a56.a.example.com. A IN a57.a.example.com. A IN a58.a.example.com. A IN a59.a.example.com. A IN a60.a.example.com. A IN a61.a.example.com. A IN a62.a.example.com. A IN a63.a.example.com. A IN a64.a.example.com. A IN a65.a.example.com. A IN a66.a.example.com. A IN a67.a.example.com. A IN a68.a.example.com. A IN a69.a.example.com. A IN a70.a.example.com. A IN a71.a.example.com. A IN a72.a.example.com. A IN a73.a.example.com. A IN a74.a.example.com. A IN a75.a.example.com. A IN a76.a.example.com. A IN a77.a.example.com. A IN a78.a.example.com. A IN a79.a.example.com. A IN a80.a.example.com. A IN a81.a.example.com. A IN a82.a.example.com. A IN a83.a.example.com. A IN a84.a.example.com. A IN a85.a.example.com. A IN a86.a.example.com. A IN a87.a.example.com. A IN a88.a.example.com. A IN a89.a.example.com. A IN a90.a.example.com. A IN >outfile 2>&1 317cat outfile 318if test "$?" -ne 0; then 319 echo "exit status not OK" 320 echo "> cat logfiles" 321 cat outfile 322 cat fwd.log 323 cat unbound.log 324 echo "Not OK" 325 exit 1 326fi 327num_ans=$(grep -B 3 "a.example.com. IN A" outfile | grep "rcode: NOERROR" | wc -l ) 328if test "$num_ans" -ne 90; then 329 echo "number of answers not OK" 330 echo "> cat logfiles" 331 cat outfile 332 cat fwd.log 333 cat unbound.log 334 echo "Not OK" 335 exit 1 336fi 337 338echo "OK" 339exit 0 340