mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Implement KDBX 4.1 PreviousParentGroup flag
This commit is contained in:
@@ -614,7 +614,7 @@ void TestEntry::testIsRecycled()
|
||||
QVERIFY(entry1->isRecycled());
|
||||
}
|
||||
|
||||
void TestEntry::testMove()
|
||||
void TestEntry::testMoveUpDown()
|
||||
{
|
||||
Database db;
|
||||
Group* root = db.rootGroup();
|
||||
@@ -724,3 +724,47 @@ void TestEntry::testMove()
|
||||
QCOMPARE(root->entries().at(2), entry1);
|
||||
QCOMPARE(root->entries().at(3), entry0);
|
||||
}
|
||||
|
||||
void TestEntry::testPreviousParentGroup()
|
||||
{
|
||||
Database db;
|
||||
auto* root = db.rootGroup();
|
||||
root->setUuid(QUuid::createUuid());
|
||||
QVERIFY(!root->uuid().isNull());
|
||||
|
||||
auto* group1 = new Group();
|
||||
group1->setUuid(QUuid::createUuid());
|
||||
group1->setParent(root);
|
||||
QVERIFY(!group1->uuid().isNull());
|
||||
|
||||
auto* group2 = new Group();
|
||||
group2->setParent(root);
|
||||
group2->setUuid(QUuid::createUuid());
|
||||
QVERIFY(!group2->uuid().isNull());
|
||||
|
||||
auto* entry = new Entry();
|
||||
QVERIFY(entry);
|
||||
QVERIFY(entry->previousParentGroupUuid().isNull());
|
||||
QVERIFY(!entry->previousParentGroup());
|
||||
|
||||
entry->setGroup(root);
|
||||
QVERIFY(entry->previousParentGroupUuid().isNull());
|
||||
QVERIFY(!entry->previousParentGroup());
|
||||
|
||||
// Previous parent shouldn't be recorded if new and old parent are the same
|
||||
entry->setGroup(root);
|
||||
QVERIFY(entry->previousParentGroupUuid().isNull());
|
||||
QVERIFY(!entry->previousParentGroup());
|
||||
|
||||
entry->setGroup(group1);
|
||||
QVERIFY(entry->previousParentGroupUuid() == root->uuid());
|
||||
QVERIFY(entry->previousParentGroup() == root);
|
||||
|
||||
entry->setGroup(group2);
|
||||
QVERIFY(entry->previousParentGroupUuid() == group1->uuid());
|
||||
QVERIFY(entry->previousParentGroup() == group1);
|
||||
|
||||
entry->setGroup(group2);
|
||||
QVERIFY(entry->previousParentGroupUuid() == group1->uuid());
|
||||
QVERIFY(entry->previousParentGroup() == group1);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ private slots:
|
||||
void testResolveNonIdPlaceholdersToUuid();
|
||||
void testResolveClonedEntry();
|
||||
void testIsRecycled();
|
||||
void testMove();
|
||||
void testMoveUpDown();
|
||||
void testPreviousParentGroup();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TESTENTRY_H
|
||||
|
||||
@@ -1143,7 +1143,7 @@ void TestGroup::testUsernamesRecursive()
|
||||
QVERIFY(usernames.indexOf("Name2") < usernames.indexOf("Name1"));
|
||||
}
|
||||
|
||||
void TestGroup::testMove()
|
||||
void TestGroup::testMoveUpDown()
|
||||
{
|
||||
Database database;
|
||||
Group* root = database.rootGroup();
|
||||
@@ -1253,3 +1253,40 @@ void TestGroup::testMove()
|
||||
QCOMPARE(root->entries().at(2), entry1);
|
||||
QCOMPARE(root->entries().at(3), entry0);
|
||||
}
|
||||
|
||||
void TestGroup::testPreviousParentGroup()
|
||||
{
|
||||
Database db;
|
||||
auto* root = db.rootGroup();
|
||||
root->setUuid(QUuid::createUuid());
|
||||
QVERIFY(!root->uuid().isNull());
|
||||
QVERIFY(!root->previousParentGroup());
|
||||
QVERIFY(root->previousParentGroupUuid().isNull());
|
||||
|
||||
auto* group1 = new Group();
|
||||
group1->setUuid(QUuid::createUuid());
|
||||
group1->setParent(root);
|
||||
QVERIFY(!group1->uuid().isNull());
|
||||
QVERIFY(!group1->previousParentGroup());
|
||||
QVERIFY(group1->previousParentGroupUuid().isNull());
|
||||
|
||||
auto* group2 = new Group();
|
||||
group2->setParent(root);
|
||||
group2->setUuid(QUuid::createUuid());
|
||||
QVERIFY(!group2->uuid().isNull());
|
||||
QVERIFY(!group2->previousParentGroup());
|
||||
QVERIFY(group2->previousParentGroupUuid().isNull());
|
||||
|
||||
group1->setParent(group2);
|
||||
QVERIFY(group1->previousParentGroupUuid() == root->uuid());
|
||||
QVERIFY(group1->previousParentGroup() == root);
|
||||
|
||||
// Previous parent shouldn't be recorded if new and old parent are the same
|
||||
group1->setParent(group2);
|
||||
QVERIFY(group1->previousParentGroupUuid() == root->uuid());
|
||||
QVERIFY(group1->previousParentGroup() == root);
|
||||
|
||||
group1->setParent(root);
|
||||
QVERIFY(group1->previousParentGroupUuid() == group2->uuid());
|
||||
QVERIFY(group1->previousParentGroup() == group2);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ private slots:
|
||||
void testHierarchy();
|
||||
void testApplyGroupIconRecursively();
|
||||
void testUsernamesRecursive();
|
||||
void testMove();
|
||||
void testMoveUpDown();
|
||||
void testPreviousParentGroup();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TESTGROUP_H
|
||||
|
||||
Reference in New Issue
Block a user