(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestSpoof(t *testing.T) { |
| 15 | // Send query for example.org, get reply for example.net; should not be cached. |
| 16 | c := New() |
| 17 | c.Next = spoofHandler(true) |
| 18 | |
| 19 | req := new(dns.Msg) |
| 20 | req.SetQuestion("example.org.", dns.TypeA) |
| 21 | rec := dnstest.NewRecorder(&test.ResponseWriter{}) |
| 22 | |
| 23 | c.ServeDNS(context.TODO(), rec, req) |
| 24 | |
| 25 | qname := rec.Msg.Question[0].Name |
| 26 | if c.pcache.Len() != 0 { |
| 27 | t.Errorf("Cached %s, while reply had %s", "example.org.", qname) |
| 28 | } |
| 29 | |
| 30 | // qtype |
| 31 | c.Next = spoofHandlerType() |
| 32 | req.SetQuestion("example.org.", dns.TypeMX) |
| 33 | |
| 34 | c.ServeDNS(context.TODO(), rec, req) |
| 35 | |
| 36 | qtype := rec.Msg.Question[0].Qtype |
| 37 | if c.pcache.Len() != 0 { |
| 38 | t.Errorf("Cached %s type %d, while reply had %d", "example.org.", dns.TypeMX, qtype) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestResponse(t *testing.T) { |
| 43 | // Send query for example.org, get reply for example.net; should not be cached. |
nothing calls this directly
no test coverage detected
searching dependent graphs…