Skip to content

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

Add E2E import test (#542)

Leendert de Borstc50178967a1b
diff --git a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
index ac49b78d3..1095ff01a 100644
--- a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
+++ b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
@@ -25,6 +25,8 @@
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
<EmbeddedResource Include="TestData\AliasClientDb_encrypted_base64_1.0.0.txt" />
<EmbeddedResource Include="TestData\TestAttachment.txt" />
+ <None Remove="TestData\TestImportBitwarden.csv" />
+ <EmbeddedResource Include="TestData\TestImportBitwarden.csv" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Tests/AliasVault.E2ETests/TestData/TestImportBitwarden.csv b/src/Tests/AliasVault.E2ETests/TestData/TestImportBitwarden.csv
new file mode 100644
index 000000000..b43c15745
--- /dev/null
+++ b/src/Tests/AliasVault.E2ETests/TestData/TestImportBitwarden.csv
@@ -0,0 +1,6 @@
+folder,favorite,type,name,notes,fields,reprompt,login_uri,login_username,login_password,login_totp
+Business,,login,Item for business folder,,,0,,crisply,4CSp43uhSZri8A,
+,,login,Test,,,0,,,,
+,,login,Test,,,0,,test2,asdasd,
+Business,,login,TutaNota,,,0,,[email protected],blabla,otpauth://totp/Strongbox?secret=PLW4SB3PQ7MKVXY2MXF4NEXS6Y&algorithm=SHA1&digits=6&period=30
+Business,,login,Aliasvault.net,,,0,https://www.aliasvault.net,root,toor,
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/ImportTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/ImportTests.cs
new file mode 100644
index 000000000..f2d07b48f
--- /dev/null
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/ImportTests.cs
@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------
+// <copyright file="ImportTests.cs" company="lanedirt">
+// Copyright (c) lanedirt. All rights reserved.
+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.E2ETests.Tests.Client.Shard3;
+
+/// <summary>
+/// End-to-end tests for importing credentials from various password managers.
+/// </summary>
+[Parallelizable(ParallelScope.Self)]
+[Category("ClientTests")]
+[TestFixture]
+public class ImportTests : ClientPlaywrightTest
+{
+ /// <summary>
+ /// Test that importing credentials from Bitwarden CSV works correctly.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ [Order(1)]
+ public async Task ImportFromBitwarden()
+ {
+ // Navigate to import/export settings page.
+ await NavigateUsingBlazorRouter("settings/import-export");
+ await WaitForUrlAsync("settings/import-export", "Import / Export");
+
+ // Click on the Bitwarden import card.
+ await Page.ClickAsync("text=Bitwarden");
+ await Page.WaitForSelectorAsync("div.modal-dialog");
+
+ // Get the Bitwarden CSV file content from embedded resources.
+ var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.E2ETests.TestData.TestImportBitwarden.csv");
+
+ // Create a temporary file with the content.
+ var tempFilePath = Path.Combine(Path.GetTempPath(), "bitwarden.csv");
+ await File.WriteAllBytesAsync(tempFilePath, fileContent);
+
+ // Set the file input using the temporary file.
+ var fileInput = Page.Locator("input[type='file']");
+ await fileInput.SetInputFilesAsync(tempFilePath);
+
+ // Delete the temporary file.
+ File.Delete(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 credentials.
+ await Page.ClickAsync("button:has-text('Import')");
+ await Page.WaitForSelectorAsync("text=Successfully imported");
+
+ // Navigate to credentials page to verify imported credentials.
+ await NavigateUsingBlazorRouter("credentials");
+ await WaitForUrlAsync("credentials", "Find all of your credentials");
+
+ // Verify that expected credentials from the Bitwarden CSV are present.
+ var pageContent = await Page.TextContentAsync("body");
+ Assert.Multiple(() =>
+ {
+ Assert.That(pageContent, Does.Contain("TutaNota"), "TutaNota credential not imported");
+ Assert.That(pageContent, Does.Contain("Aliasvault.net"), "Aliasvault.net credential not imported");
+ });
+ }
+}