MCPcopy
hub / github.com/coredns/coredns / TestProxyTLSFail

Function TestProxyTLSFail

plugin/forward/proxy_test.go:44–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestProxyTLSFail(t *testing.T) {
45 // This is an udp/tcp test server, so we shouldn't reach it with TLS.
46 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
47 ret := new(dns.Msg)
48 ret.SetReply(r)
49 ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1"))
50 w.WriteMsg(ret)
51 })
52 defer s.Close()
53
54 c := caddy.NewTestController("dns", "forward . tls://"+s.Addr)
55 fs, err := parseForward(c)
56 f := fs[0]
57 if err != nil {
58 t.Errorf("Failed to create forwarder: %s", err)
59 }
60 f.OnStartup()
61 defer f.OnShutdown()
62
63 m := new(dns.Msg)
64 m.SetQuestion("example.org.", dns.TypeA)
65 rec := dnstest.NewRecorder(&test.ResponseWriter{})
66
67 if _, err := f.ServeDNS(context.TODO(), rec, m); err == nil {
68 t.Fatal("Expected *not* to receive reply, but got one")
69 }
70}

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
NewServerFunction · 0.92
AFunction · 0.92
NewRecorderFunction · 0.92
parseForwardFunction · 0.85
ErrorfMethod · 0.65
ServeDNSMethod · 0.65
FatalMethod · 0.65
WriteMsgMethod · 0.45
OnStartupMethod · 0.45
OnShutdownMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…