Debian Codegraph @

testdata/10-unbound-anchor.tdir/10-unbound-anchor.test

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