Skip to content

Commit c558458

Browse files
committed
Added missing file
1 parent 9173a48 commit c558458

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/Smtp2Go.NET.IntegrationTests/Webhooks/WebhookManagementIntegrationTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,39 @@ public WebhookManagementIntegrationTests(Smtp2GoLiveFixture fixture)
4545
#endregion
4646

4747

48+
#region Methods - Helpers
49+
50+
/// <summary>
51+
/// Deletes all existing webhooks on the SMTP2GO account.
52+
/// SMTP2GO free tier limits accounts to 1 webhook — stale webhooks from
53+
/// previous failed runs or E2E tests block creation of new ones.
54+
/// </summary>
55+
private async Task DeleteAllExistingWebhooksAsync(CancellationToken ct)
56+
{
57+
var listResponse = await _fixture.Client.Webhooks.ListAsync(ct);
58+
59+
if (listResponse.Data is not { Length: > 0 })
60+
return;
61+
62+
foreach (var webhook in listResponse.Data)
63+
{
64+
if (webhook.WebhookId is { } id)
65+
{
66+
try
67+
{
68+
await _fixture.Client.Webhooks.DeleteAsync(id, ct);
69+
}
70+
catch
71+
{
72+
// Best-effort cleanup — continue with remaining webhooks.
73+
}
74+
}
75+
}
76+
}
77+
78+
#endregion
79+
80+
4881
#region Webhook Lifecycle
4982

5083
[Fact]
@@ -56,6 +89,9 @@ public async Task WebhookLifecycle_CreateListDelete_Succeeds()
5689
var ct = TestContext.Current.CancellationToken;
5790
int? webhookId = null;
5891

92+
// SMTP2GO free tier allows only 1 webhook — clear stale webhooks from previous runs.
93+
await DeleteAllExistingWebhooksAsync(ct);
94+
5995
try
6096
{
6197
// Step 1: Create a webhook.
@@ -133,6 +169,9 @@ public async Task WebhookCreate_WithSpecificEvents_ConfiguresCorrectly()
133169
var ct = TestContext.Current.CancellationToken;
134170
int? webhookId = null;
135171

172+
// SMTP2GO free tier allows only 1 webhook — clear stale webhooks from previous runs.
173+
await DeleteAllExistingWebhooksAsync(ct);
174+
136175
try
137176
{
138177
// Arrange — Create a webhook with a specific set of event types.

0 commit comments

Comments
 (0)