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

Function TestOutboundRequiresAuth

internal/e2e/e2e_test.go:184–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestOutboundRequiresAuth(t *testing.T) {
185 pool := testutil.TestDB(t)
186 ts := testutil.TestServer(t, pool)
187
188 // Send relocated (Slice 2): POST /v1/agents/{email}/messages. With no
189 // bearer the typed handler authenticates first and 401s before it ever
190 // resolves the path agent.
191 sendPayload := `{"to":["someone@test.com"],"subject":"Hi","body":"Hello"}`
192 req, _ := http.NewRequest("POST", ts.HTTPServer.URL+"/v1/agents/"+url.PathEscape("agent@noauth.example.com")+"/messages", bytes.NewBufferString(sendPayload))
193 req.Header.Set("Content-Type", "application/json")
194 resp, _ := http.DefaultClient.Do(req)
195 defer resp.Body.Close()
196
197 if resp.StatusCode != 401 {
198 t.Errorf("status = %d, want 401", resp.StatusCode)
199 }
200}
201
202func TestReplayProtection(t *testing.T) {
203 pool := testutil.TestDB(t)

Callers

nothing calls this directly

Calls 3

TestDBFunction · 0.92
TestServerFunction · 0.92
CloseMethod · 0.45

Tested by

no test coverage detected