MCPcopy Index your code
hub / github.com/foxcpp/maddy / DNS

Method DNS

tests/t.go:104–138  ·  view source on GitHub ↗

DNS sets the DNS zones to emulate for the tested server instance. If it is not called before Run, DNS(nil) call is assumed which makes the mockdns server respond with NXDOMAIN to all queries.

(zones map[string]mockdns.Zone)

Source from the content-addressed store, hash-verified

102// If it is not called before Run, DNS(nil) call is assumed which makes the
103// mockdns server respond with NXDOMAIN to all queries.
104func (t *T) DNS(zones map[string]mockdns.Zone) {
105 t.Helper()
106
107 if zones == nil {
108 zones = map[string]mockdns.Zone{}
109 }
110 if _, ok := zones["100.97.109.127.in-addr.arpa."]; !ok {
111 zones["100.97.109.127.in-addr.arpa."] = mockdns.Zone{PTR: []string{"client.maddy.test."}}
112 }
113
114 if t.dnsServ != nil {
115 t.Log("NOTE: Multiple DNS calls, replacing the server instance...")
116 require.NoError(t, t.dnsServ.Close())
117 }
118
119 dnsServ, err := mockdns.NewServerWithLogger(zones, t, false)
120 if err != nil {
121 t.Fatal("Test configuration failed:", err)
122 }
123 dnsServ.Log = t
124 t.dnsServ = dnsServ
125
126 t.Cleanup(func() {
127 if t.dnsServ == nil {
128 return
129 }
130
131 // Shutdown the DNS server after maddy to make sure it will not spend time
132 // timing out queries.
133 if err := t.dnsServ.Close(); err != nil {
134 t.Log("Unable to stop the DNS server:", err)
135 }
136 t.dnsServ = nil
137 })
138}
139
140// Port allocates the random TCP port for use by test. It will made accessible
141// in the configuration via environment variables with name in the form

Callers 15

TestConcurrencyLimitFunction · 0.95
TestPerIPConcurrencyFunction · 0.95
TestImapsqlDeliveryFunction · 0.95
TestImapsqlDeliveryMapFunction · 0.95
TestImapsqlAuthMapFunction · 0.95
TestLMTPClient_Issue308Function · 0.95
TestLDAPInjectionFilterFunction · 0.95
TestDovecotSASLClientFunction · 0.95

Calls 1

CloseMethod · 0.65

Tested by 15

TestConcurrencyLimitFunction · 0.76
TestPerIPConcurrencyFunction · 0.76
TestImapsqlDeliveryFunction · 0.76
TestImapsqlDeliveryMapFunction · 0.76
TestImapsqlAuthMapFunction · 0.76
TestLMTPClient_Issue308Function · 0.76
TestLDAPInjectionFilterFunction · 0.76
TestDovecotSASLClientFunction · 0.76