Home | History | Annotate | Line # | Download | only in ipset.tdir
ipset.test revision 1.1.1.1
      1 # #-- ipset.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 . ../common.sh
      8 PRE="../.."
      9 if grep "define USE_IPSET 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
     10 
     11 # Make all the queries. They need to succeed by the way.
     12 echo "> dig www.example.net."
     13 dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
     14 echo "> check answer"
     15 if grep "1.1.1.1" outfile; then
     16 	echo "OK"
     17 else
     18 	echo "> cat logfiles"
     19 	cat fwd.log
     20 	cat unbound.log
     21 	echo "Not OK"
     22 	exit 1
     23 fi
     24 echo "> check ipset"
     25 if grep "ipset: add 1.1.1.1 to atotallymadeupnamefor4 for www.example.net." unbound.log; then
     26 	echo "ipset OK"
     27 else
     28 	echo "> cat logfiles"
     29 	cat fwd.log
     30 	cat unbound.log
     31 	echo "Not OK"
     32 	exit 1
     33 fi
     34 
     35 echo "> dig www.example.net. AAAA"
     36 dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. AAAA | tee outfile
     37 echo "> check answer"
     38 if grep "::1" outfile; then
     39 	echo "OK"
     40 else
     41 	echo "> cat logfiles"
     42 	cat fwd.log
     43 	cat unbound.log
     44 	echo "Not OK"
     45 	exit 1
     46 fi
     47 echo "> check ipset"
     48 if grep "ipset: add ::1 to atotallymadeupnamefor6 for www.example.net." unbound.log; then
     49 	echo "ipset OK"
     50 else
     51 	echo "> cat logfiles"
     52 	cat fwd.log
     53 	cat unbound.log
     54 	echo "Not OK"
     55 	exit 1
     56 fi
     57 
     58 echo "> dig cname.example.net."
     59 dig @127.0.0.1 -p $UNBOUND_PORT cname.example.net. | tee outfile
     60 echo "> check answer"
     61 if grep "2.2.2.2" outfile; then
     62 	echo "OK"
     63 else
     64 	echo "> cat logfiles"
     65 	cat fwd.log
     66 	cat unbound.log
     67 	echo "Not OK"
     68 	exit 1
     69 fi
     70 echo "> check ipset"
     71 if grep "ipset: add 2.2.2.2 to atotallymadeupnamefor4 for target.example.net." unbound.log; then
     72 	echo "ipset OK"
     73 else
     74 	echo "> cat logfiles"
     75 	cat fwd.log
     76 	cat unbound.log
     77 	echo "Not OK"
     78 	exit 1
     79 fi
     80 
     81 echo "> dig cname.example.net. AAAA"
     82 dig @127.0.0.1 -p $UNBOUND_PORT cname.example.net. AAAA | tee outfile
     83 echo "> check answer"
     84 if grep "::2" outfile; then
     85 	echo "OK"
     86 else
     87 	echo "> cat logfiles"
     88 	cat fwd.log
     89 	cat unbound.log
     90 	echo "Not OK"
     91 	exit 1
     92 fi
     93 echo "> check ipset"
     94 if grep "ipset: add ::2 to atotallymadeupnamefor6 for target.example.net." unbound.log; then
     95 	echo "ipset OK"
     96 else
     97 	echo "> cat logfiles"
     98 	cat fwd.log
     99 	cat unbound.log
    100 	echo "Not OK"
    101 	exit 1
    102 fi
    103 
    104 echo "> dig outsidecname.example.net."
    105 dig @127.0.0.1 -p $UNBOUND_PORT outsidecname.example.net. | tee outfile
    106 echo "> check answer"
    107 if grep "3.3.3.3" outfile; then
    108 	echo "OK"
    109 else
    110 	echo "> cat logfiles"
    111 	cat fwd.log
    112 	cat unbound.log
    113 	echo "Not OK"
    114 	exit 1
    115 fi
    116 echo "> check ipset"
    117 if grep "ipset: add 3.3.3.3 to atotallymadeupnamefor4 for target.example.com." unbound.log; then
    118 	echo "ipset OK"
    119 else
    120 	echo "> cat logfiles"
    121 	cat fwd.log
    122 	cat unbound.log
    123 	echo "Not OK"
    124 	exit 1
    125 fi
    126 
    127 echo "> dig outsidecname.example.net. AAAA"
    128 dig @127.0.0.1 -p $UNBOUND_PORT outsidecname.example.net. AAAA | tee outfile
    129 echo "> check answer"
    130 if grep "::3" outfile; then
    131 	echo "OK"
    132 else
    133 	echo "> cat logfiles"
    134 	cat fwd.log
    135 	cat unbound.log
    136 	echo "Not OK"
    137 	exit 1
    138 fi
    139 echo "> check ipset"
    140 if grep "ipset: add ::3 to atotallymadeupnamefor6 for target.example.com." unbound.log; then
    141 	echo "ipset OK"
    142 else
    143 	echo "> cat logfiles"
    144 	cat fwd.log
    145 	cat unbound.log
    146 	echo "Not OK"
    147 	exit 1
    148 fi
    149 
    150 echo "> cat logfiles"
    151 cat tap.log
    152 cat tap.errlog
    153 cat fwd.log
    154 echo "> OK"
    155 exit 0
    156