mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 15:29:51 -05:00
Fix issues with group functions (#2410)
This commit is contained in:
parent
7263dcddfe
commit
fa687f246e
@ -84,7 +84,7 @@ int Clip::clipEntry(Database* database, QString entryPath, QString timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
Entry* entry = database->rootGroup()->findEntry(entryPath);
|
Entry* entry = database->rootGroup()->findEntryByPath(entryPath);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl;
|
err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -82,7 +82,7 @@ int Show::showEntry(Database* database, QStringList attributes, const QString& e
|
|||||||
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||||
TextStream err(Utils::STDERR, QIODevice::WriteOnly);
|
TextStream err(Utils::STDERR, QIODevice::WriteOnly);
|
||||||
|
|
||||||
Entry* entry = database->rootGroup()->findEntry(entryPath);
|
Entry* entry = database->rootGroup()->findEntryByPath(entryPath);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
err << QObject::tr("Could not find entry with path %1.").arg(entryPath) << endl;
|
err << QObject::tr("Could not find entry with path %1.").arg(entryPath) << endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -321,9 +321,7 @@ void Group::setNotes(const QString& notes)
|
|||||||
|
|
||||||
void Group::setIcon(int iconNumber)
|
void Group::setIcon(int iconNumber)
|
||||||
{
|
{
|
||||||
Q_ASSERT(iconNumber >= 0);
|
if (iconNumber >= 0 && (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull())) {
|
||||||
|
|
||||||
if (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull()) {
|
|
||||||
m_data.iconNumber = iconNumber;
|
m_data.iconNumber = iconNumber;
|
||||||
m_data.customIcon = QUuid();
|
m_data.customIcon = QUuid();
|
||||||
emit modified();
|
emit modified();
|
||||||
@ -333,9 +331,7 @@ void Group::setIcon(int iconNumber)
|
|||||||
|
|
||||||
void Group::setIcon(const QUuid& uuid)
|
void Group::setIcon(const QUuid& uuid)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!uuid.isNull());
|
if (!uuid.isNull() && m_data.customIcon != uuid) {
|
||||||
|
|
||||||
if (m_data.customIcon != uuid) {
|
|
||||||
m_data.customIcon = uuid;
|
m_data.customIcon = uuid;
|
||||||
m_data.iconNumber = 0;
|
m_data.iconNumber = 0;
|
||||||
emit modified();
|
emit modified();
|
||||||
@ -552,36 +548,12 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems) const
|
|||||||
return entryList;
|
return entryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* Group::findEntry(QString entryId)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!entryId.isNull());
|
|
||||||
|
|
||||||
Entry* entry;
|
|
||||||
QUuid entryUuid = QUuid::fromRfc4122(QByteArray::fromHex(entryId.toLatin1()));
|
|
||||||
if (!entryUuid.isNull()) {
|
|
||||||
entry = findEntryByUuid(entryUuid);
|
|
||||||
if (entry) {
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = findEntryByPath(entryId);
|
|
||||||
if (entry) {
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Entry* entry : entriesRecursive(false)) {
|
|
||||||
if (entry->title() == entryId) {
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entry* Group::findEntryByUuid(const QUuid& uuid) const
|
Entry* Group::findEntryByUuid(const QUuid& uuid) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!uuid.isNull());
|
if (uuid.isNull()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry* entry : entriesRecursive(false)) {
|
for (Entry* entry : entriesRecursive(false)) {
|
||||||
if (entry->uuid() == uuid) {
|
if (entry->uuid() == uuid) {
|
||||||
return entry;
|
return entry;
|
||||||
@ -591,20 +563,34 @@ Entry* Group::findEntryByUuid(const QUuid& uuid) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* Group::findEntryByPath(QString entryPath, QString basePath)
|
Entry* Group::findEntryByPath(QString entryPath)
|
||||||
{
|
{
|
||||||
|
if (entryPath.isEmpty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Q_ASSERT(!entryPath.isNull());
|
// Add a beginning slash if the search string contains a slash
|
||||||
|
// We don't add a slash by default to allow searching by entry title
|
||||||
|
QString normalizedEntryPath = entryPath;
|
||||||
|
if (!normalizedEntryPath.startsWith("/") && normalizedEntryPath.contains("/")) {
|
||||||
|
normalizedEntryPath = "/" + normalizedEntryPath;
|
||||||
|
}
|
||||||
|
return findEntryByPathRecursive(normalizedEntryPath, "/");
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry* entry : asConst(m_entries)) {
|
Entry* Group::findEntryByPathRecursive(QString entryPath, QString basePath)
|
||||||
QString currentEntryPath = basePath + entry->title();
|
{
|
||||||
if (entryPath == currentEntryPath || entryPath == QString("/" + currentEntryPath)) {
|
// Return the first entry that matches the full path OR if there is no leading
|
||||||
|
// slash, return the first entry title that matches
|
||||||
|
for (Entry* entry : entries()) {
|
||||||
|
if (entryPath == (basePath + entry->title())
|
||||||
|
|| (!entryPath.startsWith("/") && entry->title() == entryPath)) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Group* group : asConst(m_children)) {
|
for (Group* group : children()) {
|
||||||
Entry* entry = group->findEntryByPath(entryPath, basePath + group->name() + QString("/"));
|
Entry* entry = group->findEntryByPathRecursive(entryPath, basePath + group->name() + "/");
|
||||||
if (entry != nullptr) {
|
if (entry != nullptr) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -615,22 +601,20 @@ Entry* Group::findEntryByPath(QString entryPath, QString basePath)
|
|||||||
|
|
||||||
Group* Group::findGroupByPath(QString groupPath)
|
Group* Group::findGroupByPath(QString groupPath)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!groupPath.isNull());
|
|
||||||
|
|
||||||
// normalize the groupPath by adding missing front and rear slashes. once.
|
// normalize the groupPath by adding missing front and rear slashes. once.
|
||||||
QString normalizedGroupPath;
|
QString normalizedGroupPath;
|
||||||
|
|
||||||
if (groupPath == "") {
|
if (groupPath.isEmpty()) {
|
||||||
normalizedGroupPath = QString("/"); // root group
|
normalizedGroupPath = QString("/"); // root group
|
||||||
} else {
|
} else {
|
||||||
normalizedGroupPath = ((groupPath.startsWith("/"))? "" : "/")
|
normalizedGroupPath = (groupPath.startsWith("/") ? "" : "/")
|
||||||
+ groupPath
|
+ groupPath
|
||||||
+ ((groupPath.endsWith("/") )? "" : "/");
|
+ (groupPath.endsWith("/") ? "" : "/");
|
||||||
}
|
}
|
||||||
return findGroupByPathRecursion(normalizedGroupPath, "/");
|
return findGroupByPathRecursive(normalizedGroupPath, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* Group::findGroupByPathRecursion(QString groupPath, QString basePath)
|
Group* Group::findGroupByPathRecursive(QString groupPath, QString basePath)
|
||||||
{
|
{
|
||||||
// paths must be normalized
|
// paths must be normalized
|
||||||
Q_ASSERT(groupPath.startsWith("/") && groupPath.endsWith("/"));
|
Q_ASSERT(groupPath.startsWith("/") && groupPath.endsWith("/"));
|
||||||
@ -642,7 +626,7 @@ Group* Group::findGroupByPathRecursion(QString groupPath, QString basePath)
|
|||||||
|
|
||||||
for (Group* innerGroup : children()) {
|
for (Group* innerGroup : children()) {
|
||||||
QString innerBasePath = basePath + innerGroup->name() + "/";
|
QString innerBasePath = basePath + innerGroup->name() + "/";
|
||||||
Group* group = innerGroup->findGroupByPathRecursion(groupPath, innerBasePath);
|
Group* group = innerGroup->findGroupByPathRecursive(groupPath, innerBasePath);
|
||||||
if (group != nullptr) {
|
if (group != nullptr) {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
@ -683,7 +667,7 @@ QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
|||||||
groupList.append(this);
|
groupList.append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Group* group : m_children) {
|
for (const Group* group : asConst(m_children)) {
|
||||||
groupList.append(group->groupsRecursive(true));
|
groupList.append(group->groupsRecursive(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,7 +712,10 @@ QSet<QUuid> Group::customIconsRecursive() const
|
|||||||
|
|
||||||
Group* Group::findGroupByUuid(const QUuid& uuid)
|
Group* Group::findGroupByUuid(const QUuid& uuid)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!uuid.isNull());
|
if (uuid.isNull()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
for (Group* group : groupsRecursive(true)) {
|
for (Group* group : groupsRecursive(true)) {
|
||||||
if (group->uuid() == uuid) {
|
if (group->uuid() == uuid) {
|
||||||
return group;
|
return group;
|
||||||
@ -749,6 +736,11 @@ Group* Group::findChildByName(const QString& name)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a duplicate of this group.
|
||||||
|
* Note that you need to copy the custom icons manually when inserting the
|
||||||
|
* new group into another database.
|
||||||
|
*/
|
||||||
Group* Group::clone(Entry::CloneFlags entryFlags, Group::CloneFlags groupFlags) const
|
Group* Group::clone(Entry::CloneFlags entryFlags, Group::CloneFlags groupFlags) const
|
||||||
{
|
{
|
||||||
Group* clonedGroup = new Group();
|
Group* clonedGroup = new Group();
|
||||||
@ -936,8 +928,11 @@ bool Group::resolveAutoTypeEnabled() const
|
|||||||
|
|
||||||
QStringList Group::locate(QString locateTerm, QString currentPath)
|
QStringList Group::locate(QString locateTerm, QString currentPath)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!locateTerm.isNull());
|
// TODO: Replace with EntrySearcher
|
||||||
QStringList response;
|
QStringList response;
|
||||||
|
if (locateTerm.isEmpty()) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry* entry : asConst(m_entries)) {
|
for (Entry* entry : asConst(m_entries)) {
|
||||||
QString entryPath = currentPath + entry->title();
|
QString entryPath = currentPath + entry->title();
|
||||||
@ -957,20 +952,15 @@ QStringList Group::locate(QString locateTerm, QString currentPath)
|
|||||||
|
|
||||||
Entry* Group::addEntryWithPath(QString entryPath)
|
Entry* Group::addEntryWithPath(QString entryPath)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!entryPath.isNull());
|
if (entryPath.isEmpty() || findEntryByPath(entryPath)) {
|
||||||
if (this->findEntryByPath(entryPath)) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList groups = entryPath.split("/");
|
QStringList groups = entryPath.split("/");
|
||||||
QString entryTitle = groups.takeLast();
|
QString entryTitle = groups.takeLast();
|
||||||
QString groupPath = groups.join("/");
|
QString groupPath = groups.join("/");
|
||||||
if (groupPath.isNull()) {
|
|
||||||
groupPath = QString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(!groupPath.isNull());
|
Group* group = findGroupByPath(groupPath);
|
||||||
Group* group = this->findGroupByPath(groupPath);
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -114,12 +114,11 @@ public:
|
|||||||
static const QString RootAutoTypeSequence;
|
static const QString RootAutoTypeSequence;
|
||||||
|
|
||||||
Group* findChildByName(const QString& name);
|
Group* findChildByName(const QString& name);
|
||||||
Entry* findEntry(QString entryId);
|
|
||||||
Entry* findEntryByUuid(const QUuid& uuid) const;
|
Entry* findEntryByUuid(const QUuid& uuid) const;
|
||||||
Entry* findEntryByPath(QString entryPath, QString basePath = QString(""));
|
Entry* findEntryByPath(QString entryPath);
|
||||||
Group* findGroupByUuid(const QUuid& uuid);
|
Group* findGroupByUuid(const QUuid& uuid);
|
||||||
Group* findGroupByPath(QString groupPath);
|
Group* findGroupByPath(QString groupPath);
|
||||||
QStringList locate(QString locateTerm, QString currentPath = QString("/"));
|
QStringList locate(QString locateTerm, QString currentPath = {"/"});
|
||||||
Entry* addEntryWithPath(QString entryPath);
|
Entry* addEntryWithPath(QString entryPath);
|
||||||
void setUuid(const QUuid& uuid);
|
void setUuid(const QUuid& uuid);
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
@ -154,11 +153,7 @@ public:
|
|||||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||||
QList<Group*> groupsRecursive(bool includeSelf);
|
QList<Group*> groupsRecursive(bool includeSelf);
|
||||||
QSet<QUuid> customIconsRecursive() const;
|
QSet<QUuid> customIconsRecursive() const;
|
||||||
/**
|
|
||||||
* Creates a duplicate of this group.
|
|
||||||
* Note that you need to copy the custom icons manually when inserting the
|
|
||||||
* new group into another database.
|
|
||||||
*/
|
|
||||||
Group* clone(Entry::CloneFlags entryFlags = DefaultEntryCloneFlags,
|
Group* clone(Entry::CloneFlags entryFlags = DefaultEntryCloneFlags,
|
||||||
CloneFlags groupFlags = DefaultCloneFlags) const;
|
CloneFlags groupFlags = DefaultCloneFlags) const;
|
||||||
|
|
||||||
@ -167,28 +162,22 @@ public:
|
|||||||
|
|
||||||
void addEntry(Entry* entry);
|
void addEntry(Entry* entry);
|
||||||
void removeEntry(Entry* entry);
|
void removeEntry(Entry* entry);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged(Group* group);
|
void dataChanged(Group* group);
|
||||||
|
|
||||||
void aboutToAdd(Group* group, int index);
|
void aboutToAdd(Group* group, int index);
|
||||||
void added();
|
void added();
|
||||||
void aboutToRemove(Group* group);
|
void aboutToRemove(Group* group);
|
||||||
void removed();
|
void removed();
|
||||||
/**
|
|
||||||
* Group moved within the database.
|
|
||||||
*/
|
|
||||||
void aboutToMove(Group* group, Group* toGroup, int index);
|
void aboutToMove(Group* group, Group* toGroup, int index);
|
||||||
void moved();
|
void moved();
|
||||||
|
void modified();
|
||||||
void entryAboutToAdd(Entry* entry);
|
void entryAboutToAdd(Entry* entry);
|
||||||
void entryAdded(Entry* entry);
|
void entryAdded(Entry* entry);
|
||||||
void entryAboutToRemove(Entry* entry);
|
void entryAboutToRemove(Entry* entry);
|
||||||
void entryRemoved(Entry* entry);
|
void entryRemoved(Entry* entry);
|
||||||
|
|
||||||
void entryDataChanged(Entry* entry);
|
void entryDataChanged(Entry* entry);
|
||||||
|
|
||||||
void modified();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateTimeinfo();
|
void updateTimeinfo();
|
||||||
|
|
||||||
@ -201,7 +190,8 @@ private:
|
|||||||
void cleanupParent();
|
void cleanupParent();
|
||||||
void recCreateDelObjects();
|
void recCreateDelObjects();
|
||||||
|
|
||||||
Group* findGroupByPathRecursion(QString groupPath, QString basePath);
|
Entry* findEntryByPathRecursive(QString entryPath, QString basePath);
|
||||||
|
Group* findGroupByPathRecursive(QString groupPath, QString basePath);
|
||||||
|
|
||||||
QPointer<Database> m_db;
|
QPointer<Database> m_db;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
|
@ -493,57 +493,64 @@ void TestGroup::testFindEntry()
|
|||||||
|
|
||||||
Entry* entry;
|
Entry* entry;
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(entry1->uuidToHex());
|
entry = db->rootGroup()->findEntryByUuid(entry1->uuid());
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry1"));
|
QCOMPARE(entry->title(), QString("entry1"));
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(QString("entry1"));
|
entry = db->rootGroup()->findEntryByPath(QString("entry1"));
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry1"));
|
QCOMPARE(entry->title(), QString("entry1"));
|
||||||
|
|
||||||
// We also can find the entry with the leading slash.
|
// We also can find the entry with the leading slash.
|
||||||
entry = db->rootGroup()->findEntry(QString("/entry1"));
|
entry = db->rootGroup()->findEntryByPath(QString("/entry1"));
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry1"));
|
QCOMPARE(entry->title(), QString("entry1"));
|
||||||
|
|
||||||
// But two slashes should not be accepted.
|
// But two slashes should not be accepted.
|
||||||
entry = db->rootGroup()->findEntry(QString("//entry1"));
|
entry = db->rootGroup()->findEntryByPath(QString("//entry1"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(entry2->uuidToHex());
|
entry = db->rootGroup()->findEntryByUuid(entry2->uuid());
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry2"));
|
QCOMPARE(entry->title(), QString("entry2"));
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(QString("group1/entry2"));
|
entry = db->rootGroup()->findEntryByPath(QString("group1/entry2"));
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry2"));
|
QCOMPARE(entry->title(), QString("entry2"));
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(QString("/entry2"));
|
entry = db->rootGroup()->findEntryByPath(QString("/entry2"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
// We also can find the entry with the leading slash.
|
// We also can find the entry with the leading slash.
|
||||||
entry = db->rootGroup()->findEntry(QString("/group1/entry2"));
|
entry = db->rootGroup()->findEntryByPath(QString("/group1/entry2"));
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry2"));
|
QCOMPARE(entry->title(), QString("entry2"));
|
||||||
|
|
||||||
// Should also find the entry only by title.
|
// Should also find the entry only by title.
|
||||||
entry = db->rootGroup()->findEntry(QString("entry2"));
|
entry = db->rootGroup()->findEntryByPath(QString("entry2"));
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QCOMPARE(entry->title(), QString("entry2"));
|
QCOMPARE(entry->title(), QString("entry2"));
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(QString("invalid/path/to/entry2"));
|
entry = db->rootGroup()->findEntryByPath(QString("invalid/path/to/entry2"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
entry = db->rootGroup()->findEntry(QString("entry27"));
|
entry = db->rootGroup()->findEntryByPath(QString("entry27"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
// A valid UUID that does not exist in this database.
|
// A valid UUID that does not exist in this database.
|
||||||
entry = db->rootGroup()->findEntry(QString("febfb01ebcdf9dbd90a3f1579dc75281"));
|
entry = db->rootGroup()->findEntryByUuid(QUuid("febfb01ebcdf9dbd90a3f1579dc75281"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
// An invalid UUID.
|
// An invalid UUID.
|
||||||
entry = db->rootGroup()->findEntry(QString("febfb01ebcdf9dbd90a3f1579dc"));
|
entry = db->rootGroup()->findEntryByUuid(QUuid("febfb01ebcdf9dbd90a3f1579dc"));
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
|
// Empty strings
|
||||||
|
entry = db->rootGroup()->findEntryByUuid({});
|
||||||
|
QVERIFY(!entry);
|
||||||
|
|
||||||
|
entry = db->rootGroup()->findEntryByPath({});
|
||||||
|
QVERIFY(!entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGroup::testFindGroupByPath()
|
void TestGroup::testFindGroupByPath()
|
||||||
@ -561,51 +568,51 @@ void TestGroup::testFindGroupByPath()
|
|||||||
Group* group;
|
Group* group;
|
||||||
|
|
||||||
group = db->rootGroup()->findGroupByPath("/");
|
group = db->rootGroup()->findGroupByPath("/");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), db->rootGroup()->uuid());
|
QCOMPARE(group->uuid(), db->rootGroup()->uuid());
|
||||||
|
|
||||||
// We also accept it if the leading slash is missing.
|
// We also accept it if the leading slash is missing.
|
||||||
group = db->rootGroup()->findGroupByPath("");
|
group = db->rootGroup()->findGroupByPath("");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), db->rootGroup()->uuid());
|
QCOMPARE(group->uuid(), db->rootGroup()->uuid());
|
||||||
|
|
||||||
group = db->rootGroup()->findGroupByPath("/group1/");
|
group = db->rootGroup()->findGroupByPath("/group1/");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group1->uuid());
|
QCOMPARE(group->uuid(), group1->uuid());
|
||||||
|
|
||||||
// We also accept it if the leading slash is missing.
|
// We also accept it if the leading slash is missing.
|
||||||
group = db->rootGroup()->findGroupByPath("group1/");
|
group = db->rootGroup()->findGroupByPath("group1/");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group1->uuid());
|
QCOMPARE(group->uuid(), group1->uuid());
|
||||||
|
|
||||||
// Too many slashes at the end
|
// Too many slashes at the end
|
||||||
group = db->rootGroup()->findGroupByPath("group1//");
|
group = db->rootGroup()->findGroupByPath("group1//");
|
||||||
QVERIFY(group == nullptr);
|
QVERIFY(!group);
|
||||||
|
|
||||||
// Missing a slash at the end.
|
// Missing a slash at the end.
|
||||||
group = db->rootGroup()->findGroupByPath("/group1");
|
group = db->rootGroup()->findGroupByPath("/group1");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group1->uuid());
|
QCOMPARE(group->uuid(), group1->uuid());
|
||||||
|
|
||||||
// Too many slashes at the start
|
// Too many slashes at the start
|
||||||
group = db->rootGroup()->findGroupByPath("//group1");
|
group = db->rootGroup()->findGroupByPath("//group1");
|
||||||
QVERIFY(group == nullptr);
|
QVERIFY(!group);
|
||||||
|
|
||||||
group = db->rootGroup()->findGroupByPath("/group1/group2/");
|
group = db->rootGroup()->findGroupByPath("/group1/group2/");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group2->uuid());
|
QCOMPARE(group->uuid(), group2->uuid());
|
||||||
|
|
||||||
// We also accept it if the leading slash is missing.
|
// We also accept it if the leading slash is missing.
|
||||||
group = db->rootGroup()->findGroupByPath("group1/group2/");
|
group = db->rootGroup()->findGroupByPath("group1/group2/");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group2->uuid());
|
QCOMPARE(group->uuid(), group2->uuid());
|
||||||
|
|
||||||
group = db->rootGroup()->findGroupByPath("group1/group2");
|
group = db->rootGroup()->findGroupByPath("group1/group2");
|
||||||
QVERIFY(group != nullptr);
|
QVERIFY(group);
|
||||||
QCOMPARE(group->uuid(), group2->uuid());
|
QCOMPARE(group->uuid(), group2->uuid());
|
||||||
|
|
||||||
group = db->rootGroup()->findGroupByPath("invalid");
|
group = db->rootGroup()->findGroupByPath("invalid");
|
||||||
QVERIFY(group == nullptr);
|
QVERIFY(!group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGroup::testPrint()
|
void TestGroup::testPrint()
|
||||||
@ -697,7 +704,7 @@ void TestGroup::testLocate()
|
|||||||
QVERIFY(results.contains("/entry1"));
|
QVERIFY(results.contains("/entry1"));
|
||||||
|
|
||||||
results = db->rootGroup()->locate("invalid");
|
results = db->rootGroup()->locate("invalid");
|
||||||
QVERIFY(results.size() == 0);
|
QVERIFY(results.isEmpty());
|
||||||
|
|
||||||
results = db->rootGroup()->locate("google");
|
results = db->rootGroup()->locate("google");
|
||||||
QVERIFY(results.size() == 1);
|
QVERIFY(results.size() == 1);
|
||||||
@ -725,37 +732,37 @@ void TestGroup::testAddEntryWithPath()
|
|||||||
group2->setParent(group1);
|
group2->setParent(group1);
|
||||||
|
|
||||||
Entry* entry = db->rootGroup()->addEntryWithPath("entry1");
|
Entry* entry = db->rootGroup()->addEntryWithPath("entry1");
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QVERIFY(!entry->uuid().isNull());
|
QVERIFY(!entry->uuid().isNull());
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("entry1");
|
entry = db->rootGroup()->addEntryWithPath("entry1");
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("/entry1");
|
entry = db->rootGroup()->addEntryWithPath("/entry1");
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("entry2");
|
entry = db->rootGroup()->addEntryWithPath("entry2");
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QVERIFY(entry->title() == "entry2");
|
QVERIFY(entry->title() == "entry2");
|
||||||
QVERIFY(!entry->uuid().isNull());
|
QVERIFY(!entry->uuid().isNull());
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("/entry3");
|
entry = db->rootGroup()->addEntryWithPath("/entry3");
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QVERIFY(entry->title() == "entry3");
|
QVERIFY(entry->title() == "entry3");
|
||||||
QVERIFY(!entry->uuid().isNull());
|
QVERIFY(!entry->uuid().isNull());
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("/group1/entry4");
|
entry = db->rootGroup()->addEntryWithPath("/group1/entry4");
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QVERIFY(entry->title() == "entry4");
|
QVERIFY(entry->title() == "entry4");
|
||||||
QVERIFY(!entry->uuid().isNull());
|
QVERIFY(!entry->uuid().isNull());
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("/group1/group2/entry5");
|
entry = db->rootGroup()->addEntryWithPath("/group1/group2/entry5");
|
||||||
QVERIFY(entry != nullptr);
|
QVERIFY(entry);
|
||||||
QVERIFY(entry->title() == "entry5");
|
QVERIFY(entry->title() == "entry5");
|
||||||
QVERIFY(!entry->uuid().isNull());
|
QVERIFY(!entry->uuid().isNull());
|
||||||
|
|
||||||
entry = db->rootGroup()->addEntryWithPath("/group1/invalid_group/entry6");
|
entry = db->rootGroup()->addEntryWithPath("/group1/invalid_group/entry6");
|
||||||
QVERIFY(entry == nullptr);
|
QVERIFY(!entry);
|
||||||
|
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void TestMerge::testResolveConflictNewer()
|
|||||||
QVERIFY(groupDestinationInitial != nullptr);
|
QVERIFY(groupDestinationInitial != nullptr);
|
||||||
QCOMPARE(groupDestinationInitial->entries().size(), 2);
|
QCOMPARE(groupDestinationInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ void TestMerge::testResolveConflictNewer()
|
|||||||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationInitialTimeInfo);
|
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationInitialTimeInfo);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->password(), QString("password"));
|
QCOMPARE(entryDestinationMerged->password(), QString("password"));
|
||||||
@ -192,7 +192,7 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
QVERIFY(groupDestinationInitial != nullptr);
|
QVERIFY(groupDestinationInitial != nullptr);
|
||||||
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
QCOMPARE(groupSourceInitial->entries().size(), 2);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
QVERIFY(entrySourceInitial->group() == groupSourceInitial);
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
QPointer<Group> groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
QPointer<Group> groupDestinationUpdated = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(groupDestinationUpdated != nullptr);
|
QVERIFY(groupDestinationUpdated != nullptr);
|
||||||
QCOMPARE(groupDestinationUpdated->entries().size(), 2);
|
QCOMPARE(groupDestinationUpdated->entries().size(), 2);
|
||||||
QPointer<Entry> entryDestinationUpdated = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationUpdated = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationUpdated != nullptr);
|
QVERIFY(entryDestinationUpdated != nullptr);
|
||||||
QVERIFY(entryDestinationUpdated->group() == groupDestinationUpdated);
|
QVERIFY(entryDestinationUpdated->group() == groupDestinationUpdated);
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ void TestMerge::testResolveConflictExisting()
|
|||||||
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
QCOMPARE(groupDestinationMerged->entries().size(), 2);
|
||||||
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationUpdatedNewerTimeInfo);
|
QCOMPARE(groupDestinationMerged->timeInfo(), groupDestinationUpdatedNewerTimeInfo);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->password(), QString("password2"));
|
QCOMPARE(entryDestinationMerged->password(), QString("password2"));
|
||||||
QCOMPARE(entryDestinationMerged->timeInfo(), entryDestinationUpdatedNewerTimeInfo);
|
QCOMPARE(entryDestinationMerged->timeInfo(), entryDestinationUpdatedNewerTimeInfo);
|
||||||
@ -382,9 +382,9 @@ void TestMerge::testResolveConflictTemplate(int mergeMode, std::function<void(Da
|
|||||||
|
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
|
|
||||||
QPointer<Entry> deletedEntryDestination = dbDestination->rootGroup()->findEntry("deletedDestination");
|
QPointer<Entry> deletedEntryDestination = dbDestination->rootGroup()->findEntryByPath("deletedDestination");
|
||||||
dbDestination->recycleEntry(deletedEntryDestination);
|
dbDestination->recycleEntry(deletedEntryDestination);
|
||||||
QPointer<Entry> deletedEntrySource = dbSource->rootGroup()->findEntry("deletedSource");
|
QPointer<Entry> deletedEntrySource = dbSource->rootGroup()->findEntryByPath("deletedSource");
|
||||||
dbSource->recycleEntry(deletedEntrySource);
|
dbSource->recycleEntry(deletedEntrySource);
|
||||||
|
|
||||||
m_clock->advanceMinute(1);
|
m_clock->advanceMinute(1);
|
||||||
@ -428,8 +428,8 @@ void TestMerge::testResolveConflictTemplate(int mergeMode, std::function<void(Da
|
|||||||
|
|
||||||
verification(dbDestination.data(), timestamps);
|
verification(dbDestination.data(), timestamps);
|
||||||
|
|
||||||
QVERIFY(dbDestination->rootGroup()->findEntry("entryDestination"));
|
QVERIFY(dbDestination->rootGroup()->findEntryByPath("entryDestination"));
|
||||||
QVERIFY(dbDestination->rootGroup()->findEntry("entrySource"));
|
QVERIFY(dbDestination->rootGroup()->findEntryByPath("entrySource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMerge::testDeletionConflictTemplate(int mergeMode, std::function<void(Database*, const QMap<QString, QUuid>&)> verification)
|
void TestMerge::testDeletionConflictTemplate(int mergeMode, std::function<void(Database*, const QMap<QString, QUuid>&)> verification)
|
||||||
@ -790,7 +790,7 @@ void TestMerge::testMoveEntry()
|
|||||||
QScopedPointer<Database> dbSource(
|
QScopedPointer<Database> dbSource(
|
||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
|
|
||||||
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
QPointer<Group> groupSourceInitial = dbSource->rootGroup()->findChildByName("group2");
|
||||||
@ -807,7 +807,7 @@ void TestMerge::testMoveEntry()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
@ -824,7 +824,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
QScopedPointer<Database> dbSource(
|
QScopedPointer<Database> dbSource(
|
||||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
|
|
||||||
QPointer<Group> group2Source = dbSource->rootGroup()->findChildByName("group2");
|
QPointer<Group> group2Source = dbSource->rootGroup()->findChildByName("group2");
|
||||||
@ -835,7 +835,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
entrySourceInitial->setGroup(group2Source);
|
entrySourceInitial->setGroup(group2Source);
|
||||||
QCOMPARE(entrySourceInitial->group()->name(), QString("group2"));
|
QCOMPARE(entrySourceInitial->group()->name(), QString("group2"));
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationInitial = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationInitial != nullptr);
|
QVERIFY(entryDestinationInitial != nullptr);
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -849,7 +849,7 @@ void TestMerge::testMoveEntryPreserveChanges()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2"));
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
||||||
@ -892,7 +892,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||||||
groupSourceCreated->setUuid(QUuid::createUuid());
|
groupSourceCreated->setUuid(QUuid::createUuid());
|
||||||
groupSourceCreated->setParent(dbSource->rootGroup());
|
groupSourceCreated->setParent(dbSource->rootGroup());
|
||||||
|
|
||||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
entrySourceMoved->setGroup(groupSourceCreated);
|
entrySourceMoved->setGroup(groupSourceCreated);
|
||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
@ -907,7 +907,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
|||||||
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
QCOMPARE(groupDestinationMerged->name(), QString("group3"));
|
||||||
QCOMPARE(groupDestinationMerged->entries().size(), 1);
|
QCOMPARE(groupDestinationMerged->entries().size(), 1);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMerged != nullptr);
|
QVERIFY(entryDestinationMerged != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group3"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group3"));
|
||||||
}
|
}
|
||||||
@ -929,7 +929,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entryDestinationMoved = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entryDestinationMoved = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entryDestinationMoved != nullptr);
|
QVERIFY(entryDestinationMoved != nullptr);
|
||||||
entryDestinationMoved->setGroup(groupDestinationCreated);
|
entryDestinationMoved->setGroup(groupDestinationCreated);
|
||||||
QUuid uuidBeforeSyncing = entryDestinationMoved->uuid();
|
QUuid uuidBeforeSyncing = entryDestinationMoved->uuid();
|
||||||
@ -938,7 +938,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
// Change the entry in the source db.
|
// Change the entry in the source db.
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceMoved = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceMoved != nullptr);
|
QVERIFY(entrySourceMoved != nullptr);
|
||||||
entrySourceMoved->beginUpdate();
|
entrySourceMoved->beginUpdate();
|
||||||
entrySourceMoved->setUsername("username");
|
entrySourceMoved->setUsername("username");
|
||||||
@ -954,7 +954,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
|||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
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 != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->username(), QString("username"));
|
QCOMPARE(entryDestinationMerged->username(), QString("username"));
|
||||||
@ -983,7 +983,7 @@ void TestMerge::testUpdateGroup()
|
|||||||
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
||||||
groupSourceInitial->setIcon(customIconId);
|
groupSourceInitial->setIcon(customIconId);
|
||||||
|
|
||||||
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entrySourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entrySourceInitial != nullptr);
|
QVERIFY(entrySourceInitial != nullptr);
|
||||||
entrySourceInitial->setGroup(groupSourceInitial);
|
entrySourceInitial->setGroup(groupSourceInitial);
|
||||||
entrySourceInitial->setTitle("entry1 renamed");
|
entrySourceInitial->setTitle("entry1 renamed");
|
||||||
@ -996,7 +996,7 @@ void TestMerge::testUpdateGroup()
|
|||||||
|
|
||||||
QCOMPARE(dbDestination->rootGroup()->entriesRecursive().size(), 2);
|
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 != nullptr);
|
||||||
QVERIFY(entryDestinationMerged->group() != nullptr);
|
QVERIFY(entryDestinationMerged->group() != nullptr);
|
||||||
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2 renamed"));
|
QCOMPARE(entryDestinationMerged->group()->name(), QString("group2 renamed"));
|
||||||
@ -1125,7 +1125,7 @@ void TestMerge::testDeletedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||||
delete entry1SourceInitial;
|
delete entry1SourceInitial;
|
||||||
@ -1133,7 +1133,7 @@ void TestMerge::testDeletedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationInitial != nullptr);
|
QVERIFY(entry2DestinationInitial != nullptr);
|
||||||
QUuid entry2Uuid = entry2DestinationInitial->uuid();
|
QUuid entry2Uuid = entry2DestinationInitial->uuid();
|
||||||
delete entry2DestinationInitial;
|
delete entry2DestinationInitial;
|
||||||
@ -1144,10 +1144,10 @@ void TestMerge::testDeletedEntry()
|
|||||||
Merger merger(dbSource.data(), dbDestination.data());
|
Merger merger(dbSource.data(), dbDestination.data());
|
||||||
merger.merge();
|
merger.merge();
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(entry1Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry1Uuid));
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
// Uuid in db and deletedObjects is intended according to KeePass #1752
|
// Uuid in db and deletedObjects is intended according to KeePass #1752
|
||||||
QVERIFY(dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
@ -1176,9 +1176,9 @@ void TestMerge::testDeletedGroup()
|
|||||||
|
|
||||||
QPointer<Group> group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
QPointer<Group> group1SourceInitial = dbSource->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1SourceInitial != nullptr);
|
QVERIFY(group1SourceInitial != nullptr);
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2SourceInitial != nullptr);
|
QVERIFY(entry2SourceInitial != nullptr);
|
||||||
QUuid group1Uuid = group1SourceInitial->uuid();
|
QUuid group1Uuid = group1SourceInitial->uuid();
|
||||||
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
QUuid entry1Uuid = entry1SourceInitial->uuid();
|
||||||
@ -1206,11 +1206,11 @@ void TestMerge::testDeletedGroup()
|
|||||||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(group2Uuid));
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
QPointer<Entry> entry3DestinationMerged = dbDestination->rootGroup()->findEntry("entry3");
|
QPointer<Entry> entry3DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry3");
|
||||||
QVERIFY(entry3DestinationMerged);
|
QVERIFY(entry3DestinationMerged);
|
||||||
QPointer<Group> group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
QPointer<Group> group1DestinationMerged = dbDestination->rootGroup()->findChildByName("group1");
|
||||||
QVERIFY(group1DestinationMerged);
|
QVERIFY(group1DestinationMerged);
|
||||||
@ -1228,7 +1228,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationInitial = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationInitial != nullptr);
|
QVERIFY(entry1DestinationInitial != nullptr);
|
||||||
QUuid entry1Uuid = entry1DestinationInitial->uuid();
|
QUuid entry1Uuid = entry1DestinationInitial->uuid();
|
||||||
delete entry1DestinationInitial;
|
delete entry1DestinationInitial;
|
||||||
@ -1236,7 +1236,7 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2SourceInitial = dbSource->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2SourceInitial != nullptr);
|
QVERIFY(entry2SourceInitial != nullptr);
|
||||||
QUuid entry2Uuid = entry2SourceInitial->uuid();
|
QUuid entry2Uuid = entry2SourceInitial->uuid();
|
||||||
delete entry2SourceInitial;
|
delete entry2SourceInitial;
|
||||||
@ -1244,11 +1244,11 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
|
|
||||||
m_clock->advanceSecond(1);
|
m_clock->advanceSecond(1);
|
||||||
|
|
||||||
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1SourceInitial = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1SourceInitial != nullptr);
|
QVERIFY(entry1SourceInitial != nullptr);
|
||||||
entry1SourceInitial->setNotes("Updated");
|
entry1SourceInitial->setNotes("Updated");
|
||||||
|
|
||||||
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2DestinationInitial = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationInitial != nullptr);
|
QVERIFY(entry2DestinationInitial != nullptr);
|
||||||
entry2DestinationInitial->setNotes("Updated");
|
entry2DestinationInitial->setNotes("Updated");
|
||||||
|
|
||||||
@ -1259,10 +1259,10 @@ void TestMerge::testDeletedRevertedEntry()
|
|||||||
QVERIFY(dbDestination->containsDeletedObject(entry1Uuid));
|
QVERIFY(dbDestination->containsDeletedObject(entry1Uuid));
|
||||||
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
QVERIFY(!dbDestination->containsDeletedObject(entry2Uuid));
|
||||||
|
|
||||||
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntry("entry1");
|
QPointer<Entry> entry1DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry1");
|
||||||
QVERIFY(entry1DestinationMerged);
|
QVERIFY(entry1DestinationMerged);
|
||||||
QVERIFY(entry1DestinationMerged->notes() == "Updated");
|
QVERIFY(entry1DestinationMerged->notes() == "Updated");
|
||||||
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntry("entry2");
|
QPointer<Entry> entry2DestinationMerged = dbDestination->rootGroup()->findEntryByPath("entry2");
|
||||||
QVERIFY(entry2DestinationMerged);
|
QVERIFY(entry2DestinationMerged);
|
||||||
QVERIFY(entry2DestinationMerged->notes() == "Updated");
|
QVERIFY(entry2DestinationMerged->notes() == "Updated");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user