Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update AliasVault.Admin startup for e2e tests (#1758)

Leendert de Borst9809d7f33614
diff --git a/apps/server/AliasVault.Admin/Program.cs b/apps/server/AliasVault.Admin/Program.cs
index 1c5788c7c..d79a91861 100644
--- a/apps/server/AliasVault.Admin/Program.cs
+++ b/apps/server/AliasVault.Admin/Program.cs
@@ -166,8 +166,18 @@ using (var scope = app.Services.CreateScope())
var logger = container.GetRequiredService<ILogger<Program>>();
await using var db = await container.GetRequiredService<IAliasServerDbContextFactory>().CreateDbContextAsync();
- // Wait for migrations to be applied (API project runs them centrally)
- await db.WaitForDatabaseReadyAsync(logger);
+ // In test mode, run migrations directly. Otherwise, wait for API to run them.
+ var isTestMode = Environment.GetEnvironmentVariable("ALIASVAULT_TEST_MODE") == "true";
+ if (isTestMode)
+ {
+ logger.LogInformation("Test mode detected. Running migrations directly.");
+ await db.Database.MigrateAsync();
+ }
+ else
+ {
+ // Wait for migrations to be applied (API project runs them centrally)
+ await db.WaitForDatabaseReadyAsync(logger);
+ }
await StartupTasks.CreateRolesIfNotExist(scope.ServiceProvider);
await StartupTasks.SetAdminUser(scope.ServiceProvider);
diff --git a/apps/server/Tests/AliasVault.E2ETests/Infrastructure/Abstracts/WebApplicationFactoryFixture.cs b/apps/server/Tests/AliasVault.E2ETests/Infrastructure/Abstracts/WebApplicationFactoryFixture.cs
index 1ad6cf992..85605de1d 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Infrastructure/Abstracts/WebApplicationFactoryFixture.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Infrastructure/Abstracts/WebApplicationFactoryFixture.cs
@@ -184,5 +184,6 @@ public abstract class WebApplicationFactoryFixture<TEntryPoint> : WebApplication
Environment.SetEnvironmentVariable("PUBLIC_REGISTRATION_ENABLED", "true");
Environment.SetEnvironmentVariable("ADMIN_PASSWORD_HASH", "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag==");
Environment.SetEnvironmentVariable("ADMIN_PASSWORD_GENERATED", "2024-01-01T00:00:00Z");
+ Environment.SetEnvironmentVariable("ALIASVAULT_TEST_MODE", "true");
}
}