mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-01-03 17:45:38 -05:00
Fix issues with group functions (#2410)
This commit is contained in:
parent
7263dcddfe
commit
fa687f246e
6 changed files with 147 additions and 160 deletions
|
|
@ -125,7 +125,7 @@ void TestMerge::testResolveConflictNewer()
|
|||
QVERIFY(groupDestinationInitial != nullptr);
|
||||
QCOMPARE(groupDestinationInitial->entries().size(), 2);
|
||||
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceInitial != nullptr);
|
||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ void TestMerge::testResolveConflictNewer()
|
|||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationInitialTimeInfo);
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->password(), QString("password"));
|
||||
|
|
@ -192,7 +192,7 @@ void TestMerge::testResolveConflictExisting()
|
|||
QVERIFY(groupDestinationInitial != nullptr);
|
||||
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
||||
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceInitial != nullptr);
|
||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ void TestMerge::testResolveConflictExisting()
|
|||
QPointer<Group> groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
||||
QVERIFY(groupDestinationUpdated != nullptr);
|
||||
QCOMPARE(groupDestinationUpdated->entries().size(), 2);
|
||||
QPointer<Entry> entryDestinationUpdated = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationUpdated = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationUpdated != nullptr);
|
||||
QVERIFY(entryDestinationUpdated->group() == groupDestinationUpdated);
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ void TestMerge::testResolveConflictExisting()
|
|||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationUpdatedNewerTimeInfo);
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->password(), QString("password2"));
|
||||
QCOMPARE(entryDestinationMerged->timeInfo(), entryDestinationUpdatedNewerTimeInfo);
|
||||
|
|
@ -382,9 +382,9 @@ void TestMerge::testResolveConflictTemplate(int mergeMode, std::function<void(Da
|
|||
|
||||
m_clock->advanceMinute(1);
|
||||
|
||||
QPointer<Entry> deletedEntryDestination = dbDestination->rootGroup()->findEntry("deletedDestination");
|
||||
QPointer<Entry> deletedEntryDestination = dbDestination->rootGroup()->findEntryByPath("deletedDestination");
|
||||
dbDestination->recycleEntry(deletedEntryDestination);
|
||||
QPointer<Entry> deletedEntrySource = dbSource->rootGroup()->findEntry("deletedSource");
|
||||
QPointer<Entry> deletedEntrySource = dbSource->rootGroup()->findEntryByPath("deletedSource");
|
||||
dbSource->recycleEntry(deletedEntrySource);
|
||||
|
||||
m_clock->advanceMinute(1);
|
||||
|
|
@ -428,8 +428,8 @@ void TestMerge::testResolveConflictTemplate(int mergeMode, std::function<void(Da
|
|||
|
||||
verification(dbDestination.data(), timestamps);
|
||||
|
||||
QVERIFY(dbDestination->rootGroup()->findEntry("entryDestination"));
|
||||
QVERIFY(dbDestination->rootGroup()->findEntry("entrySource"));
|
||||
QVERIFY(dbDestination->rootGroup()->findEntryByPath("entryDestination"));
|
||||
QVERIFY(dbDestination->rootGroup()->findEntryByPath("entrySource"));
|
||||
}
|
||||
|
||||
void TestMerge::testDeletionConflictTemplate(int mergeMode, std::function<void(Database*, const QMap<QString, QUuid>&)> verification)
|
||||
|
|
@ -790,7 +790,7 @@ void TestMerge::testMoveEntry()
|
|||
QScopedPointer<Database> dbSource(
|
||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceInitial != nullptr);
|
||||
|
||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||
|
|
@ -807,7 +807,7 @@ void TestMerge::testMoveEntry()
|
|||
Merger merger(dbSource.data(), dbDestination.data());
|
||||
merger.merge();
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
|
@ -824,7 +824,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||
QScopedPointer<Database> dbSource(
|
||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceInitial != nullptr);
|
||||
|
||||
QPointer<Group> group2Source = dbSource->rootGroup()->findChildByName("group2");
|
||||
|
|
@ -835,7 +835,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||
entrySourceInitial->setGroup(group2Source);
|
||||
QCOMPARE(entrySourceInitial->group()->name(), QString("group2"));
|
||||
|
||||
QPointer<Entry> entryDestinationInitial = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationInitial != nullptr);
|
||||
|
||||
m_clock->advanceSecond(1);
|
||||
|
|
@ -849,7 +849,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||
Merger merger(dbSource.data(), dbDestination.data());
|
||||
merger.merge();
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
|
@ -892,7 +892,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||
groupSourceCreated->setUuid(QUuid::createUuid());
|
||||
groupSourceCreated->setParent(dbSource->rootGroup());
|
||||
|
||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
entrySourceMoved->setGroup(groupSourceCreated);
|
||||
|
||||
m_clock->advanceSecond(1);
|
||||
|
|
@ -907,7 +907,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
||||
QCOMPARE(groupDestinationMerged->entries().size(), 1);
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group3"));
|
||||
}
|
||||
|
|
@ -929,7 +929,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entryDestinationMoved = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMoved = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMoved != nullptr);
|
||||
entryDestinationMoved->setGroup(groupDestinationCreated);
|
||||
QUuid uuidBeforeSyncing = entryDestinationMoved->uuid();
|
||||
|
|
@ -938,7 +938,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||
// Change the entry in the source db.
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceMoved != nullptr);
|
||||
entrySourceMoved->beginUpdate();
|
||||
entrySourceMoved->setUsername("username");
|
||||
|
|
@ -954,7 +954,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->username(), QString("username"));
|
||||
|
|
@ -983,7 +983,7 @@ void TestMerge::testUpdateGroup()
|
|||
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
||||
groupSourceInitial->setIcon(customIconId);
|
||||
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entrySourceInitial != nullptr);
|
||||
entrySourceInitial->setGroup(groupSourceInitial);
|
||||
entrySourceInitial->setTitle("entry1 renamed");
|
||||
|
|
@ -996,7 +996,7 @@ void TestMerge::testUpdateGroup()
|
|||
|
||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1 renamed");
|
||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1 renamed");
|
||||
QVERIFY(entryDestinationMerged != nullptr);
|
||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2 renamed"));
|
||||
|
|
@ -1125,7 +1125,7 @@ void TestMerge::testDeletedEntry()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1SourceInitial != nullptr);
|
||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||
delete entry1SourceInitial;
|
||||
|
|
@ -1133,7 +1133,7 @@ void TestMerge::testDeletedEntry()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2DestinationInitial != nullptr);
|
||||
QUuid entry2Uuid = entry2DestinationInitial->uuid();
|
||||
delete entry2DestinationInitial;
|
||||
|
|
@ -1144,10 +1144,10 @@ void TestMerge::testDeletedEntry()
|
|||
Merger merger(dbSource.data(), dbDestination.data());
|
||||
merger.merge();
|
||||
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1DestinationMerged);
|
||||
QVERIFY(!dbDestination->containsDeletedObject(entry1Uuid));
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2DestinationMerged);
|
||||
// Uuid in db and deletedObjects is intended according to KeePass #1752
|
||||
QVERIFY(dbDestination->containsDeletedObject(entry2Uuid));
|
||||
|
|
@ -1176,9 +1176,9 @@ void TestMerge::testDeletedGroup()
|
|||
|
||||
QPointer<Group> group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||
QVERIFY(group1SourceInitial != nullptr);
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1SourceInitial != nullptr);
|
||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2SourceInitial != nullptr);
|
||||
QUuid group1Uuid = group1SourceInitial->uuid();
|
||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||
|
|
@ -1206,11 +1206,11 @@ void TestMerge::testDeletedGroup()
|
|||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
||||
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1DestinationMerged);
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2DestinationMerged);
|
||||
QPointer<Entry> entry3DestinationMerged = dbDestination->rootGroup()->findEntry("entry3");
|
||||
QPointer<Entry> entry3DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry3");
|
||||
QVERIFY(entry3DestinationMerged);
|
||||
QPointer<Group> group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||
QVERIFY(group1DestinationMerged);
|
||||
|
|
@ -1228,7 +1228,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entry1DestinationInitial = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1DestinationInitial != nullptr);
|
||||
QUuid entry1Uuid = entry1DestinationInitial->uuid();
|
||||
delete entry1DestinationInitial;
|
||||
|
|
@ -1236,7 +1236,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2SourceInitial != nullptr);
|
||||
QUuid entry2Uuid = entry2SourceInitial->uuid();
|
||||
delete entry2SourceInitial;
|
||||
|
|
@ -1244,11 +1244,11 @@ void TestMerge::testDeletedRevertedEntry()
|
|||
|
||||
m_clock->advanceSecond(1);
|
||||
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1SourceInitial != nullptr);
|
||||
entry1SourceInitial->setNotes("Updated");
|
||||
|
||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2DestinationInitial != nullptr);
|
||||
entry2DestinationInitial->setNotes("Updated");
|
||||
|
||||
|
|
@ -1259,10 +1259,10 @@ void TestMerge::testDeletedRevertedEntry()
|
|||
QVERIFY(dbDestination->containsDeletedObject(entry1Uuid));
|
||||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||
QVERIFY(entry1DestinationMerged);
|
||||
QVERIFY(entry1DestinationMerged->notes() == "Updated");
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||
QVERIFY(entry2DestinationMerged);
|
||||
QVERIFY(entry2DestinationMerged->notes() == "Updated");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue