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

Function TestEventsDisabledReturns501

internal/httpapi/events_test.go:129–151  ·  view source on GitHub ↗

TestEventsDisabledReturns501 pins the gate: when the durable event log is off (EventsEnabled=false, i.e. WEBHOOKS_OUTBOX_ENABLED unset in prod), the list/get/redeliver endpoints must return 501 events_log_disabled rather than querying the empty webhook_events table and masquerading as "no events".

(t *testing.T)

Source from the content-addressed store, hash-verified

127// list/get/redeliver endpoints must return 501 events_log_disabled rather than
128// querying the empty webhook_events table and masquerading as "no events".
129func TestEventsDisabledReturns501(t *testing.T) {
130 srv := httptest.NewServer(New(Deps{
131 EventsEnabled: false,
132 Authenticator: func(r *http.Request) (*identity.User, error) {
133 if r.Header.Get("Authorization") == "Bearer good" {
134 return &identity.User{ID: "u_1", Email: "owner@acme.com"}, nil
135 }
136 return nil, errors.New("unauthorized")
137 },
138 }))
139 defer srv.Close()
140
141 for _, path := range []string{"/v1/events?limit=5", "/v1/events/evt_a"} {
142 code, body := getJSON(t, srv.URL+path, "good")
143 if code != 501 || errCode(body) != "events_log_disabled" {
144 t.Fatalf("GET %s: want 501 events_log_disabled, got %d %v", path, code, body)
145 }
146 }
147 code, body := postJSON(t, srv.URL+"/v1/events/evt_a/redeliver", "good", map[string]any{})
148 if code != 501 || errCode(body) != "events_log_disabled" {
149 t.Fatalf("redeliver: want 501 events_log_disabled, got %d %v", code, body)
150 }
151}

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
getJSONFunction · 0.85
errCodeFunction · 0.85
postJSONFunction · 0.85
NewFunction · 0.70
GetMethod · 0.65

Tested by

no test coverage detected