Skip to content

Commit 37c9794

Browse files
committed
test: fix destwebhookstandard header to metadata mapper
1 parent 41602d1 commit 37c9794

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

internal/destregistry/providers/destwebhookstandard/destwebhookstandard_publish_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,25 @@ func NewStandardWebhookConsumer() *StandardWebhookConsumer {
4646
metadata := make(map[string]string)
4747
for k, v := range r.Header {
4848
if len(v) > 0 {
49-
// Convert header name to lowercase for consistent access
50-
metadata[strings.ToLower(k)] = v[0]
49+
headerKey := strings.ToLower(k)
50+
// Map Standard Webhooks headers to expected metadata keys
51+
// Standard Webhooks prefixes all headers with "webhook-", so we need to strip it
52+
if strings.HasPrefix(headerKey, "webhook-") {
53+
// Remove "webhook-" prefix to get the actual metadata key
54+
metadataKey := strings.TrimPrefix(headerKey, "webhook-")
55+
// Map to expected keys
56+
switch metadataKey {
57+
case "id":
58+
metadata["event-id"] = v[0]
59+
case "timestamp":
60+
metadata["timestamp"] = v[0]
61+
default:
62+
metadata[metadataKey] = v[0]
63+
}
64+
} else {
65+
// Keep all non-prefixed headers as-is (user-defined metadata)
66+
metadata[headerKey] = v[0]
67+
}
5168
}
5269
}
5370

0 commit comments

Comments
 (0)