Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow updating custom header values of webhook subscriptions #594

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions pagerduty/resource_pagerduty_webhook_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ func TestAccPagerDutyWebhookSubscription_Basic(t *testing.T) {
"pagerduty_webhook_subscription.foo", "events.#", "13"),
),
},
{
Config: testAccCheckPagerDutyWebhookSubscriptionConfig_updateCustomHeaderValue(username, email, escalationPolicy, service, description),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyWebhookSubscriptionExists("pagerduty_webhook_subscription.foo"),
resource.TestCheckResourceAttr(
"pagerduty_webhook_subscription.foo", "description", description),
resource.TestCheckResourceAttr(
"pagerduty_webhook_subscription.foo", "events.#", "13"),
),
ExpectNonEmptyPlan: true,
},
},
})
}
Expand Down Expand Up @@ -175,3 +186,73 @@ func testAccCheckPagerDutyWebhookSubscriptionConfig(username, useremail, escalat
}
`, username, useremail, escalationPolicy, service, description)
}

func testAccCheckPagerDutyWebhookSubscriptionConfig_updateCustomHeaderValue(username, useremail, escalationPolicy, service, description string) string {
return fmt.Sprintf(`
resource "pagerduty_user" "foo" {
name = "%s"
email = "%s"
}

resource "pagerduty_escalation_policy" "foo" {
name = "%s"
description = "foo"
num_loops = 1

rule {
escalation_delay_in_minutes = 10

target {
type = "user_reference"
id = pagerduty_user.foo.id
}
}
}

resource "pagerduty_service" "foo" {
name = "%s"
description = "foo"
auto_resolve_timeout = 1800
acknowledgement_timeout = 1800
escalation_policy = pagerduty_escalation_policy.foo.id

incident_urgency_rule {
type = "constant"
urgency = "high"
}
}

resource "pagerduty_webhook_subscription" "foo" {
delivery_method {
type = "http_delivery_method"
url = "https://example.com/receive_a_pagerduty_webhook"
custom_header {
name = "X-Foo"
value = "bar"
}
}
description = "%s"
events = [
"incident.acknowledged",
"incident.annotated",
"incident.delegated",
"incident.escalated",
"incident.priority_updated",
"incident.reassigned",
"incident.reopened",
"incident.resolved",
"incident.responder.added",
"incident.responder.replied",
"incident.status_update_published",
"incident.triggered",
"incident.unacknowledged"
]
active = true
filter {
id = pagerduty_service.foo.id
type = "service_reference"
}
type = "webhook_subscription"
}
`, username, useremail, escalationPolicy, service, description)
}