Test compile again, but fail

This commit is contained in:
Miek Gieben 2011-03-23 19:03:37 +01:00
parent 369d06f1c7
commit be6f2365cb
5 changed files with 25 additions and 45 deletions

View File

@ -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 */
}

View File

@ -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()
}

View File

@ -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 {

View File

@ -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) */

View File

@ -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) {