This commit is contained in:
StellaOps Bot
2025-12-11 08:20:04 +02:00
parent 49922dff5a
commit b8b493913a
82 changed files with 14053 additions and 1705 deletions

View File

@@ -17,6 +17,7 @@ public sealed class NotifyApiEndpointsTests : IClassFixture<WebApplicationFactor
private readonly HttpClient _client;
private readonly InMemoryRuleRepository _ruleRepository;
private readonly InMemoryTemplateRepository _templateRepository;
private readonly WebApplicationFactory<WebProgram> _factory;
public NotifyApiEndpointsTests(WebApplicationFactory<WebProgram> factory)
{
@@ -33,6 +34,8 @@ public sealed class NotifyApiEndpointsTests : IClassFixture<WebApplicationFactor
builder.UseSetting("Environment", "Testing");
});
_factory = customFactory;
_client = customFactory.CreateClient();
_client.DefaultRequestHeaders.Add("X-StellaOps-Tenant", "test-tenant");
}
@@ -98,7 +101,13 @@ public sealed class NotifyApiEndpointsTests : IClassFixture<WebApplicationFactor
tenantId: "test-tenant",
name: "Existing Rule",
match: NotifyRuleMatch.Create(eventKinds: ["test.event"]),
actions: []);
actions: new[]
{
NotifyRuleAction.Create(
actionId: "action-001",
channel: "slack:alerts",
template: "tmpl-001")
});
await _ruleRepository.UpsertAsync(rule);
// Act
@@ -130,7 +139,13 @@ public sealed class NotifyApiEndpointsTests : IClassFixture<WebApplicationFactor
tenantId: "test-tenant",
name: "Delete Me",
match: NotifyRuleMatch.Create(),
actions: []);
actions: new[]
{
NotifyRuleAction.Create(
actionId: "action-001",
channel: "slack:alerts",
template: "tmpl-001")
});
await _ruleRepository.UpsertAsync(rule);
// Act
@@ -255,13 +270,13 @@ public sealed class NotifyApiEndpointsTests : IClassFixture<WebApplicationFactor
public async Task AllEndpoints_ReturnBadRequest_WhenTenantMissing()
{
// Arrange
var clientWithoutTenant = new HttpClient { BaseAddress = _client.BaseAddress };
var clientWithoutTenant = _factory.CreateClient();
// Act
var response = await clientWithoutTenant.GetAsync("/api/v2/notify/rules");
// Assert - should fail without tenant header
// Note: actual behavior depends on endpoint implementation
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}
#endregion