add TSIG axfr test, still needs work though

This commit is contained in:
Miek Gieben 2011-07-05 20:52:35 +02:00
parent 73cad7898b
commit f53ca4bfc3
3 changed files with 34 additions and 63 deletions

View File

@ -1,4 +1,4 @@
Extensions from the original work are copyright (c) 2010 Miek Gieben
Extensions from the original work are copyright (c) 2010, 2011 Miek Gieben
As this is fork of the official Go code the same license applies:

View File

@ -2,6 +2,7 @@ package dns
import (
"testing"
"time"
)
func TestClientSync(t *testing.T) {
@ -81,53 +82,23 @@ func TestResolverEdns(t *testing.T) {
}
*/
func TestClientTsigAXFR(t *testing.T) {
m := new(Msg)
m.SetAxfr("miek.nl")
m.SetTsig("axfr", HmacMD5, 300, uint64(time.Seconds()))
secrets := make(map[string]string)
secrets["axfr"] = "so6ZGir4GPAqINNh9U5c3A=="
c := NewClient()
c.Net = "tcp"
c.TsigSecret = secrets
_, err := c.XfrReceive(m, "85.223.71.124:53")
/*
func TestResolverTsig(t *testing.T) {
res := new(Resolver)
res.Servers = []string{"127.0.0.1"}
res.Timeout = 2
res.Attempts = 1
m := new(Msg)
m.MsgHdr.RecursionDesired = true //only set this bit
m.Question = make([]Question, 1)
// ask something
m.Question[0] = Question{"powerdns.nl", TypeDNSKEY, ClassINET}
m.Extra = make([]RR, 1)
m.Id = Id()
tsig := new(Tsig)
tsig.Name = "miek.nl."
tsig.Algorithm = HmacMD5
tsig.Fudge = 300
tsig.TimeSigned = uint64(time.Seconds())
tsig.Secret = "ZGZqc2tmZAo="
in, _ := res.QueryTsig(m,tsig)
if in != nil {
if in.Rcode != RcodeSuccess {
t.Logf("%v\n", in)
t.Log("Failed to get an valid answer")
// t.Fail()
}
}
}
func TestAXFR(t *testing.T) {
res := new(Resolver)
res.Servers = []string{"127.0.0.1"}
m := new(Msg)
m.Question = make([]Question, 1)
m.Question[0] = Question{"miek.nl", TypeAXFR, ClassINET}
ch := make(chan Xfr)
go res.Xfr(m, ch)
for x := range ch {
var _ = x
// fmt.Printf("%v\n",dm.Dns)
}
// channel is closed by Axfr()
if err != nil {
t.Log("%s\n", err.String())
t.Fail()
}
*/
}