MCPcopy
hub / github.com/coredns/coredns / wildcardMetadataBackend

Function wildcardMetadataBackend

plugin/cache/cache_test.go:1037–1050  ·  view source on GitHub ↗

wildcardMetadataBackend mocks a backend that responds with a response for qname synthesized by wildcard and sets the zone/wildcard metadata value

(qname, wildcard string)

Source from the content-addressed store, hash-verified

1035// wildcardMetadataBackend mocks a backend that responds with a response for qname synthesized by wildcard
1036// and sets the zone/wildcard metadata value
1037func wildcardMetadataBackend(qname, wildcard string) plugin.Handler {
1038 return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
1039 m := new(dns.Msg)
1040 m.SetReply(r)
1041 m.Response, m.RecursionAvailable = true, true
1042 m.Answer = []dns.RR{test.A(qname + " 300 IN A 127.0.0.1")}
1043 metadata.SetValueFunc(ctx, "zone/wildcard", func() string {
1044 return wildcard
1045 })
1046 w.WriteMsg(m)
1047
1048 return dns.RcodeSuccess, nil
1049 })
1050}
1051
1052func TestServfailDoesNotShadowPositiveCache(t *testing.T) {
1053 c := New()

Callers 1

Calls 4

HandlerFuncFuncType · 0.92
AFunction · 0.92
SetValueFuncFunction · 0.92
WriteMsgMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…