Skip to content

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

Add todos (#186)

Leendert de Borsteda6ad0e444e
diff --git a/src/AliasVault.Client/Services/Database/DbMergeUtility.cs b/src/AliasVault.Client/Services/Database/DbMergeUtility.cs
index 55391d6f6..3d8d4f9b1 100644
--- a/src/AliasVault.Client/Services/Database/DbMergeUtility.cs
+++ b/src/AliasVault.Client/Services/Database/DbMergeUtility.cs
@@ -89,8 +89,8 @@ public static class DbMergeUtility
while (await sourceReader.ReadAsync())
{
var id = sourceReader.GetValue(0);
- var updatedAt = hasUpdatedAt ? sourceReader.GetDateTime(columns.IndexOf("UpdatedAt")) : DateTime.MinValue;
- var isDeleted = hasIsDeleted && sourceReader.GetBoolean(columns.IndexOf("IsDeleted"));
+ var updatedAt = sourceReader.GetDateTime(columns.IndexOf("UpdatedAt"));
+ var isDeleted = sourceReader.GetBoolean(columns.IndexOf("IsDeleted"));
// Check if the record exists in the base table.
baseCommand.CommandText = $"SELECT UpdatedAt FROM {tableName} WHERE Id = @Id";
@@ -150,6 +150,9 @@ public static class DbMergeUtility
var updateColumns = string.Join(", ", columns.Select(c => $"{c} = @{c}"));
command.CommandText = $"UPDATE {tableName} SET {updateColumns} WHERE Id = @Id";
+ Console.WriteLine($"Updating record in {tableName}.");
+ Console.WriteLine($"Command: {command.CommandText}");
+
for (int i = 0; i < columns.Count; i++)
{
command.Parameters.AddWithValue($"@{columns[i]}", sourceReader.GetValue(i));
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs
index 2c62a7993..9a8cabc54 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs
@@ -75,16 +75,16 @@ public class DbSyncTests : ClientPlaywrightTest
var baselineVault = await CreateBaselineVault(async () =>
{
ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));
- await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline1" }, { "username", "user1" }, { "email", "email1" } });
+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline1" }, { "username", "user1" }, { "email", "email1" }, { "first-name", "firstname1" } });
ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));
- await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline2" }, { "username", "user2" }, { "email", "email2" } });
+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline2" }, { "username", "user2" }, { "email", "email2" }, { "first-name", "firstname2" } });
ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));
- await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline3" }, { "username", "user3" }, { "email", "email3" } });
+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline3" }, { "username", "user3" }, { "email", "email3" }, { "first-name", "firstname3" } });
});
var client1Vault = await SimulateClient(baselineVault, async () =>
{
- await UpdateCredentialEntry("TestBaseline2", new Dictionary<string, string> { { "service-name", "TestBaseMutate2" }, { "username", "usermutate2" }, { "email", "emailmutate2" } });
+ await UpdateCredentialEntry("TestBaseline2", new Dictionary<string, string> { { "service-name", "TestBaseMutate2" }, { "username", "usermutate2" }, { "email", "emailmutate2" }, { "first-name", "firstnamemutate2" } });
});
await SimulateClient(baselineVault, async () =>
@@ -95,12 +95,17 @@ public class DbSyncTests : ClientPlaywrightTest
await ApiDbContext.SaveChangesAsync();
await UpdateCredentialEntry("TestBaseline3", new Dictionary<string, string> { { "service-name", "TestBaseMutate3" }, { "username", "usermutate3" }, { "email", "emailmutate3" } });
+
+ // TODO: investigate why the client1Vault changes are visible here while there does not
+ // seem to be an actual merge? Also, the Alias table is not updated with UpdatedAt so it should
+ // not trigger a merge anyway. Check why this test gives a false-positive...
+ await Task.Delay(50000);
});
// Assert that the two conflicting vaults have been merged and all mutated service names are found.
Dictionary<string, List<string>> expectedStrings = new()
{
- { "TestBaseMutate2", new List<string> { "usermutate2", "[email protected]" } },
+ { "TestBaseMutate2", new List<string> { "usermutate2", "[email protected]", "firstnamemutate2" } },
{ "TestBaseMutate3", new List<string> { "usermutate3", "[email protected]" } },
};
@@ -159,7 +164,6 @@ public class DbSyncTests : ClientPlaywrightTest
// Execute custom client actions.
await clientActions();
-
return await ApiDbContext.Vaults.OrderByDescending(x => x.UpdatedAt).FirstAsync();
}
}