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)
| 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. |
| 12 | func 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 | |
| 24 | func TestHandlerRejectsBadJSON(t *testing.T) { |
| 25 | h := Handler(NewVerifier(nil, nil), NewConsumer(nil, nil)) |
nothing calls this directly
no test coverage detected