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

Function TestIssue327

tests/issue327_test.go:33–91  ·  view source on GitHub ↗
(tt *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestIssue327(tt *testing.T) {
34 tt.Parallel()
35 t := tests.NewT(tt)
36 t.DNS(nil)
37 t.Port("smtp")
38 tgtPort := t.Port("target")
39 t.Config(`
40 hostname mx.maddy.test
41 tls off
42 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
43 deliver_to queue outbound_queue {
44 target remote { } # it will fail
45 autogenerated_msg_domain maddy.test
46 bounce {
47 check {
48 spf
49 }
50 deliver_to lmtp tcp://127.0.0.1:{env:TEST_PORT_target}
51 }
52 }
53 }`)
54 t.Run(1)
55 defer t.Close()
56
57 be, s := testutils.SMTPServer(tt, "127.0.0.1:"+strconv.Itoa(int(tgtPort)))
58 s.LMTP = true
59 be.LMTPDataErr = []error{nil, nil}
60 defer s.Close()
61
62 c := t.Conn("smtp")
63 defer c.Close()
64 c.SMTPNegotation("client.maddy.test", nil, nil)
65 c.Writeln("MAIL FROM:<from@maddy.test>")
66 c.ExpectPattern("250 *")
67 c.Writeln("RCPT TO:<to1@maddy.test>")
68 c.ExpectPattern("250 *")
69 c.Writeln("DATA")
70 c.ExpectPattern("354 *")
71 c.Writeln("From: <from@maddy.test>")
72 c.Writeln("To: <to@maddy.test>")
73 c.Writeln("Subject: Hello!")
74 c.Writeln("")
75 c.Writeln("Hello!")
76 c.Writeln(".")
77 c.ExpectPattern("250 2.0.0 OK: queued")
78 c.Writeln("QUIT")
79 c.ExpectPattern("221 *")
80
81 for i := 0; i < 5; i++ {
82 time.Sleep(1 * time.Second)
83 if len(be.Messages) != 0 {
84 break
85 }
86 }
87
88 if len(be.Messages) != 1 {
89 t.Fatal("No DSN sent?", len(be.Messages))
90 }

Callers

nothing calls this directly

Calls 12

DNSMethod · 0.95
PortMethod · 0.95
ConfigMethod · 0.95
RunMethod · 0.95
CloseMethod · 0.95
ConnMethod · 0.95
NewTFunction · 0.92
SMTPServerFunction · 0.92
SMTPNegotationMethod · 0.80
WritelnMethod · 0.80
ExpectPatternMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected