Formatting the code.
This commit is contained in:
@@ -18,17 +18,16 @@
|
||||
#include "TestKdbx4.h"
|
||||
#include "TestGlobal.h"
|
||||
|
||||
#include "config-keepassx-tests.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
#include "keys/FileKey.h"
|
||||
#include "mock/MockChallengeResponseKey.h"
|
||||
#include "format/KdbxXmlReader.h"
|
||||
#include "format/KdbxXmlWriter.h"
|
||||
#include "format/KeePass2.h"
|
||||
#include "format/KeePass2Reader.h"
|
||||
#include "format/KeePass2Writer.h"
|
||||
#include "format/KdbxXmlReader.h"
|
||||
#include "format/KdbxXmlWriter.h"
|
||||
#include "config-keepassx-tests.h"
|
||||
|
||||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
#include "mock/MockChallengeResponseKey.h"
|
||||
|
||||
QTEST_GUILESS_MAIN(TestKdbx4)
|
||||
|
||||
@@ -66,8 +65,11 @@ void TestKdbx4::writeXml(QBuffer* buf, Database* db, bool& hasError, QString& er
|
||||
errorString = writer.errorString();
|
||||
}
|
||||
|
||||
void TestKdbx4::readKdbx(QIODevice* device, CompositeKey const& key, QScopedPointer<Database>& db,
|
||||
bool& hasError, QString& errorString)
|
||||
void TestKdbx4::readKdbx(QIODevice* device,
|
||||
CompositeKey const& key,
|
||||
QScopedPointer<Database>& db,
|
||||
bool& hasError,
|
||||
QString& errorString)
|
||||
{
|
||||
KeePass2Reader reader;
|
||||
db.reset(reader.readDatabase(device, key));
|
||||
@@ -78,8 +80,11 @@ void TestKdbx4::readKdbx(QIODevice* device, CompositeKey const& key, QScopedPoin
|
||||
QCOMPARE(reader.version(), KeePass2::FILE_VERSION_4);
|
||||
}
|
||||
|
||||
void TestKdbx4::readKdbx(const QString& path, CompositeKey const& key, QScopedPointer<Database>& db,
|
||||
bool& hasError, QString& errorString)
|
||||
void TestKdbx4::readKdbx(const QString& path,
|
||||
CompositeKey const& key,
|
||||
QScopedPointer<Database>& db,
|
||||
bool& hasError,
|
||||
QString& errorString)
|
||||
{
|
||||
KeePass2Reader reader;
|
||||
db.reset(reader.readDatabase(path, key));
|
||||
@@ -139,7 +144,7 @@ void TestKdbx4::testFormat400Upgrade()
|
||||
QScopedPointer<Database> sourceDb(new Database());
|
||||
sourceDb->changeKdf(fastKdf(sourceDb->kdf()));
|
||||
sourceDb->metadata()->setName("Wubba lubba dub dub");
|
||||
QCOMPARE(sourceDb->kdf()->uuid(), KeePass2::KDF_AES_KDBX3); // default is legacy AES-KDF
|
||||
QCOMPARE(sourceDb->kdf()->uuid(), KeePass2::KDF_AES_KDBX3); // default is legacy AES-KDF
|
||||
|
||||
CompositeKey key;
|
||||
key.addKey(PasswordKey("I am in great pain, please help me!"));
|
||||
@@ -156,7 +161,8 @@ void TestKdbx4::testFormat400Upgrade()
|
||||
sourceDb->metadata()->customData()->set("CustomPublicData", "Hey look, I turned myself into a pickle!");
|
||||
if (addCustomData) {
|
||||
// this, however, should
|
||||
sourceDb->rootGroup()->customData()->set("CustomGroupData", "I just killed my family! I don't care who they were!");
|
||||
sourceDb->rootGroup()->customData()->set("CustomGroupData",
|
||||
"I just killed my family! I don't care who they were!");
|
||||
}
|
||||
|
||||
KeePass2Writer writer;
|
||||
@@ -305,16 +311,18 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity_data()
|
||||
QTest::addColumn<QString>("upgradeAction");
|
||||
QTest::addColumn<quint32>("expectedVersion");
|
||||
|
||||
QTest::newRow("Upgrade: none") << QString("none") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade: none (meta-customdata)") << QString("meta-customdata") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade: none (explicit kdf-aes-kdbx3)") << QString("kdf-aes-kdbx3") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade (explicit): kdf-argon2") << QString("kdf-argon2") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (explicit): kdf-aes-kdbx4") << QString("kdf-aes-kdbx4") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): public-customdata") << QString("public-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): rootgroup-customdata") << QString("rootgroup-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): group-customdata") << QString("group-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): rootentry-customdata") << QString("rootentry-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): entry-customdata") << QString("entry-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade: none") << QString("none") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade: none (meta-customdata)") << QString("meta-customdata") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade: none (explicit kdf-aes-kdbx3)") << QString("kdf-aes-kdbx3") << KeePass2::FILE_VERSION_3;
|
||||
QTest::newRow("Upgrade (explicit): kdf-argon2") << QString("kdf-argon2") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (explicit): kdf-aes-kdbx4") << QString("kdf-aes-kdbx4") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): public-customdata") << QString("public-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): rootgroup-customdata") << QString("rootgroup-customdata")
|
||||
<< KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): group-customdata") << QString("group-customdata") << KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): rootentry-customdata") << QString("rootentry-customdata")
|
||||
<< KeePass2::FILE_VERSION_4;
|
||||
QTest::newRow("Upgrade (implicit): entry-customdata") << QString("entry-customdata") << KeePass2::FILE_VERSION_4;
|
||||
}
|
||||
|
||||
void TestKdbx4::testCustomData()
|
||||
@@ -335,8 +343,8 @@ void TestKdbx4::testCustomData()
|
||||
const QString customDataKey2 = "CD2";
|
||||
const QString customData1 = "abcäöü";
|
||||
const QString customData2 = "Hello World";
|
||||
const int dataSize = customDataKey1.toUtf8().size() + customDataKey1.toUtf8().size() +
|
||||
customData1.toUtf8().size() + customData2.toUtf8().size();
|
||||
const int dataSize = customDataKey1.toUtf8().size() + customDataKey1.toUtf8().size() + customData1.toUtf8().size()
|
||||
+ customData2.toUtf8().size();
|
||||
|
||||
// test custom database data
|
||||
db.metadata()->customData()->set(customDataKey1, customData1);
|
||||
@@ -413,10 +421,7 @@ QSharedPointer<Kdf> TestKdbx4::fastKdf(QSharedPointer<Kdf> kdf)
|
||||
kdf->setRounds(1);
|
||||
|
||||
if (kdf->uuid() == KeePass2::KDF_ARGON2) {
|
||||
kdf->processParameters({
|
||||
{KeePass2::KDFPARAM_ARGON2_MEMORY, 1024},
|
||||
{KeePass2::KDFPARAM_ARGON2_PARALLELISM, 1}
|
||||
});
|
||||
kdf->processParameters({{KeePass2::KDFPARAM_ARGON2_MEMORY, 1024}, {KeePass2::KDFPARAM_ARGON2_PARALLELISM, 1}});
|
||||
}
|
||||
|
||||
return kdf;
|
||||
|
||||
Reference in New Issue
Block a user