mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 06:36:07 -04:00
Implement support for parsing groups and entries from KeePass 1 databases.
Still missing: - Key files. - Twofish encryption. Refs #2
This commit is contained in:
parent
6234065898
commit
79b15e2ac6
6 changed files with 454 additions and 2 deletions
|
@ -22,6 +22,8 @@
|
|||
#include "config-keepassx-tests.h"
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "format/KeePass1Reader.h"
|
||||
|
||||
|
@ -39,7 +41,49 @@ void TestKeePass1Reader::testBasic()
|
|||
QVERIFY(db);
|
||||
QVERIFY(!reader.hasError());
|
||||
|
||||
QCOMPARE(db->rootGroup()->children().size(), 2);
|
||||
|
||||
Group* group1 = db->rootGroup()->children().at(0);
|
||||
QCOMPARE(group1->name(), QString("Internet"));
|
||||
QCOMPARE(group1->iconNumber(), 1);
|
||||
QCOMPARE(group1->entries().size(), 2);
|
||||
|
||||
Entry* entry11 = group1->entries().at(0);
|
||||
QCOMPARE(entry11->title(), QString("Test entry"));
|
||||
QCOMPARE(entry11->iconNumber(), 1);
|
||||
QCOMPARE(entry11->username(), QString("I"));
|
||||
QCOMPARE(entry11->url(), QString("http://example.com/"));
|
||||
QCOMPARE(entry11->password(), QString("secretpassword"));
|
||||
QCOMPARE(entry11->notes(), QString("Lorem ipsum\ndolor sit amet"));
|
||||
QVERIFY(entry11->timeInfo().expires());
|
||||
QCOMPARE(entry11->timeInfo().expiryTime(), genDT(2012, 5, 9, 10, 32));
|
||||
QCOMPARE(entry11->attachments()->keys().size(), 1);
|
||||
QCOMPARE(entry11->attachments()->keys().first(), QString("attachment.txt"));
|
||||
QCOMPARE(entry11->attachments()->value("attachment.txt"), QByteArray("hello world\n"));
|
||||
|
||||
Entry* entry12 = group1->entries().at(1);
|
||||
QCOMPARE(entry12->title(), QString(""));
|
||||
QCOMPARE(entry12->iconNumber(), 0);
|
||||
QCOMPARE(entry12->username(), QString(""));
|
||||
QCOMPARE(entry12->url(), QString(""));
|
||||
QCOMPARE(entry12->password(), QString(""));
|
||||
QCOMPARE(entry12->notes(), QString(""));
|
||||
QVERIFY(!entry12->timeInfo().expires());
|
||||
QCOMPARE(entry12->attachments()->keys().size(), 0);
|
||||
|
||||
Group* group2 = db->rootGroup()->children().at(1);
|
||||
QCOMPARE(group2->name(), QString("eMail"));
|
||||
QCOMPARE(group2->iconNumber(), 19);
|
||||
QCOMPARE(group2->entries().size(), 0);
|
||||
|
||||
delete db;
|
||||
}
|
||||
|
||||
QDateTime TestKeePass1Reader::genDT(int year, int month, int day, int hour, int min)
|
||||
{
|
||||
QDate date(year, month, day);
|
||||
QTime time(hour, min, 0);
|
||||
return QDateTime(date, time, Qt::UTC);
|
||||
}
|
||||
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass1Reader)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue