Added the use of DEK's for encryption of secrets. Both the KEK's and DEK's are stored in a way that you can have multiple key of which one is active. But the others are still available for decrypting. This allows for implementing key rotation. Co-authored-by: eelke <eelke@eelkeklein.nl> Co-authored-by: Eelke76 <31384324+Eelke76@users.noreply.github.com> Reviewed-on: #6
56 lines
No EOL
1.8 KiB
C#
56 lines
No EOL
1.8 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Testcontainers.PostgreSql;
|
|
|
|
namespace IdentityShroud.Core.Tests.Fixtures;
|
|
|
|
public class ApplicationFactory : WebApplicationFactory<Program>, IAsyncLifetime
|
|
{
|
|
private readonly PostgreSqlContainer _postgresqlServer;
|
|
|
|
// public IRealmService RealmService { get; } = Substitute.For<IRealmService>();
|
|
|
|
public ApplicationFactory()
|
|
{
|
|
_postgresqlServer = new PostgreSqlBuilder("postgres:18.1")
|
|
.WithName($"is-applicationFactory-{Guid.NewGuid():N}")
|
|
.Build();
|
|
}
|
|
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
{
|
|
base.ConfigureWebHost(builder);
|
|
|
|
builder.ConfigureAppConfiguration((context, configBuilder) =>
|
|
{
|
|
configBuilder.AddInMemoryCollection(
|
|
new Dictionary<string, string?>
|
|
{
|
|
["Db:ConnectionString"] = _postgresqlServer.GetConnectionString(),
|
|
["secrets:master:0:Id"] = "94970f27-3d88-4223-9940-7dd57548f5b5",
|
|
["secrets:master:0:Active"] = "true",
|
|
["secrets:master:0:Algorithm"] = "AES",
|
|
["secrets:master:0:Key"] = "GVd07qW0frRX9quPX/X62L88BeRR7+IzgRJHtG7ZzHw=",
|
|
});
|
|
});
|
|
|
|
// builder.ConfigureServices(services =>
|
|
// {
|
|
// services.AddScoped<IRealmService>(c => RealmService);
|
|
// });
|
|
|
|
builder.UseEnvironment("Development");
|
|
}
|
|
|
|
public async ValueTask InitializeAsync()
|
|
{
|
|
await _postgresqlServer.StartAsync();
|
|
}
|
|
|
|
public override async ValueTask DisposeAsync()
|
|
{
|
|
await _postgresqlServer.StopAsync();
|
|
await base.DisposeAsync();
|
|
}
|
|
} |