Skip to content

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

Add GenerateAvuxTestFile test export and import (#773)

Leendert de Borst038c24a9f7ac
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor
index 5c73048bb..4210f43ec 100644
--- a/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor
@@ -18,6 +18,7 @@
@if (isLastInput)
{
<button type="button"
+ id="@($"add-{Id}")"
@onclick="AddValue"
@onclick:preventDefault="true"
class="absolute right-2 top-1/2 -translate-y-1/2 w-6 h-6 flex items-center justify-center text-gray-400 hover:text-primary-500 dark:hover:text-primary-400 transition-colors">
diff --git a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
index 068a8b0b2..40e5f8ac1 100644
--- a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
+++ b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
@@ -54,13 +54,13 @@
</div>
<p class="mb-4 text-sm text-gray-500 dark:text-gray-400">@Localizer["TotpInstructions"]</p>
<div class="mb-4">
- <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["NameOptionalLabel"]</label>
- <InputText id="name" @bind-Value="NewTotpCode.Name" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" />
+ <label for="totp-name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["NameOptionalLabel"]</label>
+ <InputText id="totp-name" @bind-Value="NewTotpCode.Name" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" />
<ValidationMessage For="@(() => NewTotpCode.Name)" class="text-red-600 dark:text-red-400 text-sm mt-1" />
</div>
<div class="mb-4">
- <label for="secretKey" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["SecretKeyLabel"]</label>
- <InputText id="secretKey" @bind-Value="NewTotpCode.SecretKey" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="@Localizer["SecretKeyPlaceholder"]" />
+ <label for="totp-secret" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["SecretKeyLabel"]</label>
+ <InputText id="totp-secret" @bind-Value="NewTotpCode.SecretKey" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="@Localizer["SecretKeyPlaceholder"]" />
<ValidationMessage For="@(() => NewTotpCode.SecretKey)" class="text-red-600 dark:text-red-400 text-sm mt-1" />
</div>
<div class="flex justify-end">
diff --git a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
index 32cf85e7e..59881c3a0 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
@@ -322,12 +322,12 @@ else
<EditFormRow Id="expiry-year" Label="@Localizer["ExpiryYearLabel"]" Placeholder="YYYY" @bind-Value="Obj.GetField(FieldKey.CardExpiryYear)!.Value"></EditFormRow>
</div>
<div class="col-span-6 sm:col-span-3">
- <EditPasswordFormRow Id="card-cvv" Label="@Localizer["CardCvvLabel"]" @bind-Value="Obj.GetField(FieldKey.CardCvv)!.Value" ShowPassword="false" ShowGenerateButtons="false"></EditPasswordFormRow>
+ <EditPasswordFormRow Id="cvv" Label="@Localizer["CardCvvLabel"]" @bind-Value="Obj.GetField(FieldKey.CardCvv)!.Value" ShowPassword="false" ShowGenerateButtons="false"></EditPasswordFormRow>
</div>
@if (ShouldShowField(FieldKey.CardPin))
{
<div class="col-span-6 sm:col-span-3 relative">
- <EditPasswordFormRow Id="card-pin" Label="@Localizer["CardPinLabel"]" @bind-Value="Obj.GetField(FieldKey.CardPin)!.Value" ShowPassword="false"></EditPasswordFormRow>
+ <EditPasswordFormRow Id="pin" Label="@Localizer["CardPinLabel"]" @bind-Value="Obj.GetField(FieldKey.CardPin)!.Value" ShowPassword="false"></EditPasswordFormRow>
@if (CanRemoveField(FieldKey.CardPin))
{
<button type="button" @onclick="() => RemoveOptionalField(FieldKey.CardPin)" @onclick:preventDefault="true"
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
index 928fcb813..eb844339c 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor
@@ -13,7 +13,7 @@
@using AliasClientDb
@using AliasClientDb.Models
-<div @onclick="OpenImportModal" class="flex flex-col p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors duration-200">
+<div @onclick="OpenImportModal" data-import-service="@ServiceName" class="flex flex-col p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors duration-200">
<div class="flex items-center">
<div class="w-12 h-12 mr-3 flex-shrink-0 rounded-md flex items-center justify-center">
@if (!string.IsNullOrEmpty(LogoUrl))
diff --git a/apps/server/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj b/apps/server/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
index 6446924e1..a6eb0e3af 100644
--- a/apps/server/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
+++ b/apps/server/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
@@ -27,6 +27,8 @@
<EmbeddedResource Include="TestData\TestAttachment.txt" />
<None Remove="TestData\TestImportBitwarden.csv" />
<EmbeddedResource Include="TestData\TestImportBitwarden.csv" />
+ <None Remove="TestData\TestVault.avux" />
+ <EmbeddedResource Include="TestData\TestVault.avux" />
</ItemGroup>
<ItemGroup>
diff --git a/apps/server/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/apps/server/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
index 792e4ee5c..c7ca74379 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
@@ -285,6 +285,16 @@ public abstract class ClientPlaywrightTest : PlaywrightTest
formValues["email"] = localPart;
}
+ // Check if notes field is specified. For Login items, notes is now a separate section that needs to be added.
+ if (formValues != null && formValues.ContainsKey("notes") && !string.IsNullOrEmpty(formValues["notes"]))
+ {
+ // Add the Notes section via the + menu
+ await AddFieldSectionAsync("Notes");
+
+ // Wait for the notes textarea to appear
+ await Page.WaitForSelectorAsync("textarea#notes", new() { State = WaitForSelectorState.Visible, Timeout = 5000 });
+ }
+
// Fill all input fields with specified values and remaining empty fields with random data.
await InputHelper.FillInputFields(formValues);
await InputHelper.FillEmptyInputFieldsWithRandom();
diff --git a/apps/server/Tests/AliasVault.E2ETests/TestData/README.md b/apps/server/Tests/AliasVault.E2ETests/TestData/README.md
index f252c8863..69914d3be 100644
--- a/apps/server/Tests/AliasVault.E2ETests/TestData/README.md
+++ b/apps/server/Tests/AliasVault.E2ETests/TestData/README.md
@@ -4,4 +4,5 @@ using the `AliasVault.UnitTests.ResourceReaderUtility` class.
Index:
- `AliasClientDb_encrypted_base64_1.0.0` - Encrypted vault blob with client db version 1.0.0 used to test client db upgrade paths. This vault contains two test credentials that are checked in the tests after local client db upgrade.
+- `TestVault.avux` - .Avux file with predetermined set of credentials, used to test if Avux import works as expected.
- `TestAttachment.txt` - Test attachment file that is uploaded during test.
diff --git a/apps/server/Tests/AliasVault.E2ETests/TestData/TestVault.avux b/apps/server/Tests/AliasVault.E2ETests/TestData/TestVault.avux
new file mode 100644
index 000000000..25906bbd9
Binary files /dev/null and b/apps/server/Tests/AliasVault.E2ETests/TestData/TestVault.avux differ
diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard3/AvuxExportImportTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard3/AvuxExportImportTests.cs
new file mode 100644
index 000000000..7e5b72bf0
--- /dev/null
+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard3/AvuxExportImportTests.cs
@@ -0,0 +1,328 @@
+//-----------------------------------------------------------------------
+// <copyright file="AvuxExportImportTests.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.E2ETests.Tests.Client.Shard3;
+
+using System.IO.Compression;
+
+/// <summary>
+/// End-to-end tests for importing vault data using the .avux format.
+/// These tests use a pre-generated .avux file to ensure backward compatibility
+/// and that old exports continue to work with new versions.
+/// </summary>
+[Parallelizable(ParallelScope.Self)]
+[Category("ClientTests")]
+[TestFixture]
+public class AvuxExportImportTests : ClientPlaywrightTest
+{
+ /// <summary>
+ /// Test that importing a .avux file works correctly and all data is preserved.
+ /// This test uses a pre-generated .avux file (TestVault.avux) that contains:
+ /// - Basic login credential (username, password, URL, notes)
+ /// - Login with 2FA/TOTP
+ /// - Login with file attachment
+ /// - Credit card entry
+ /// - Secure note entry
+ /// - Credential with multiple URLs
+ /// - Credential in a folder
+ /// This ensures backward compatibility with existing .avux exports.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ [Order(1)]
+ public async Task ImportAvuxFile()
+ {
+ // Get the .avux test file from embedded resources
+ var avuxBytes = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync(
+ "AliasVault.E2ETests.TestData.TestVault.avux");
+
+ // Verify the .avux file structure before importing
+ VerifyAvuxFileStructure(avuxBytes);
+
+ // Navigate to import/export settings page
+ await NavigateUsingBlazorRouter("settings/import-export");
+ await WaitForUrlAsync("settings/import-export", "Import / Export");
+
+ // Click on the AliasVault import card
+ await Page.ClickAsync("[data-import-service='AliasVault']");
+
+ // Wait for modal to appear by waiting for the file input
+ await Page.WaitForSelectorAsync("input[type='file']", new() { State = WaitForSelectorState.Visible });
+
+ // Create a temporary file with the .avux content
+ var tempFilePath = Path.Combine(Path.GetTempPath(), $"test-import-{Guid.NewGuid()}.avux");
+ await File.WriteAllBytesAsync(tempFilePath, avuxBytes);
+
+ try
+ {
+ // Set the file input using the temporary file
+ var fileInput = Page.Locator("input[type='file']");
+ await fileInput.SetInputFilesAsync(tempFilePath);
+
+ // Click Next in the verify screen
+ await Page.ClickAsync("text=Next");
+
+ // Wait for Import button to be visible
+ await Page.WaitForSelectorAsync("button:has-text('Import')");
+
+ // Click Import button to import the items
+ await Page.ClickAsync("button:has-text('Import')");
+ await Page.WaitForSelectorAsync("text=Successfully imported");
+
+ // Verify all items were imported
+ await VerifyImportedItems();
+ }
+ finally
+ {
+ // Cleanup: delete the temporary file
+ if (File.Exists(tempFilePath))
+ {
+ File.Delete(tempFilePath);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Verifies the structure of an .avux file.
+ /// </summary>
+ /// <param name="avuxBytes">The .avux file content as bytes.</param>
+ private void VerifyAvuxFileStructure(byte[] avuxBytes)
+ {
+ Assert.That(avuxBytes, Is.Not.Null);
+ Assert.That(avuxBytes.Length, Is.GreaterThan(0));
+
+ using var zipStream = new MemoryStream(avuxBytes);
+ using var archive = new ZipArchive(zipStream, ZipArchiveMode.Read);
+
+ // Verify manifest.json exists
+ var manifestEntry = archive.GetEntry("manifest.json");
+ Assert.That(manifestEntry, Is.Not.Null, "manifest.json should exist in .avux file");
+
+ // Read and verify manifest content
+ using var reader = new StreamReader(manifestEntry.Open());
+ var manifestJson = reader.ReadToEnd();
+ Assert.That(manifestJson, Is.Not.Empty, "manifest.json should not be empty");
+ Assert.That(manifestJson, Does.Contain("\"version\""), "manifest should contain version");
+ Assert.That(manifestJson, Does.Contain("\"items\""), "manifest should contain items");
+ Assert.That(manifestJson, Does.Contain("\"folders\""), "manifest should contain folders");
+ }
+
+ /// <summary>
+ /// Verifies that all expected items from the .avux file were imported correctly.
+ /// </summary>
+ private async Task VerifyImportedItems()
+ {
+ // Navigate to items page
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+
+ // Wait for items to load
+ await Page.WaitForTimeoutAsync(1000);
+
+ var pageContent = await Page.TextContentAsync("body");
+
+ // Verify all expected items are present
+ var expectedItems = new Dictionary<string, string>
+ {
+ { "Basic Login Test", "Basic login credential" },
+ { "Login with 2FA", "Login with 2FA/TOTP" },
+ { "Login with Attachment", "Login with file attachment" },
+ { "Test Credit Card", "Credit card entry" },
+ { "Test Secure Note", "Secure note entry" },
+ { "Multi-URL Login", "Credential with multiple URLs" },
+ };
+
+ foreach (var (itemName, description) in expectedItems)
+ {
+ Assert.That(pageContent, Does.Contain(itemName), $"{description} should be imported");
+ }
+
+ // Verify the folder was imported
+ Assert.That(pageContent, Does.Contain("Test Folder"), "Test Folder should be imported");
+
+ // Verify individual items in detail
+ await VerifyBasicLoginTest();
+ await VerifyLoginWith2FA();
+ await VerifyLoginWithAttachment();
+ await VerifyCreditCard();
+ await VerifySecureNote();
+ await VerifyMultiUrlLogin();
+ await VerifyCredentialInFolder();
+ }
+
+ /// <summary>
+ /// Verifies the "Basic Login Test" item details.
+ /// </summary>
+ private async Task VerifyBasicLoginTest()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Basic Login Test");
+
+ // Wait for navigation to item view page
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ // Get input values - fields are displayed in readonly inputs on view page
+ var usernameValue = await Page.Locator("input#login-username").InputValueAsync();
+ var pageContent = await Page.TextContentAsync("body");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(usernameValue, Is.EqualTo("testuser"), "Username should be preserved");
+ Assert.That(pageContent, Does.Contain("https://example.com"), "URL should be preserved");
+ Assert.That(pageContent, Does.Contain("This is a test note for basic login"), "Notes should be preserved");
+ });
+ }
+
+ /// <summary>
+ /// Verifies the "Login with 2FA" item details.
+ /// </summary>
+ private async Task VerifyLoginWith2FA()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Login with 2FA");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ var usernameValue = await Page.Locator("input#login-username").InputValueAsync();
+ var pageContent = await Page.TextContentAsync("body");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(usernameValue, Is.EqualTo("user2fa"), "2FA username should be preserved");
+ Assert.That(
+ pageContent,
+ Does.Contain("Test TOTP").Or.Contains("Two-Factor").Or.Contains("2FA").Or.Contains("TOTP"),
+ "TOTP should be preserved");
+ });
+ }
+
+ /// <summary>
+ /// Verifies the "Login with Attachment" item details.
+ /// </summary>
+ private async Task VerifyLoginWithAttachment()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Login with Attachment");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ var usernameValue = await Page.Locator("input#login-username").InputValueAsync();
+ var pageContent = await Page.TextContentAsync("body");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(usernameValue, Is.EqualTo("userattachment"), "Attachment username should be preserved");
+ Assert.That(
+ pageContent,
+ Does.Contain("test-attachment.txt").Or.Contains("Attachment"),
+ "Attachment should be preserved");
+ });
+ }
+
+ /// <summary>
+ /// Verifies the "Test Credit Card" item details.
+ /// </summary>
+ private async Task VerifyCreditCard()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Test Credit Card");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ // Read credit card field values - View page uses full field keys with dots replaced by hyphens
+ var cardNumberValue = await Page.Locator("input#card-number").InputValueAsync();
+ var cardholderValue = await Page.Locator("input#card-cardholder_name").InputValueAsync();
+ var expiryMonthValue = await Page.Locator("input#card-expiry_month").InputValueAsync();
+ var expiryYearValue = await Page.Locator("input#card-expiry_year").InputValueAsync();
+ var cvvValue = await Page.Locator("input#card-cvv").InputValueAsync();
+ var pinValue = await Page.Locator("input#card-pin").InputValueAsync();
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(cardNumberValue, Is.EqualTo("4111111111111111"), "Card number should be preserved");
+ Assert.That(cardholderValue, Is.EqualTo("Test Cardholder"), "Cardholder name should be preserved");
+ Assert.That(expiryMonthValue, Is.EqualTo("12"), "Expiry month should be preserved");
+ Assert.That(expiryYearValue, Is.EqualTo("2025"), "Expiry year should be preserved");
+ Assert.That(cvvValue, Is.EqualTo("123"), "CVV should be preserved");
+ Assert.That(pinValue, Is.EqualTo("1234"), "PIN should be preserved");
+ });
+ }
+
+ /// <summary>
+ /// Verifies the "Test Secure Note" item details.
+ /// </summary>
+ private async Task VerifySecureNote()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Test Secure Note");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ var pageContent = await Page.TextContentAsync("body");
+ Assert.That(
+ pageContent,
+ Does.Contain("secure note").Or.Contains("important information"),
+ "Note content should be preserved");
+ }
+
+ /// <summary>
+ /// Verifies the "Multi-URL Login" item details.
+ /// </summary>
+ private async Task VerifyMultiUrlLogin()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+ await Page.ClickAsync("text=Multi-URL Login");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ // Read username from input and URLs from page body (URLs are displayed as text, not input fields)
+ var usernameValue = await Page.Locator("input#login-username").InputValueAsync();
+ var pageContent = await Page.TextContentAsync("body");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(usernameValue, Is.EqualTo("multiurluser"), "Multi-URL username should be preserved");
+ Assert.That(pageContent, Does.Contain("app.example.com"), "First URL should be preserved");
+ Assert.That(pageContent, Does.Contain("www.example.com"), "Second URL should be preserved");
+ Assert.That(pageContent, Does.Contain("admin.example.com"), "Third URL should be preserved");
+ });
+ }
+
+ /// <summary>
+ /// Verifies the "Credential in Folder" item details.
+ /// </summary>
+ private async Task VerifyCredentialInFolder()
+ {
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+
+ // Navigate to the folder first
+ await Page.ClickAsync("text=Test Folder");
+ await Page.WaitForTimeoutAsync(500);
+
+ // Now click on the credential within the folder
+ await Page.ClickAsync("text=Credential in Folder");
+
+ await Page.WaitForURLAsync("**/items/*", new() { Timeout = 5000 });
+ await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
+
+ var usernameValue = await Page.Locator("input#login-username").InputValueAsync();
+ Assert.That(usernameValue, Is.EqualTo("folderuser"), "Folder credential username should be preserved");
+ }
+}
diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard5/TotpTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard5/TotpTests.cs
index b01d1643f..7ed93f306 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard5/TotpTests.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard5/TotpTests.cs
@@ -36,8 +36,8 @@ public class TotpTests : ClientPlaywrightTest
await AddFieldSectionAsync("Two-Factor Authentication");
// Fill in the TOTP code details (form is already visible)
- var nameInput = Page.Locator("input[id='name']");
- var secretKeyInput = Page.Locator("input[id='secretKey']");
+ var nameInput = Page.Locator("input[id='totp-name']");
+ var secretKeyInput = Page.Locator("input[id='totp-secret']");
await nameInput.FillAsync("Test TOTP");
await secretKeyInput.FillAsync("JBSWY3DPEHPK3PXP"); // Example secret key
@@ -78,8 +78,8 @@ public class TotpTests : ClientPlaywrightTest
await AddFieldSectionAsync("Two-Factor Authentication");
// Fill in the TOTP code details (form is already visible)
- await Page.Locator("input[id='name']").FillAsync("TOTP to Delete");
- await Page.Locator("input[id='secretKey']").FillAsync("JBSWY3DPEHPK3PXP");
+ await Page.Locator("input[id='totp-name']").FillAsync("TOTP to Delete");
+ await Page.Locator("input[id='totp-secret']").FillAsync("JBSWY3DPEHPK3PXP");
// Submit the TOTP form
await Page.Locator("button[id='save-totp-code']").ClickAsync();
diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
index f797f07b9..03819b7db 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
@@ -174,4 +174,266 @@ public class TestVaultGeneratorTests : BrowserExtensionPlaywrightTest
Process.Start("explorer.exe", vaultOutputDir);
}
}
+
+ /// <summary>
+ /// Creates a comprehensive test vault with all item types and exports it to .avux format.
+ /// This test should be run manually when you need to generate a new .avux test file.
+ /// The generated .avux file can be used for backward compatibility testing.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ public async Task GenerateComprehensiveAvuxTestFile()
+ {
+ // 1. Create a basic login credential
+ await CreateItemEntry(new Dictionary<string, string>
+ {
+ { "service-name", "Basic Login Test" },
+ { "username", "testuser" },
+ { "password", "testpassword123" },
+ { "service-url-0", "https://example.com" },
+ { "notes", "This is a test note for basic login" },
+ });
+
+ // 2. Create a login credential with 2FA/TOTP
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Login with 2FA" },
+ { "username", "user2fa" },
+ { "password", "password2fa123" },
+ },
+ async () =>
+ {
+ // Add TOTP section
+ await AddFieldSectionAsync("Two-Factor Authentication");
+ await Page.WaitForSelectorAsync("input#totp-name");
+
+ // Fill TOTP fields
+ await Page.FillAsync("input#totp-name", "Test TOTP");
+ await Page.FillAsync("input#totp-secret", "JBSWY3DPEHPK3PXP");
+ });
+
+ // 3. Create a login credential with attachment
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Login with Attachment" },
+ { "username", "userattachment" },
+ { "password", "passwordattachment" },
+ },
+ async () =>
+ {
+ // Add attachments section
+ await AddFieldSectionAsync("Attachments");
+ await Page.WaitForSelectorAsync("input[type='file']");
+
+ // Upload test file
+ var fileInput = Page.Locator("input[type='file']");
+ var fileContent = System.Text.Encoding.UTF8.GetBytes("Test attachment content for .avux export");
+ var tempFilePath = Path.Combine(Path.GetTempPath(), "test-attachment.txt");
+ await File.WriteAllBytesAsync(tempFilePath, fileContent);
+ await fileInput.SetInputFilesAsync(tempFilePath);
+ File.Delete(tempFilePath);
+ });
+
+ // 4. Create a credit card entry
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Test Credit Card" },
+ },
+ async () =>
+ {
+ // Switch to Credit Card item type
+ await Page.ClickAsync("button:has-text('Login')");
+ await Page.ClickAsync("button:has-text('Credit Card')");
+
+ // Wait for credit card fields to appear
+ await Page.WaitForSelectorAsync("input#card-number");
+
+ // Fill credit card fields
+ await Page.FillAsync("input#card-number", "4111111111111111");
+ await Page.FillAsync("input#cardholder-name", "Test Cardholder");
+ await Page.FillAsync("input#expiry-month", "12");
+ await Page.FillAsync("input#expiry-year", "2025");
+ await Page.FillAsync("input#cvv", "123");
+
+ // Add PIN section
+ await AddFieldSectionAsync("PIN");
+ await Page.WaitForSelectorAsync("input#pin");
+ await Page.FillAsync("input#pin", "1234");
+ });
+
+ // 5. Create a note entry
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Test Secure Note" },
+ },
+ async () =>
+ {
+ // Switch to Note item type
+ await Page.ClickAsync("button:has-text('Login')");
+ await Page.ClickAsync("button:has-text('Login')");
+ await Page.ClickAsync("button:has-text('Secure Note')");
+
+ // Wait for notes field
+ await Page.WaitForSelectorAsync("textarea#notes");
+
+ // Fill notes field
+ await Page.FillAsync("textarea#notes", "This is a secure note with important information.");
+ });
+
+ // 6. Create a credential with multiple URLs
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Multi-URL Login" },
+ { "username", "multiurluser" },
+ { "password", "multiurlpass" },
+ },
+ async () =>
+ {
+ // Multi-value inputs have IDs like "service-url-0", "service-url-1", etc.
+ // Fill the first URL
+ await Page.WaitForSelectorAsync("input#service-url-0");
+ await Page.FillAsync("input#service-url-0", "https://app.example.com");
+
+ // Add and fill the second URL
+ await Page.ClickAsync("button#add-service-url");
+ await Page.WaitForSelectorAsync("input#service-url-1");
+ await Page.FillAsync("input#service-url-1", "https://www.example.com");
+
+ // Add and fill the third URL
+ await Page.ClickAsync("button#add-service-url");
+ await Page.WaitForSelectorAsync("input#service-url-2");
+ await Page.FillAsync("input#service-url-2", "https://admin.example.com");
+ });
+
+ // 7. Create a folder and a credential in it
+ await Page.BringToFrontAsync();
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+
+ // Click "New Folder" button
+ await Page.ClickAsync("button:has-text('New Folder')");
+
+ // Wait for modal to appear by waiting for the input field
+ await Page.WaitForSelectorAsync("input#folder-name", new() { State = WaitForSelectorState.Visible });
+
+ // Fill folder name
+ await Page.FillAsync("input#folder-name", "Test Folder");
+
+ // Click the confirm button in the modal (it says "Create" for new folders)
+ await Page.ClickAsync("button:has-text('Create')");
+
+ // Wait for the folder to appear in the list
+ await Page.WaitForSelectorAsync("text=Test Folder");
+
+ // Now create a credential in this folder
+ await CreateItemEntry(
+ new Dictionary<string, string>
+ {
+ { "service-name", "Credential in Folder" },
+ { "username", "folderuser" },
+ { "password", "folderpass" },
+ },
+ async () =>
+ {
+ // Click the folder selector button to open the modal
+ await Page.ClickAsync("button:has-text('No folder')");
+
+ // Wait for the folder modal to appear and click on "Test Folder"
+ await Page.WaitForSelectorAsync("button:has-text('Test Folder')");
+ await Page.ClickAsync("button:has-text('Test Folder')");
+ });
+
+ // Verify all items were created
+ await Page.BringToFrontAsync();
+ await NavigateUsingBlazorRouter("items");
+ await WaitForUrlAsync("items", "Find all of your items");
+
+ var pageContent = await Page.TextContentAsync("body");
+ var expectedItems = new[]
+ {
+ "Basic Login Test",
+ "Login with 2FA",
+ "Login with Attachment",
+ "Test Credit Card",
+ "Test Secure Note",
+ "Multi-URL Login",
+ };
+
+ foreach (var itemName in expectedItems)
+ {
+ Assert.That(pageContent, Does.Contain(itemName), $"Created item '{itemName}' not found in vault");
+ }
+
+ // Export to .avux format
+ await NavigateUsingBlazorRouter("settings/import-export");
+ await WaitForUrlAsync("settings/import-export", "Import / Export");
+
+ // Click the "Export Full Vault (.avux)" button
+ var exportButton = Page.Locator("button").Filter(new() { HasText = "Export Full Vault (.avux)" });
+ await exportButton.ClickAsync();
+
+ // Confirm the export warning
+ await Page.WaitForSelectorAsync("button:has-text('Confirm')");
+ await Page.ClickAsync("button:has-text('Confirm')");
+
+ // Enter password for verification
+ await Page.WaitForSelectorAsync("input[type='password']");
+ await Page.FillAsync("input[type='password']", TestUserPassword);
+ await Page.ClickAsync("button:has-text('Confirm')");
+
+ // Wait for download
+ var downloadPromise = Page.WaitForDownloadAsync();
+ var download = await downloadPromise;
+
+ // Save to output directory
+ var outputDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
+ var vaultOutputDir = Path.Combine(outputDir, "output");
+ Directory.CreateDirectory(vaultOutputDir);
+
+ var avuxFilePath = Path.Combine(vaultOutputDir, "TestVault.avux");
+ await download.SaveAsAsync(avuxFilePath);
+
+ // Also save to TestData directory for use in CI tests
+ var testDataDir = Path.Combine(
+ Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty,
+ "..",
+ "..",
+ "..",
+ "TestData");
+ Directory.CreateDirectory(testDataDir);
+ var testDataAvuxPath = Path.Combine(testDataDir, "TestVault.avux");
+ File.Copy(avuxFilePath, testDataAvuxPath, overwrite: true);
+
+ Console.WriteLine("\n=== AVUX TEST FILE GENERATION COMPLETE ===");
+ Console.WriteLine("A .avux file has been generated with the following items:");
+ Console.WriteLine("1. Basic Login Test - basic login credential with username, password, URL, notes");
+ Console.WriteLine("2. Login with 2FA - login with TOTP/2FA enabled");
+ Console.WriteLine("3. Login with Attachment - login with file attachment");
+ Console.WriteLine("4. Test Credit Card - credit card entry with all fields");
+ Console.WriteLine("5. Test Secure Note - secure note item");
+ Console.WriteLine("6. Multi-URL Login - credential with multiple URLs");
+ Console.WriteLine("7. Credential in Folder - credential organized in 'Test Folder'");
+ Console.WriteLine("\nFiles saved to:");
+ Console.WriteLine($" - Output directory: {avuxFilePath}");
+ Console.WriteLine($" - TestData directory: {testDataAvuxPath}");
+ Console.WriteLine("\nThis .avux file can now be used for:");
+ Console.WriteLine(" - Backward compatibility testing");
+ Console.WriteLine(" - CI/CD automated import tests");
+ Console.WriteLine(" - Validation that old exports work with new versions");
+
+ // Open file explorer at the output location
+ if (OperatingSystem.IsMacOS())
+ {
+ Process.Start("open", vaultOutputDir);
+ }
+ else if (OperatingSystem.IsWindows())
+ {
+ Process.Start("explorer.exe", vaultOutputDir);
+ }
+ }
}