Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add tweaks to tests for improved stability (#125)
Leendert de Borst633cef3450a8
diff --git a/src/AliasVault.Client/Auth/Pages/Login.razor b/src/AliasVault.Client/Auth/Pages/Login.razorindex 241054029..0c92b5b45 100644--- a/src/AliasVault.Client/Auth/Pages/Login.razor+++ b/src/AliasVault.Client/Auth/Pages/Login.razor@@ -375,8 +375,6 @@ else/// </summary>private async Task<List<string>> ProcessLoginVerify(ValidateLoginResponse validateLoginResponse){- Console.WriteLine("ProcessLoginVerify called...");-// 5. Client verifies proof.Srp.VerifySession(ClientEphemeral.Public, ClientSession, validateLoginResponse.ServerSessionProof);diff --git a/src/AliasVault.Client/Auth/Pages/Logout.razor b/src/AliasVault.Client/Auth/Pages/Logout.razorindex c7b381ec1..0e49891fa 100644--- a/src/AliasVault.Client/Auth/Pages/Logout.razor+++ b/src/AliasVault.Client/Auth/Pages/Logout.razor@@ -25,8 +25,6 @@/// <inheritdoc />protected override async Task OnInitializedAsync(){- await Task.Delay(500);-await base.OnInitializedAsync();await AuthService.RemoveTokensAsync();AuthService.RemoveEncryptionKey();@@ -36,6 +34,8 @@DbService.InitializeEmptyDatabase();GlobalNotificationService.ClearMessages();+ await Task.Delay(500);+// Redirect to home pageNavigationManager.NavigateTo("/");}diff --git a/src/AliasVault.Client/Main/Pages/Sync/Sync.razor b/src/AliasVault.Client/Main/Pages/Sync/Sync.razorindex 1a449a35f..d442a2fa5 100644--- a/src/AliasVault.Client/Main/Pages/Sync/Sync.razor+++ b/src/AliasVault.Client/Main/Pages/Sync/Sync.razor@@ -108,7 +108,9 @@private async Task RedirectBackToReturnUrl(){var localStorageReturnUrl = await LocalStorage.GetItemAsync<string>(ReturnUrlKey);- if (!string.IsNullOrEmpty(localStorageReturnUrl) && localStorageReturnUrl != "/sync")+ var disallowedUrls = new[] { "/sync", "/unlock", "/user/logout" };++ if (!string.IsNullOrEmpty(localStorageReturnUrl) && !disallowedUrls.Contains(localStorageReturnUrl)){await LocalStorage.RemoveItemAsync(ReturnUrlKey);NavigationManager.NavigateTo(localStorageReturnUrl);diff --git a/src/AliasVault.Client/Services/Auth/AliasVaultApiHandlerService.cs b/src/AliasVault.Client/Services/Auth/AliasVaultApiHandlerService.csindex 897bcf767..620184aa8 100644--- a/src/AliasVault.Client/Services/Auth/AliasVaultApiHandlerService.cs+++ b/src/AliasVault.Client/Services/Auth/AliasVaultApiHandlerService.cs@@ -54,15 +54,15 @@ public sealed class AliasVaultApiHandlerService(IServiceProvider serviceProviderresponse = await base.SendAsync(request, cancellationToken);return response;}- else- {- // Refreshing token failed. This might be caused by the expiration or revocation of the refresh token itself.- // Remove the token from local storage and redirect to the login page.- await authService.RemoveTokensAsync();- var navigationManager = serviceProvider.GetRequiredService<NavigationManager>();- navigationManager.NavigateTo("/user/login");- }+ Console.WriteLine("Failed to refresh token, redirect to login.");++ // Refreshing token failed. This might be caused by the expiration or revocation of the refresh token itself.+ // Remove the token from local storage and redirect to the login page.+ await authService.RemoveTokensAsync();++ var navigationManager = serviceProvider.GetRequiredService<NavigationManager>();+ navigationManager.NavigateTo("/user/login");}return response;diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.csindex d5ee0b749..2b9725423 100644--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs@@ -5,7 +5,8 @@// </copyright>//------------------------------------------------------------------------[assembly: LevelOfParallelism(4)]+// Run tests in parallel with a maximum of 2 parallel tests.+[assembly: LevelOfParallelism(2)]namespace AliasVault.E2ETests.Common;@@ -198,15 +199,19 @@ public class ClientPlaywrightTest : PlaywrightTest/// <returns>Async task.</returns>protected async Task Login(){- await NavigateUsingBlazorRouter("/");-// Check that we are on the login page after navigating to the base URL.// We are expecting to not be authenticated and thus to be redirected to the login page.- await WaitForUrlAsync("user/login");+ await WaitForUrlAsync("user/login", "Your username");++ // Wait for 100ms to ensure the page has loaded.+ // Note: the default Playwright "waitfor" logic didn't work here and caused the form to be filled+ // before it was actually fully rendered thus losing the input...+ await Task.Delay(100);// Try to log in with test credentials.var emailField = Page.Locator("input[id='email']");var passwordField = Page.Locator("input[id='password']");+await emailField.FillAsync(TestUserUsername);await passwordField.FillAsync(TestUserPassword);@@ -275,6 +280,6 @@ public class ClientPlaywrightTest : PlaywrightTestawait submitButton.ClickAsync();// Check if we get redirected to the root URL after registration which means we are logged in.- await WaitForUrlAsync(AppBaseUrl, "Getting Started");+ await WaitForUrlAsync("welcome**", "Getting Started");}}diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.csindex f37872c65..5e82c1866 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs@@ -43,11 +43,12 @@ public class AuthTests : ClientPlaywrightTestawait Logout();await Login();- await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");+ // Wait for the index page to load which should show "Credentials" in the top menu.+ await WaitForUrlAsync("**", "Credentials");// Check if the login was successful by verifying content.var pageContent = await Page.TextContentAsync("body");- Assert.That(pageContent, Does.Contain("Welcome to AliasVault"), "No index content after logging in.");+ Assert.That(pageContent, Does.Contain("Getting Started"), "No index content after logging in.");// Check if login has created an auth log entry.var authLogEntry = await ApiDbContext.AuthLogs.FirstOrDefaultAsync(x => x.Username == TestUserUsername && x.EventType == AuthEventType.Login);@@ -70,8 +71,9 @@ public class AuthTests : ClientPlaywrightTestawait registerButton.ClickAsync();await WaitForUrlAsync("user/register", "Create a new AliasVault account");- // Wait for the form to be fully loaded- await Page.WaitForSelectorAsync("form");+ // Wait for .1 seconds to ensure the page is fully loaded.+ // Note: this is a workaround for a Playwright issue where the page is not fully loaded when the test continues.+ await Task.Delay(100);// Register account with same test credentials as used in the initial registration bootstrap method.var emailField = Page.Locator("input[id='email']");diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.csindex 935e0f46c..876a4b941 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs@@ -60,7 +60,7 @@ public class TwoFactorAuthTests : TwoFactorAuthBaseawait submitButton.ClickAsync();// Check if we get redirected to the index page.- await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");+ await WaitForUrlAsync("welcome**", "Getting Started");}/// <summary>@@ -100,6 +100,6 @@ public class TwoFactorAuthTests : TwoFactorAuthBaseawait submitButton.ClickAsync();// Check if we get redirected to the index page.- await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");+ await WaitForUrlAsync("welcome**", "Getting Started");}}