MCPcopy Create free account
hub / github.com/foxcpp/maddy / TestDkimVerify_FailOpen

Function TestDkimVerify_FailOpen

internal/check/dkim/dkim_test.go:312–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

310}
311
312func TestDkimVerify_FailOpen(t *testing.T) {
313 zones := map[string]mockdns.Zone{
314 "brisbane._domainkey.example.com.": {
315 Err: &net.DNSError{
316 Err: "DNS server is not having a great time",
317 IsTemporary: true,
318 IsTimeout: true,
319 },
320 },
321 }
322 check := testCheck(t, zones, []config.Node{
323 {
324 Name: "fail_open",
325 Args: []string{"true"},
326 },
327 })
328
329 ctx, cancel := context.WithCancel(context.Background())
330 defer cancel()
331
332 s, err := check.CheckStateForMsg(ctx, &module.MsgMetadata{
333 ID: "test_unsigned",
334 })
335 if err != nil {
336 t.Fatal(err)
337 }
338
339 s.CheckConnection(ctx)
340 s.CheckSender(ctx, "joe@football.example.com")
341 s.CheckRcpt(ctx, "suzie@shopping.example.net")
342
343 hdr, buf := testutils.BodyFromStr(t, verifiedMailString)
344
345 result := s.CheckBody(ctx, hdr, buf)
346
347 t.Log("auth. result:", authres.Format("", result.AuthResult))
348 if result.Reason == nil {
349 t.Fatal("No check fail reason set, auth. result:", authres.Format("", result.AuthResult))
350 }
351 if result.Reject {
352 t.Fatal("Reject requested")
353 }
354 if exterrors.IsTemporary(result.Reason) {
355 t.Fatal("Fail reason is not marked as temporary:", result.Reason)
356 }
357
358 if len(result.AuthResult) != 1 {
359 t.Fatal("Wrong amount of auth. result fields:", len(result.AuthResult))
360 }
361 resVal := result.AuthResult[0].(*authres.DKIMResult).Value
362 if resVal != authres.ResultTempError {
363 t.Fatal("Result is not temp. error:", resVal)
364 }
365}

Callers

nothing calls this directly

Calls 8

BodyFromStrFunction · 0.92
IsTemporaryFunction · 0.92
testCheckFunction · 0.85
CheckStateForMsgMethod · 0.65
CheckConnectionMethod · 0.65
CheckSenderMethod · 0.65
CheckRcptMethod · 0.65
CheckBodyMethod · 0.65

Tested by

no test coverage detected