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

Function TestSendRateLimited

internal/httpapi/ratelimit_test.go:192–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func TestSendRateLimited(t *testing.T) {
193 srv := serverWithSendLimit(t)
194 code, body := postJSON(t, srv.URL+"/v1/agents/support%40acme.com/messages", "good", map[string]any{
195 "to": []string{"a@x.com"}, "subject": "Hi", "body": "hello",
196 })
197 if code != 429 || errCode(body) != "rate_limited" {
198 t.Fatalf("want 429 rate_limited, got %d %v", code, body)
199 }
200 e, _ := body["error"].(map[string]any)
201 d, _ := e["details"].(map[string]any)
202 if d == nil || d["retry_after_seconds"].(float64) != 7 {
203 t.Fatalf("expected retry_after_seconds=7 in details, got %v", body)
204 }
205}
206
207// TestClientIPIgnoresXForwardedFor locks in the per-IP-limiter security
208// contract: the caller key comes from CF-Connecting-IP (edge-set, not

Callers

nothing calls this directly

Calls 3

serverWithSendLimitFunction · 0.85
postJSONFunction · 0.85
errCodeFunction · 0.85

Tested by

no test coverage detected