Add support for gzip compressed databases.

This commit is contained in:
Felix Geyer
2010-09-23 22:27:59 +02:00
parent f0e711ac23
commit b8dfb9cc4d
13 changed files with 1290 additions and 11 deletions

View File

@@ -66,22 +66,22 @@ endmacro (ADD_UNIT_TEST)
# TODO automocify?
add_unit_test( testgroup TestGroup.cpp )
target_link_libraries( testgroup keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testgroup keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testkeepass2xmlreader TestKeePass2XmlReader.cpp )
target_link_libraries( testkeepass2xmlreader keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testkeepass2xmlreader keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testkeepass2reader TestKeePass2Reader.cpp )
target_link_libraries( testkeepass2reader keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testkeepass2reader keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testgroupmodel TestGroupModel.cpp modeltest.cpp )
target_link_libraries( testgroupmodel keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testgroupmodel keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testentrymodel TestEntryModel.cpp modeltest.cpp )
target_link_libraries( testentrymodel keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testentrymodel keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testcryptohash TestCryptoHash.cpp )
target_link_libraries( testcryptohash keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( testcryptohash keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
add_unit_test( testsymmetriccipher TestSymmetricCipher.cpp )
target_link_libraries( testsymmetriccipher keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBGCRYPT_LIBS} )

BIN
tests/Compressed.kdbx Normal file

Binary file not shown.

View File

@@ -31,6 +31,7 @@ class TestKeePass2Reader : public QObject
private Q_SLOTS:
void initTestCase();
void testNonAscii();
void testCompressed();
};
void TestKeePass2Reader::initTestCase()
@@ -50,6 +51,18 @@ void TestKeePass2Reader::testNonAscii()
QCOMPARE(db->metadata()->name(), QString("NonAsciiTest"));
}
void TestKeePass2Reader::testCompressed()
{
QString filename = QString(KEEPASSX_TEST_DIR).append("/Compressed.kdbx");
CompositeKey key;
key.addKey(PasswordKey(""));
KeePass2Reader* reader = new KeePass2Reader();
Database* db = reader->readDatabase(filename, key);
QVERIFY(db);
QVERIFY(!reader->error());
QCOMPARE(db->metadata()->name(), QString("Compressed"));
}
QTEST_MAIN(TestKeePass2Reader);
#include "TestKeePass2Reader.moc"