mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Enforce that group/entry uuid is set when writing a database.
This commit is contained in:
parent
4ebcd53801
commit
bce46c5ece
@ -29,6 +29,7 @@ Database::Database()
|
||||
{
|
||||
m_metadata = new Metadata(this);
|
||||
setRootGroup(new Group());
|
||||
rootGroup()->setUuid(Uuid::random());
|
||||
|
||||
m_cipher = KeePass2::CIPHER_AES;
|
||||
m_compressionAlgo = CompressionGZip;
|
||||
|
@ -169,6 +169,8 @@ void KeePass2XmlWriter::writeRoot()
|
||||
|
||||
void KeePass2XmlWriter::writeGroup(const Group* group)
|
||||
{
|
||||
Q_ASSERT(!group->uuid().isNull());
|
||||
|
||||
m_xml.writeStartElement("Group");
|
||||
|
||||
writeUuid("UUID", group->uuid());
|
||||
@ -237,6 +239,8 @@ void KeePass2XmlWriter::writeDeletedObject(const DeletedObject& delObj)
|
||||
|
||||
void KeePass2XmlWriter::writeEntry(const Entry* entry)
|
||||
{
|
||||
Q_ASSERT(!entry->uuid().isNull());
|
||||
|
||||
m_xml.writeStartElement("Entry");
|
||||
|
||||
writeUuid("UUID", entry->uuid());
|
||||
|
@ -23,11 +23,13 @@
|
||||
#include "modeltest.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "gui/GroupModel.h"
|
||||
|
||||
void TestGroupModel::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QModelIndex>("QModelIndex");
|
||||
Crypto::init();
|
||||
}
|
||||
|
||||
void TestGroupModel::test()
|
||||
|
@ -45,6 +45,10 @@ void TestKeePass2Writer::initTestCase()
|
||||
entry->addAttribute("test", "protectedTest", true);
|
||||
QVERIFY(entry->isAttributeProtected("test"));
|
||||
entry->setGroup(group);
|
||||
Group* groupNew = new Group();
|
||||
groupNew->setUuid(Uuid::random());
|
||||
groupNew->setName("TESTGROUP");
|
||||
groupNew->setParent(group);
|
||||
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
@ -63,6 +67,7 @@ void TestKeePass2Writer::testBasic()
|
||||
{
|
||||
QCOMPARE(m_dbTest->metadata()->name(), m_dbOrg->metadata()->name());
|
||||
QVERIFY(m_dbTest->rootGroup());
|
||||
QCOMPARE(m_dbTest->rootGroup()->children()[0]->name(), m_dbOrg->rootGroup()->children()[0]->name());
|
||||
}
|
||||
|
||||
void TestKeePass2Writer::testProtectedAttributes()
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "format/KeePass2XmlReader.h"
|
||||
#include "config-keepassx-tests.h"
|
||||
|
||||
@ -63,6 +64,8 @@ QDateTime TestKeePass2XmlReader::genDT(int year, int month, int day, int hour, i
|
||||
|
||||
void TestKeePass2XmlReader::initTestCase()
|
||||
{
|
||||
Crypto::init();
|
||||
|
||||
KeePass2XmlReader* reader = new KeePass2XmlReader();
|
||||
QString xmlFile = QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.xml");
|
||||
m_db = reader->readDatabase(xmlFile);
|
||||
|
Loading…
Reference in New Issue
Block a user