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

Function doTestDelivery

internal/msgpipeline/dmarc_test.go:41–81  ·  view source on GitHub ↗
(t *testing.T, tgt module.DeliveryTarget, from string, to []string, hdr string)

Source from the content-addressed store, hash-verified

39)
40
41func doTestDelivery(t *testing.T, tgt module.DeliveryTarget, from string, to []string, hdr string) (string, error) {
42 t.Helper()
43
44 IDRaw := sha1.Sum([]byte(t.Name()))
45 encodedID := hex.EncodeToString(IDRaw[:])
46
47 body := buffer.MemoryBuffer{Slice: []byte("foobar")}
48 ctx := module.MsgMetadata{
49 DontTraceSender: true,
50 ID: encodedID,
51 }
52
53 hdrParsed, err := textproto.ReadHeader(bufio.NewReader(strings.NewReader(hdr)))
54 if err != nil {
55 panic(err)
56 }
57
58 delivery, err := tgt.StartDelivery(context.Background(), &ctx, from)
59 if err != nil {
60 return encodedID, err
61 }
62 for _, rcpt := range to {
63 if err := delivery.AddRcpt(context.Background(), rcpt, smtp.RcptOptions{}); err != nil {
64 if err := delivery.Abort(context.Background()); err != nil {
65 t.Log("delivery.Abort:", err)
66 }
67 return encodedID, err
68 }
69 }
70 if err := delivery.Body(context.Background(), hdrParsed, body); err != nil {
71 if err := delivery.Abort(context.Background()); err != nil {
72 t.Log("delivery.Abort:", err)
73 }
74 return encodedID, err
75 }
76 if err := delivery.Commit(context.Background()); err != nil {
77 return encodedID, err
78 }
79
80 return encodedID, err
81}
82
83func dmarcResult(t *testing.T, hdr textproto.Header) authres.ResultValue {
84 field := hdr.Get("Authentication-Results")

Callers 1

TestDMARCFunction · 0.70

Calls 6

NameMethod · 0.65
StartDeliveryMethod · 0.65
AddRcptMethod · 0.65
AbortMethod · 0.65
BodyMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected