mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-31 20:34:27 -04:00
Add tests for broken databases.
Make sure we detect the error and don't crash.
This commit is contained in:
parent
e16720d06d
commit
f1bebe904a
5 changed files with 50 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "TestKeePass2XmlReader.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
|
@ -351,6 +352,26 @@ void TestKeePass2XmlReader::testDeletedObjects()
|
|||
QVERIFY(objList.isEmpty());
|
||||
}
|
||||
|
||||
void TestKeePass2XmlReader::testBroken()
|
||||
{
|
||||
QFETCH(QString, baseName);
|
||||
|
||||
KeePass2XmlReader reader;
|
||||
QString xmlFile = QString("%1/%2.xml").arg(KEEPASSX_TEST_DATA_DIR, baseName);
|
||||
QVERIFY(QFile::exists(xmlFile));
|
||||
QScopedPointer<Database> db(reader.readDatabase(xmlFile));
|
||||
QVERIFY(reader.hasError());
|
||||
}
|
||||
|
||||
void TestKeePass2XmlReader::testBroken_data()
|
||||
{
|
||||
QTest::addColumn<QString>("baseName");
|
||||
|
||||
QTest::newRow("BrokenNoGroupUuid") << "BrokenNoGroupUuid";
|
||||
QTest::newRow("BrokenNoEntryUuid") << "BrokenNoEntryUuid";
|
||||
QTest::newRow("BrokenNoRootGroup") << "BrokenNoRootGroup";
|
||||
}
|
||||
|
||||
void TestKeePass2XmlReader::cleanupTestCase()
|
||||
{
|
||||
delete m_db;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue