1# #-- 10-unbound-anchor.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="../.." 8OPTS="-u 127.0.0.1 -P $PETAL_PORT -C ub.conf -v -a root.key -c root.pem -n petal" 9DS=`cat K.+005+37348.ds` 10 11# check that the root.key file works. 12function check_works() { 13 if $PRE/unbound-host -C ub.conf -f root.key -t DNSKEY -v . | grep "(secure)" >/dev/null; then 14 echo OK 15 else 16 echo "not OK" 17 cat fwd.log 18 cat petal.log 19 exit 1 20 fi 21} 22 23# check that the root.key file works, but insecurely. 24function check_insecure() { 25 if $PRE/unbound-host -C ub.conf -f root.key -t DNSKEY -v . | grep "(insecure)" >/dev/null; then 26 echo OK 27 else 28 echo "not OK" 29 cat fwd.log 30 cat petal.log 31 exit 1 32 fi 33} 34 35# test with good start key, and must do 5011 (no URL possible) 36echo "*** TEST 1 ***" 37echo $DS > root.key 38$PRE/unbound-anchor -x "notexist.xml" -s "notexist.p7s" $OPTS 39if test $? != 0; then 40 echo "Exitcode not OK" 41 exit 1 42fi 43check_works 44# save for test 5 45cp root.key root.key.probed 46 47# force update with the cert. 48echo "*** TEST 2 ***" 49cp test_cert.pem root.pem 50$PRE/unbound-anchor -F -x "root.xml" -s "root.p7s" $OPTS 51if test $? != 1; then 52 echo "Exitcode not OK" 53 exit 1 54fi 55check_works 56 57# 5011 fails 58echo "*** TEST 3 ***" 59echo ". IN DS 37000 5 1 b00000000000000000000100f0000000000000b2" > root.key 60$PRE/unbound-anchor -x "root.xml" -s "root.p7s" $OPTS 61if test $? != 1; then 62 echo "Exitcode not OK" 63 exit 1 64fi 65check_works 66 67# cert fails (bad p7s). 68echo "*** TEST 4 ***" 69echo ". IN DS 44444 5 1 b00000000000000000000100f0000000000000b2" > root.key 70$PRE/unbound-anchor -F -x "bad.xml" -s "bad.p7s" $OPTS 71if test $? != 0; then 72 echo "Exitcode not OK" 73 exit 1 74fi 75if grep "DS 44444" root.key >/dev/null ; then 76 echo OK 77else 78 echo "keyfile changed" 79 exit 1 80fi 81 82# cert fails (bad name). 83echo "*** TEST 4b ***" 84echo ". IN DS 44444 5 1 b00000000000000000000100f0000000000000b2" > root.key 85$PRE/unbound-anchor -F -x "bad.xml" -s "bad.p7s" $OPTS -n "not-it" 86if test $? != 0; then 87 echo "Exitcode not OK" 88 exit 1 89fi 90if grep "DS 44444" root.key >/dev/null ; then 91 echo OK 92else 93 echo "keyfile changed" 94 exit 1 95fi 96 97# 5011 fails, and probe-time too recent. 98echo "*** TEST 5 ***" 99# break the probed key. 100sed -e 's/bp0KIK3J3/b00KIK0J0/' < root.key.probed > root.key 101$PRE/unbound-anchor -x "notexist.xml" -s "notexist.p7s" $OPTS 102if test $? != 0; then 103 echo "Exitcode not OK" 104 exit 1 105fi 106if grep "b00KIK0J0" root.key >/dev/null ; then 107 echo OK 108else 109 echo "keyfile changed" 110 exit 1 111fi 112 113# 5011 fails, and probe time is very, very old. 114echo "*** TEST 6 ***" 115mv root.key bla.key 116# last probe was Sun Sep 9 03:46:40 2001 117sed -e 's/;;last_success: .*$/;;last_success: 1000000000/' < bla.key > root.key 118rm bla.key 119$PRE/unbound-anchor -x "root.xml" -s "root.p7s" $OPTS 120if test $? != 1; then 121 echo "Exitcode not OK" 122 exit 1 123fi 124check_works 125 126# 5011 update probe is only needed. 127echo "*** TEST 7 ***" 128$PRE/unbound-anchor -x "notexist.xml" -s "notexist.p7s" $OPTS 129if test $? != 0; then 130 echo "Exitcode not OK" 131 exit 1 132fi 133check_works 134 135# root goes to insecure (0 anchors). 136echo "*** TEST 8 ***" 137$PRE/unbound-anchor -F -x "no_more_keys.xml" -s "no_more_keys.p7s" $OPTS 138if test $? != 1; then 139 echo "Exitcode not OK" 140 exit 1 141fi 142if grep ";;REVOKED" root.key >/dev/null; then echo "REVOKED"; else 143 echo "not revoked"; exit 1; fi 144check_insecure 145 146# insecure input file 147echo "*** TEST 9 ***" 148$PRE/unbound-anchor -x "notexist.xml" -s "notexist.p7s" $OPTS 149if test $? != 0; then 150 echo "Exitcode not OK" 151 exit 1 152fi 153if grep ";;REVOKED" root.key >/dev/null; then echo "REVOKED"; else 154 echo "not revoked"; exit 1; fi 155check_insecure 156 157 158echo "logs" 159cat fwd.log 160cat petal.log 161 162exit 0 163