From be6f2365cbc24f14adff2e4849465d77d51691bf Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 23 Mar 2011 19:03:37 +0100 Subject: [PATCH] Test compile again, but fail --- dns_test.go | 22 +++++++--------------- dnssec_test.go | 4 ++-- parse_test.go | 2 +- resolver_test.go | 20 ++++++++++---------- server_test.go | 22 +++++----------------- 5 files changed, 25 insertions(+), 45 deletions(-) diff --git a/dns_test.go b/dns_test.go index 42527206..2aa1c032 100644 --- a/dns_test.go +++ b/dns_test.go @@ -58,24 +58,16 @@ func TestEDNS_RR(t *testing.T) { } func TestTsig(t *testing.T) { - tsig := new(RR_TSIG) - tsig.Hdr.Name = "miek.nl." // for tsig this is the key's name - tsig.SetDefaults() - tsig.TimeSigned = uint64(time.Seconds()) + tsig := new(Tsig) + tsig.Name = "axfr." + tsig.Algorithm = HmacMD5 + tsig.Fudge = 300 + 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} - - ok := tsig.Generate(out, "awwLOtRfpGE+rRKF2+DEiw==") - if !ok { - t.Log("Failed to generate TSIG record") - t.Fail() - } - - // Having the TSIG record, it must now be added to the msg - // in the extra section - out.Extra = make([]RR, 1) - out.Extra[0] = tsig +/* do something with it */ } diff --git a/dnssec_test.go b/dnssec_test.go index 45e27cba..91fbd079 100644 --- a/dnssec_test.go +++ b/dnssec_test.go @@ -60,14 +60,14 @@ func TestSignature(t *testing.T) { sig.Signature = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ" // Should not be valid - if sig.PeriodOK() { + if sig.ValidityPeriod() { t.Log("Should not be valid") t.Fail() } sig.Inception = 315565800 //Tue Jan 1 10:10:00 CET 1980 sig.Expiration = 4102477800 //Fri Jan 1 10:10:00 CET 2100 - if !sig.PeriodOK() { + if !sig.ValidityPeriod() { t.Log("Should be valid") t.Fail() } diff --git a/parse_test.go b/parse_test.go index 6a5c890b..593124fa 100644 --- a/parse_test.go +++ b/parse_test.go @@ -79,7 +79,7 @@ Activate: 20110109154937` k.Hdr.Ttl = 3600 k.Protocol = 3 k.Flags = 256 - p, _ := k.PrivateKeySetString(a) + p, _ := k.ReadPrivateKey(strings.NewReader(a)) switch priv := p.(type) { case *rsa.PrivateKey: if 65537 != priv.PublicKey.E { diff --git a/resolver_test.go b/resolver_test.go index b2749265..a73e10bc 100644 --- a/resolver_test.go +++ b/resolver_test.go @@ -1,6 +1,7 @@ package dns import ( + "time" "testing" ) @@ -84,16 +85,15 @@ func TestResolverTsig(t *testing.T) { m.Extra = make([]RR, 1) m.Id = Id() - tsig := new(RR_TSIG) - tsig.Hdr.Name = "miek.nl" // for tsig this is the key's name - tsig.Hdr.Rrtype = TypeTSIG - tsig.Hdr.Class = ClassANY - tsig.Hdr.Ttl = 0 - tsig.Generate(m, "geheim") - // Add it to the msg - m.Extra[0] = tsig - in, _ := res.Query(m) + 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) @@ -111,7 +111,7 @@ func TestAXFR(t *testing.T) { m.Question[0] = Question{"miek.nl", TypeAXFR, ClassINET} ch := make(chan Xfr) - go res.Axfr(m, ch) + go res.Xfr(m, ch) for x := range ch { var _ = x /* fmt.Printf("%v\n",dm.Dns) */ diff --git a/server_test.go b/server_test.go index a88989f5..9d701108 100644 --- a/server_test.go +++ b/server_test.go @@ -2,11 +2,10 @@ package dns import ( "testing" - "net" "time" ) -func createpkg(id uint16, tcp bool, remove net.Addr) []byte { +func createpkg(id uint16, tcp bool) *Msg { m := new(Msg) m.MsgHdr.Id = id m.MsgHdr.Authoritative = true @@ -26,26 +25,15 @@ func createpkg(id uint16, tcp bool, remove net.Addr) []byte { t.Txt = "Dit is iets anders UDP" } m.Answer[0] = t - out, _ := m.Pack() - return out + return m } -func replyUDP(c *net.UDPConn, a net.Addr, in *Msg) { - if in.MsgHdr.Response == true { - // Uh... answering to an response?? - // dont think so - return - } - out := createpkg(in.MsgHdr.Id, false, a) - SendUDP(out, c, a) -} - -func replyTCP(c *net.TCPConn, a net.Addr, in *Msg) { +func handle(c *Conn, in *Msg) { if in.MsgHdr.Response == true { return } - out := createpkg(in.MsgHdr.Id, true, a) - SendTCP(out, c, a) + out := createpkg(in.MsgHdr.Id, true) + c.WriteMsg(out) } func TestResponder(t *testing.T) {