From 3577b00280ad12ed5b3d9502a9091bdbfe910ccf Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 24 Apr 2026 14:53:06 +0200 Subject: [PATCH] Update tests for creditcard details import (#1959) --- .../TestData/Exports/protonpass.zip | Bin 3863 -> 4501 bytes .../Utilities/ImportExportTests.cs | 26 ++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.zip b/apps/server/Tests/AliasVault.UnitTests/TestData/Exports/protonpass.zip index 8659e675fab0bd7eeb006f936dd3b600a2cf823a..e7f27ffb9192fcd8ab7b1442156e4db64cb0d459 100644 GIT binary patch delta 448 zcmbO(H&vM@z?+#xmw|(Wfq}JbBTqNq(BKEb8MsW~1Nx}~OGe!2NhMczg3?nPx8sk%u9MJ0LZhQ2{jMd776>6IxdAr^UF zDe=CZX=W~2IZ=+2<5)Ufl8aJPGE0&Zi&B(yl=AXRQkATfoJ)&K@^ckHJcYFUA_WvR znI);Yp{1EAKy}7O7RiZ;=0=nMvB}g!6gfi-O3u$KNzE%!vZ_`B8J&@zlagBGmzWDO z-AlnMKO?U=KM!ajNHV0d04Qt-w7oPpDYXcw!qCXr1Pue#mZcVDre!84mSpDV`5`F< zN~Km5C}kFbWn2=$UNAB+veY#&1IiU-=0S~|oW*QDIfh3>*4V_t++0T~H$NpatuiDN zqNvknG*uLPW00RRE2Y53w=`zFOWkw7_Zt@L2OEw!p1|R?c DLkEi- delta 75 zcmbQLJY9|_z?+#xmw|(WfnjRQMxJiI$)bYNYDeCc2v_qlFo1A?HzSiSGfc^h7=+y9 NFhNVUeLy7)3;>s05hVZs diff --git a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs b/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs index 83840e40b..66e7b2aa0 100644 --- a/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs +++ b/apps/server/Tests/AliasVault.UnitTests/Utilities/ImportExportTests.cs @@ -2196,8 +2196,6 @@ public class ImportExportTests /// /// Test case for importing credentials from a Proton Pass .zip export. - /// The fixture contains a single "Personal" vault (promoted to root) with 6 items: - /// 4 logins (one with a TOTP URI, one with URLs, one with no password), 1 alias, 1 note. /// /// Async task. [Test] @@ -2211,7 +2209,7 @@ public class ImportExportTests var importedCredentials = await importer.ImportFromArchiveAsync(zipBytes); // Assert - Assert.That(importedCredentials, Has.Count.EqualTo(6)); + Assert.That(importedCredentials, Has.Count.EqualTo(7)); // Login with TOTP URI. var loginWithTotp = importedCredentials.First(c => c.ServiceName == "Test proton 1"); @@ -2230,7 +2228,7 @@ public class ImportExportTests var expectedCreatedAt = DateTimeOffset.FromUnixTimeSeconds(1744362003).UtcDateTime; Assert.That(loginWithTotp.CreatedAt, Is.EqualTo(expectedCreatedAt)); - // Alias item — email comes from the envelope's aliasEmail field. + // Alias item var aliasItem = importedCredentials.First(c => c.ServiceName == "Test alias"); Assert.Multiple(() => { @@ -2270,7 +2268,7 @@ public class ImportExportTests Assert.That(loginWithNote.ServiceUrls![0], Is.EqualTo("http://example.com/")); }); - // Secure note — note text lives in metadata.note. + // Secure note var noteItem = importedCredentials.First(c => c.ServiceName == "Customnote"); Assert.Multiple(() => { @@ -2278,9 +2276,25 @@ public class ImportExportTests Assert.That(noteItem.Notes, Is.EqualTo("Customnotecontent")); }); + // Credit card + var cardItem = importedCredentials.First(c => c.ServiceName == "Testcreditcard"); + Assert.Multiple(() => + { + Assert.That(cardItem.ItemType, Is.EqualTo(ImportedItemType.Creditcard)); + Assert.That(cardItem.Notes, Is.EqualTo("Custom note for creditcard")); + Assert.That(cardItem.FolderPath, Is.Null); + Assert.That(cardItem.Creditcard, Is.Not.Null); + Assert.That(cardItem.Creditcard!.CardholderName, Is.EqualTo("J Johnson")); + Assert.That(cardItem.Creditcard.Number, Is.EqualTo("1234123412341234123")); + Assert.That(cardItem.Creditcard.Cvv, Is.EqualTo("123")); + Assert.That(cardItem.Creditcard.Pin, Is.EqualTo("1234")); + Assert.That(cardItem.Creditcard.ExpiryYear, Is.EqualTo("2029")); + Assert.That(cardItem.Creditcard.ExpiryMonth, Is.EqualTo("06")); + }); + // Conversion to Item extracts the TOTP secret from the URI. var convertedItems = BaseImporter.ConvertToItem(importedCredentials); - Assert.That(convertedItems, Has.Count.EqualTo(6)); + Assert.That(convertedItems, Has.Count.EqualTo(7)); var convertedLogin = convertedItems.First(i => i.Name == "Test proton 1"); Assert.Multiple(() =>