Fix the tests some more -- need to configure it locally for it to work

This commit is contained in:
Miek Gieben 2011-03-25 14:57:32 +01:00
parent f2a93a155b
commit 3067b91e18
1 changed files with 34 additions and 5 deletions

View File

@ -65,9 +65,38 @@ func TestTsig(t *testing.T) {
tsig.TimeSigned = uint64(time.Seconds())
tsig.Secret = "so6ZGir4GPAqINNh9U5c3A=="
out := new(Msg)
out.MsgHdr.RecursionDesired = true
out.Question = make([]Question, 1)
out.Question[0] = Question{"miek.nl.", TypeSOA, ClassINET}
/* do something with it */
// Perform a TSIG from miek.nl
m := new(Msg)
m.Question = make([]Question, 1)
m.Question[0] = Question{"miek.nl.", TypeAXFR, ClassINET}
m.Id = Id()
res := new(Resolver)
res.FromFile("/etc/resolv.conf")
res.Servers = []string{"85.223.71.124"}
res.Tcp = true
c := make(chan Xfr)
go res.XfrTsig(m, tsig, c)
for x := range c {
if x.Err != nil {
t.Logf("Failed Xfr from miek.nl %v\n", x.Err)
t.Fail()
}
}
tsig.Secret = "ZGZqc2tmZAo="
// Do it again, must fail
c = make(chan Xfr) // Reopen the channel
go res.XfrTsig(m, tsig, c)
ok := false
for x := range c {
if x.Err != nil {
ok = true
}
}
if ok == true {
t.Logf("AXFR with wrong secret should fail")
t.Fail()
}
}