diff --git a/packages/cli/e2e/__tests__/fixtures/test-project/src/alert-channels.ts b/packages/cli/e2e/__tests__/fixtures/test-project/src/alert-channels.ts index f714da4f..9d37523f 100644 --- a/packages/cli/e2e/__tests__/fixtures/test-project/src/alert-channels.ts +++ b/packages/cli/e2e/__tests__/fixtures/test-project/src/alert-channels.ts @@ -46,3 +46,21 @@ export const webhookChannel = new WebhookAlertChannel('webhook-channel-1', { }`, ...sendDefaults, }) + +export const webhookChannelWithSecret = new WebhookAlertChannel('webhook-channel-with-secret', { + name: 'Pushover webhook w/ secret', + method: 'POST', + url: new URL('https://webhook.site/ddead495-8b15-4b0d-a25d-f6cda4144dc7'), + template: `{ + "token":"FILL_IN_YOUR_SECRET_TOKEN_FROM_PUSHOVER", + "user":"FILL_IN_YOUR_USER_FROM_PUSHOVER", + "title":"{{ALERT_TITLE}}", + "html":1, + "priority":2, + "retry":30, + "expire":10800, + "message":"{{ALERT_TYPE}} {{STARTED_AT}} ({{RESPONSE_TIME}}ms) {{RESULT_LINK}}" + }`, + webhookSecret: 'hunter2', + ...sendDefaults, +}) diff --git a/packages/cli/e2e/__tests__/fixtures/test-project/src/services/api/api.check.ts b/packages/cli/e2e/__tests__/fixtures/test-project/src/services/api/api.check.ts index dc316d5d..a348ed45 100644 --- a/packages/cli/e2e/__tests__/fixtures/test-project/src/services/api/api.check.ts +++ b/packages/cli/e2e/__tests__/fixtures/test-project/src/services/api/api.check.ts @@ -1,9 +1,13 @@ import { ApiCheck, AssertionBuilder } from 'checkly/constructs' -import { slackChannel, webhookChannel } from '../../alert-channels' +import { slackChannel, webhookChannel, webhookChannelWithSecret } from '../../alert-channels' const apiCheck = new ApiCheck('homepage-api-check-1', { name: 'Runtimes', - alertChannels: [slackChannel, webhookChannel], + alertChannels: [ + slackChannel, + webhookChannel, + webhookChannelWithSecret, + ], degradedResponseTime: 10000, maxResponseTime: 20000, request: { diff --git a/packages/cli/src/constructs/webhook-alert-channel.ts b/packages/cli/src/constructs/webhook-alert-channel.ts index 8d5efb4d..c3a4bdae 100644 --- a/packages/cli/src/constructs/webhook-alert-channel.ts +++ b/packages/cli/src/constructs/webhook-alert-channel.ts @@ -32,6 +32,13 @@ export interface WebhookAlertChannelProps extends AlertChannelProps { * Key-value elements array with the query parameters to include in the URL for the webhook HTTP request. */ queryParameters?: Array + /** + * An optional value to use as the + * {@link https://www.checklyhq.com/docs/alerting-and-retries/webhooks/#webhook-secrets secret for the webhook}. + * + * You may specify any value that meets your security criteria. + */ + webhookSecret?: string } /** @@ -49,6 +56,7 @@ export class WebhookAlertChannel extends AlertChannel { method?: HttpRequestMethod headers?: Array queryParameters?: Array + webhookSecret?: string /** * Constructs the Webhook Alert Channel instance * @@ -66,6 +74,7 @@ export class WebhookAlertChannel extends AlertChannel { this.method = props.method this.headers = props.headers this.queryParameters = props.queryParameters + this.webhookSecret = props.webhookSecret Session.registerConstruct(this) } @@ -81,6 +90,7 @@ export class WebhookAlertChannel extends AlertChannel { method: this.method, headers: this.headers, queryParameters: this.queryParameters, + webhookSecret: this.webhookSecret, }, } }