Add tests for FileKey::Type

This commit is contained in:
Janek Bevendorff 2017-12-27 14:36:21 +01:00 committed by Jonathan White
parent 871332ecf0
commit 98591c3bc0

View file

@ -35,6 +35,7 @@
#include "keys/PasswordKey.h" #include "keys/PasswordKey.h"
QTEST_GUILESS_MAIN(TestKeys) QTEST_GUILESS_MAIN(TestKeys)
Q_DECLARE_METATYPE(FileKey::Type);
void TestKeys::initTestCase() void TestKeys::initTestCase()
{ {
@ -84,9 +85,10 @@ void TestKeys::testComposite()
void TestKeys::testFileKey() void TestKeys::testFileKey()
{ {
QFETCH(QString, type); QFETCH(FileKey::Type, type);
QFETCH(QString, typeString);
QString name = QString("FileKey").append(type); QString name = QString("FileKey").append(typeString);
KeePass2Reader reader; KeePass2Reader reader;
@ -97,6 +99,9 @@ void TestKeys::testFileKey()
FileKey fileKey; FileKey fileKey;
QVERIFY(fileKey.load(keyFilename)); QVERIFY(fileKey.load(keyFilename));
QCOMPARE(fileKey.rawKey().size(), 32); QCOMPARE(fileKey.rawKey().size(), 32);
QCOMPARE(fileKey.type(), type);
compositeKey.addKey(fileKey); compositeKey.addKey(fileKey);
QScopedPointer<Database> db(reader.readDatabase(dbFilename, compositeKey)); QScopedPointer<Database> db(reader.readDatabase(dbFilename, compositeKey));
@ -107,12 +112,13 @@ void TestKeys::testFileKey()
void TestKeys::testFileKey_data() void TestKeys::testFileKey_data()
{ {
QTest::addColumn<QString>("type"); QTest::addColumn<FileKey::Type>("type");
QTest::newRow("Xml") << QString("Xml"); QTest::addColumn<QString>("typeString");
QTest::newRow("XmlBrokenBase64") << QString("XmlBrokenBase64"); QTest::newRow("Xml") << FileKey::KeePass2XML << QString("Xml");
QTest::newRow("Binary") << QString("Binary"); QTest::newRow("XmlBrokenBase64") << FileKey::Hashed << QString("XmlBrokenBase64");
QTest::newRow("Hex") << QString("Hex"); QTest::newRow("Binary") << FileKey::FixedBinary << QString("Binary");
QTest::newRow("Hashed") << QString("Hashed"); QTest::newRow("Hex") << FileKey::FixedBinaryHex << QString("Hex");
QTest::newRow("Hashed") << FileKey::Hashed << QString("Hashed");
} }
void TestKeys::testCreateFileKey() void TestKeys::testCreateFileKey()