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

Function TestScope_ProtectionPutIsAccountOnly

internal/httpapi/scope_test.go:129–144  ·  view source on GitHub ↗

TestScope_ProtectionPutIsAccountOnly: writing protection config is barred for an agent-scoped credential even on its own bound agent (#13). A valid body is sent so the request clears Huma schema validation and reaches the scope gate.

(t *testing.T)

Source from the content-addressed store, hash-verified

127// an agent-scoped credential even on its own bound agent (#13). A valid body is
128// sent so the request clears Huma schema validation and reaches the scope gate.
129func TestScope_ProtectionPutIsAccountOnly(t *testing.T) {
130 srv := scopeTestServer(t)
131 body := map[string]any{
132 "inbound": map[string]any{"gate": map[string]any{}, "scan": map[string]any{}},
133 "outbound": map[string]any{"gate": map[string]any{}, "scan": map[string]any{}},
134 "holds": map[string]any{},
135 }
136 code, _ := sendJSON(t, "PUT", srv.URL+"/v1/agents/support%40acme.com/protection", "acct", body)
137 if code != 200 {
138 t.Errorf("account key PUT protection: status %d, want 200", code)
139 }
140 code, resp := sendJSON(t, "PUT", srv.URL+"/v1/agents/support%40acme.com/protection", "agtSupport", body)
141 if code != 403 || errCode(resp) != "forbidden" {
142 t.Errorf("agent key PUT own protection: status %d body %v, want 403 forbidden", code, resp)
143 }
144}
145
146// TestScope_ApproveRejectIsAccountOnly: HITL approve/reject is barred for an
147// agent-scoped credential EVEN ON ITS OWN BOUND AGENT — self-approval would

Callers

nothing calls this directly

Calls 3

scopeTestServerFunction · 0.85
sendJSONFunction · 0.85
errCodeFunction · 0.85

Tested by

no test coverage detected