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

Function TestHandlerRejectsUnverified

internal/delivery/handler_test.go:12–22  ·  view source on GitHub ↗

failing verifier path: a TopicArn not in the allow-list is rejected before any cert fetch, so the handler returns 403 without network.

(t *testing.T)

Source from the content-addressed store, hash-verified

10// failing verifier path: a TopicArn not in the allow-list is rejected before
11// any cert fetch, so the handler returns 403 without network.
12func TestHandlerRejectsUnverified(t *testing.T) {
13 v := NewVerifier([]string{"arn:aws:sns:us-east-2:1:allowed"}, nil)
14 h := Handler(v, NewConsumer(nil, nil))
15 body := `{"Type":"Notification","TopicArn":"arn:aws:sns:us-east-2:1:EVIL","MessageId":"m","Message":"{}","Timestamp":"t","SignatureVersion":"1","Signature":"x","SigningCertURL":"https://sns.us-east-2.amazonaws.com/c.pem"}`
16 r := httptest.NewRequest(http.MethodPost, "/webhooks/ses", strings.NewReader(body))
17 w := httptest.NewRecorder()
18 h(w, r)
19 if w.Code != http.StatusForbidden {
20 t.Fatalf("unverified message: status=%d, want 403", w.Code)
21 }
22}
23
24func TestHandlerRejectsBadJSON(t *testing.T) {
25 h := Handler(NewVerifier(nil, nil), NewConsumer(nil, nil))

Callers

nothing calls this directly

Calls 3

NewVerifierFunction · 0.85
NewConsumerFunction · 0.85
HandlerFunction · 0.70

Tested by

no test coverage detected