MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / setupWebhook

Function setupWebhook

tests/helpers_test.go:120–138  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, phoneNumber string, events []string)

Source from the content-addressed store, hash-verified

118}
119
120func setupWebhook(ctx context.Context, t *testing.T, phoneNumber string, events []string) (signingKey string, webhookPath string) {
121 t.Helper()
122
123 signingKey = randomEncryptionKey()
124 webhookPath = "/webhooks/" + uuid.New().String()
125 webhookURL := wiremockWebhookURL + webhookPath
126
127 client := newAPIClient()
128 _, resp, err := client.Webhooks.Store(ctx, &httpsms.WebhookStoreParams{
129 SigningKey: signingKey,
130 URL: webhookURL,
131 PhoneNumbers: []string{phoneNumber},
132 Events: events,
133 })
134 require.NoError(t, err)
135 require.Equal(t, http.StatusCreated, resp.HTTPResponse.StatusCode, "webhook store failed")
136
137 return signingKey, webhookPath
138}
139
140func fireEvent(ctx context.Context, t *testing.T, phoneAPIKey string, messageID string, eventName string) {
141 t.Helper()

Callers 4

TestSendSMS_EncryptedFunction · 0.85
TestReceiveSMS_EncryptedFunction · 0.85
TestSendSMS_RateLimitFunction · 0.85

Calls 4

randomEncryptionKeyFunction · 0.85
newAPIClientFunction · 0.85
StoreMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected