MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / injectInboundMessage

Method injectInboundMessage

tests/contract/contract_test.go:155–176  ·  view source on GitHub ↗
(t *testing.T, agentEmail, from, subject string)

Source from the content-addressed store, hash-verified

153}
154
155func (e *testEnv) injectInboundMessage(t *testing.T, agentEmail, from, subject string) string {
156 t.Helper()
157 ctx := context.Background()
158 ag, err := e.store.GetAgentByEmail(ctx, agentEmail)
159 if err != nil {
160 t.Fatalf("get agent: %v", err)
161 }
162 // A faithful inbound message carries its raw MIME and the X-E2A-Auth-* blob
163 // the relay stamps after SPF/DKIM/DMARC — without auth_headers the detail
164 // view omits the field (it is omitempty), which is not how a real received
165 // message looks. Populate both so the contract exercises the real shape.
166 raw := []byte("From: " + from + "\r\nTo: " + agentEmail + "\r\nSubject: " + subject + "\r\n\r\nbody\r\n")
167 authHeaders := map[string]string{
168 "X-E2A-Auth-Results": "spf=pass; dkim=pass; dmarc=pass",
169 "X-E2A-Auth-Verified": "true",
170 }
171 msg, err := e.store.CreateInboundMessage(ctx, "", ag.ID, from, agentEmail, "", subject, "", "unread", raw, authHeaders, nil, false, "", nil, nil, nil, identity.InboundScreening{})
172 if err != nil {
173 t.Fatalf("store message: %v", err)
174 }
175 return msg.ID
176}
177
178// ── Scenario runner ────────────────────────────────────────────────
179

Callers 2

executeSetupMethod · 0.80
execInjectMessageMethod · 0.80

Calls 2

GetAgentByEmailMethod · 0.65
CreateInboundMessageMethod · 0.65

Tested by

no test coverage detected