Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor logout in tests (#125)
Leendert de Borstc7af544e25c9
diff --git a/src/Tests/AliasVault.E2ETests/Common/AdminPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/AdminPlaywrightTest.csindex e748600b2..ab1303a9e 100644--- a/src/Tests/AliasVault.E2ETests/Common/AdminPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/AdminPlaywrightTest.cs@@ -76,6 +76,16 @@ public class AdminPlaywrightTest : PlaywrightTestawait LoginAsAdmin();}+ /// <summary>+ /// Logout the current user.+ /// </summary>+ /// <returns>Task.</returns>+ protected async Task Logout()+ {+ await NavigateUsingBlazorRouter("user/logout");+ await WaitForUrlAsync("user/login**", "Sign in to");+ }+/// <summary>/// Login to the Admin webapp as the default admin user./// </summary>diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.csindex 815cf1791..d5ee0b749 100644--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs@@ -214,6 +214,16 @@ public class ClientPlaywrightTest : PlaywrightTestawait loginButton.ClickAsync();}+ /// <summary>+ /// Logout the current user.+ /// </summary>+ /// <returns>Task.</returns>+ protected async Task Logout()+ {+ await NavigateUsingBlazorRouter("user/logout");+ await WaitForUrlAsync("user/login**", "Sign in to");+ }+/// <summary>/// Logout the current user and register a new account./// </summary>@@ -221,11 +231,7 @@ public class ClientPlaywrightTest : PlaywrightTestprotected async Task LogoutAndLoginAsNewUser(){// Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/logout", "AliasVault");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login");+ await Logout();// Reset username and password so a new random account is created.TestUserUsername = string.Empty;diff --git a/src/Tests/AliasVault.E2ETests/Tests/Admin/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Admin/AuthTests.csindex 059b9245d..c4b27bba1 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Admin/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Admin/AuthTests.cs@@ -72,9 +72,7 @@ public class AuthTests : AdminPlaywrightTestTestUserPassword = "newnewnew";// Logout.- await NavigateBrowser("user/logout");- await WaitForUrlAsync("user/login**", "Sign in to");-+ await Logout();await LoginAsAdmin();}@@ -86,12 +84,7 @@ public class AuthTests : AdminPlaywrightTest[Test]public async Task LogoutAndLoginTest(){- // Logout.- await NavigateBrowser("user/logout");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login**", "Sign in to");-+ await Logout();var pageContent = await Page.TextContentAsync("body");Assert.That(pageContent, Does.Contain("Sign in to"), "No login page visible after logout.");}diff --git a/src/Tests/AliasVault.E2ETests/Tests/Admin/PasswordLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Admin/PasswordLockoutTests.csindex fbaf38ec8..bd695fb2e 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Admin/PasswordLockoutTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Admin/PasswordLockoutTests.cs@@ -22,11 +22,7 @@ public class PasswordLockoutTests : AdminPlaywrightTest[Test]public async Task AccountLockoutTestPassword(){- // Logout.- await NavigateBrowser("user/logout");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login**", "Sign in to");+ await Logout();var pageContent = await Page.TextContentAsync("body");Assert.That(pageContent, Does.Contain("Login to your"), "No login page visible after logout.");diff --git a/src/Tests/AliasVault.E2ETests/Tests/Admin/TwoFactorAuthLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Admin/TwoFactorAuthLockoutTests.csindex be0aa3494..2947e1a71 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Admin/TwoFactorAuthLockoutTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Admin/TwoFactorAuthLockoutTests.cs@@ -45,10 +45,7 @@ public class TwoFactorAuthLockoutTests : AdminPlaywrightTestawait WaitForUrlAsync("account/manage/enable-authenticator", "Put these codes in a safe place");// Logout.- await NavigateBrowser("user/logout");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login**", "Sign in to");+ await Logout();// Try to login.var pageContent = await Page.TextContentAsync("body");diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.csindex d299ef5c1..f26482ae9 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs@@ -69,12 +69,7 @@ public class AuthPasswordChangeTest : ClientPlaywrightTest// Test logging in again with new password.// Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/logout", "AliasVault");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login");-+ await Logout();await Login();// Wait for the credentials page to load again.diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.csindex c5f4860e2..f37872c65 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs@@ -40,13 +40,7 @@ public class AuthTests : ClientPlaywrightTest[Order(2)]public async Task LogoutAndLoginTest(){- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/logout", "AliasVault");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login");-+ await Logout();await Login();await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");@@ -69,11 +63,7 @@ public class AuthTests : ClientPlaywrightTestpublic async Task RegisterFormWarningTest(){// Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/logout", "AliasVault");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login");+ await Logout();// Try to register a new account.var registerButton = Page.Locator("a[href='/user/register']");@@ -111,9 +101,7 @@ public class AuthTests : ClientPlaywrightTest[Order(4)]public async Task PasswordAuthLockoutTest(){- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/login", "AliasVault");+ await Logout();// Fill in wrong password 11 times. After 11 times, the account should be locked.// Note: the actual lockout happens on the 10th wrong attempt, but the lockout message is only displayeddiff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.csindex 891b86a59..a240b35e3 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs@@ -56,12 +56,7 @@ public class DbUpgradeTests : ClientPlaywrightTest});await ApiDbContext.SaveChangesAsync();- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/logout", "AliasVault");-- // Wait and check if we get redirected to /user/login.- await WaitForUrlAsync("user/login");+ await Logout();await Login();// Wait for two things: either the homepage to show with credentials OR thediff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.csindex c6331621a..6cf583962 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs@@ -26,10 +26,7 @@ public class CodeLockoutTests : TwoFactorAuthBase{await DisableTwoFactorIfEnabled();await EnableTwoFactor();-- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/login", "AliasVault");+ await Logout();// Attempt to log in with test credentials.var emailField = Page.Locator("input[id='email']");diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.csindex 9db037a6e..4f91a4270 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs@@ -27,9 +27,7 @@ public class RecoveryLockoutTests : TwoFactorAuthBaseawait DisableTwoFactorIfEnabled();await EnableTwoFactor();- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/login", "AliasVault");+ await Logout();// Attempt to log in with test credentials.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 eca43afc9..935e0f46c 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs@@ -37,9 +37,7 @@ public class TwoFactorAuthTests : TwoFactorAuthBasevar message = await Page.TextContentAsync("div[role='alert']");Assert.That(message, Does.Contain("Two-factor authentication is now successfully enabled."), "No success message displayed.");- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/login", "AliasVault");+ await Logout();// Attempt to login again with test credentials.var emailField = Page.Locator("input[id='email']");@@ -75,9 +73,7 @@ public class TwoFactorAuthTests : TwoFactorAuthBaseawait DisableTwoFactorIfEnabled();var (_, recoveryCode) = await EnableTwoFactor();- // Logout.- await NavigateUsingBlazorRouter("user/logout");- await WaitForUrlAsync("user/login", "AliasVault");+ await Logout();// Attempt to log in with test credentials.var emailField = Page.Locator("input[id='email']");