2026-07-16 21:19:16 +00:00
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
|
|
|
|
|
|
|
|
namespace Heimdall.IntegrationTests.Factories;
|
|
|
|
|
|
2026-07-17 13:15:25 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// WebApplicationFactory for integration tests.
|
|
|
|
|
/// Uses unique InMemory database name per instance to prevent test pollution.
|
|
|
|
|
/// </summary>
|
2026-07-16 21:19:16 +00:00
|
|
|
public class HeimdallWebApplicationFactory : WebApplicationFactory<Program>
|
|
|
|
|
{
|
2026-07-17 13:15:25 +00:00
|
|
|
private readonly string _dbName = $"HeimdallTest_{Guid.NewGuid():N}";
|
2026-07-16 21:19:16 +00:00
|
|
|
|
|
|
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
builder.UseEnvironment("Testing");
|
|
|
|
|
builder.UseSetting("Cors:AllowedOrigins", "*");
|
2026-07-17 13:15:25 +00:00
|
|
|
builder.UseSetting("InMemoryDbName", _dbName);
|
|
|
|
|
// JWT config
|
|
|
|
|
builder.UseSetting("Jwt:Key", "ThisIsATestKeyThatIsAtLeast32BytesLong!");
|
2026-07-21 08:57:53 +00:00
|
|
|
builder.UseSetting("Jwt:RefreshKey", "ThisIsATestRefreshKeyThatIsAlso32Bytes!");
|
2026-07-17 13:15:25 +00:00
|
|
|
builder.UseSetting("Jwt:Issuer", "heimdall-test");
|
|
|
|
|
builder.UseSetting("Jwt:Audience", "heimdall-test");
|
2026-07-16 21:19:16 +00:00
|
|
|
}
|
|
|
|
|
}
|