(tt *testing.T)
| 32 | ) |
| 33 | |
| 34 | func TestMTA_Outbound(tt *testing.T) { |
| 35 | t := tests.NewT(tt) |
| 36 | t.DNS(map[string]mockdns.Zone{ |
| 37 | "example.invalid.": { |
| 38 | MX: []net.MX{{Host: "mx.example.invalid.", Pref: 10}}, |
| 39 | }, |
| 40 | "mx.example.invalid.": { |
| 41 | A: []string{"127.0.0.1"}, |
| 42 | }, |
| 43 | }) |
| 44 | t.Port("smtp") |
| 45 | tgtPort := t.Port("remote_smtp") |
| 46 | t.Config(` |
| 47 | hostname mx.maddy.test |
| 48 | tls off |
| 49 | smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} { |
| 50 | deliver_to remote |
| 51 | }`) |
| 52 | t.Run(1) |
| 53 | defer t.Close() |
| 54 | |
| 55 | be, s := testutils.SMTPServer(tt, "127.0.0.1:"+strconv.Itoa(int(tgtPort))) |
| 56 | defer s.Close() |
| 57 | |
| 58 | c := t.Conn("smtp") |
| 59 | defer c.Close() |
| 60 | c.SMTPNegotation("client.maddy.test", nil, nil) |
| 61 | c.Writeln("MAIL FROM:<from@maddy.test>") |
| 62 | c.ExpectPattern("250 *") |
| 63 | c.Writeln("RCPT TO:<to1@example.invalid>") |
| 64 | c.ExpectPattern("250 *") |
| 65 | c.Writeln("RCPT TO:<to2@example.invalid>") |
| 66 | c.ExpectPattern("250 *") |
| 67 | c.Writeln("DATA") |
| 68 | c.ExpectPattern("354 *") |
| 69 | c.Writeln("From: <from@maddy.test>") |
| 70 | c.Writeln("To: <to@maddy.test>") |
| 71 | c.Writeln("Subject: Hello!") |
| 72 | c.Writeln("") |
| 73 | c.Writeln("Hello!") |
| 74 | c.Writeln(".") |
| 75 | c.ExpectPattern("250 2.0.0 OK: queued") |
| 76 | c.Writeln("QUIT") |
| 77 | c.ExpectPattern("221 *") |
| 78 | |
| 79 | if be.SessionCounter != 1 { |
| 80 | t.Fatal("No actual connection made?", be.SessionCounter) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestIssue321(tt *testing.T) { |
| 85 | t := tests.NewT(tt) |
nothing calls this directly
no test coverage detected