Ensure TSIG state is verified in TestServerRoundtripTsig (#1085)

Automatically submitted.
This commit is contained in:
Dominik Menke 2020-03-11 15:18:07 +01:00 committed by GitHub
parent 40ecd66164
commit 438e446f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -970,13 +970,20 @@ func TestServerRoundtripTsig(t *testing.T) {
s, addrstr, _, err := RunLocalUDPServerWithFinChan(":0", func(srv *Server) {
srv.TsigSecret = secret
srv.MsgAcceptFunc = func(dh Header) MsgAcceptAction {
// defaultMsgAcceptFunc does reject UPDATE queries
return MsgAccept
}
})
if err != nil {
t.Fatalf("unable to run test server: %v", err)
}
defer s.Shutdown()
handlerFired := make(chan struct{})
HandleFunc("example.com.", func(w ResponseWriter, r *Msg) {
close(handlerFired)
m := new(Msg)
m.SetReply(r)
if r.IsTsig() != nil {
@ -991,7 +998,9 @@ func TestServerRoundtripTsig(t *testing.T) {
} else {
t.Error("missing TSIG")
}
w.WriteMsg(m)
if err := w.WriteMsg(m); err != nil {
t.Error("writemsg failed", err)
}
})
c := new(Client)
@ -1013,6 +1022,12 @@ func TestServerRoundtripTsig(t *testing.T) {
if err != nil {
t.Fatal("failed to exchange", err)
}
select {
case <-handlerFired:
// ok, handler was actually called
default:
t.Error("handler was not called")
}
}
func TestResponseAfterClose(t *testing.T) {