(t *testing.T)
| 310 | } |
| 311 | |
| 312 | func 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 | } |
nothing calls this directly
no test coverage detected