diff --git a/tests/TestAutoType.cpp b/tests/TestAutoType.cpp index 25790e3b1..5eaed66a1 100644 --- a/tests/TestAutoType.cpp +++ b/tests/TestAutoType.cpp @@ -35,8 +35,9 @@ void TestAutoType::initTestCase() { QVERIFY(Crypto::init()); Config::createTempFileInstance(); - AutoType::createTestInstance(); + config()->set("AutoTypeDelay", 1); config()->set("security/autotypeask", false); + AutoType::createTestInstance(); QPluginLoader loader(filePath()->pluginPath("keepassx-autotype-test")); loader.setLoadHints(QLibrary::ResolveAllSymbolsHint); diff --git a/tests/TestKdbx4.cpp b/tests/TestKdbx4.cpp index 4bbff1fec..f0ef1bfa8 100644 --- a/tests/TestKdbx4.cpp +++ b/tests/TestKdbx4.cpp @@ -34,8 +34,8 @@ QTEST_GUILESS_MAIN(TestKdbx4) void TestKdbx4::initTestCaseImpl() { - m_xmlDb->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2)); - m_kdbxSourceDb->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2)); + m_xmlDb->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2))); + m_kdbxSourceDb->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2))); } Database* TestKdbx4::readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) @@ -93,7 +93,7 @@ void TestKdbx4::readKdbx(const QString& path, CompositeKey const& key, QScopedPo void TestKdbx4::writeKdbx(QIODevice* device, Database* db, bool& hasError, QString& errorString) { if (db->kdf()->uuid() == KeePass2::KDF_AES_KDBX3) { - db->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2)); + db->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2))); } KeePass2Writer writer; hasError = writer.writeDatabase(device, db); @@ -137,6 +137,7 @@ void TestKdbx4::testFormat400Upgrade() QFETCH(quint32, expectedVersion); QScopedPointer 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 @@ -148,7 +149,7 @@ void TestKdbx4::testFormat400Upgrade() buffer.open(QBuffer::ReadWrite); // upgrade to KDBX 4 by changing KDF and Cipher - sourceDb->changeKdf(KeePass2::uuidToKdf(kdfUuid)); + sourceDb->changeKdf(fastKdf(KeePass2::uuidToKdf(kdfUuid))); sourceDb->setCipher(cipherUuid); // CustomData in meta should not cause any version change @@ -235,6 +236,7 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity() compositeKey.addChallengeResponseKey(crKey); QScopedPointer db(new Database()); + db->changeKdf(fastKdf(db->kdf())); db->setKey(compositeKey); // upgrade the database by a specific method @@ -243,11 +245,11 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity() } else if (upgradeAction == "meta-customdata") { db->metadata()->customData()->set("abc", "def"); } else if (upgradeAction == "kdf-aes-kdbx3") { - db->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_AES_KDBX3)); + db->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_AES_KDBX3))); } else if (upgradeAction == "kdf-argon2") { - db->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2)); + db->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_ARGON2))); } else if (upgradeAction == "kdf-aes-kdbx4") { - db->changeKdf(KeePass2::uuidToKdf(KeePass2::KDF_AES_KDBX4)); + db->changeKdf(fastKdf(KeePass2::uuidToKdf(KeePass2::KDF_AES_KDBX4))); } else if (upgradeAction == "public-customdata") { db->publicCustomData().insert("abc", "def"); } else if (upgradeAction == "rootgroup-customdata") { @@ -403,3 +405,17 @@ void TestKdbx4::testCustomData() QCOMPARE(newEntry->customData()->value(customDataKey1), customData1); QCOMPARE(newEntry->customData()->value(customDataKey2), customData2); } + +QSharedPointer TestKdbx4::fastKdf(QSharedPointer kdf) +{ + kdf->setRounds(1); + + if (kdf->uuid() == KeePass2::KDF_ARGON2) { + kdf->processParameters({ + {KeePass2::KDFPARAM_ARGON2_MEMORY, 1024}, + {KeePass2::KDFPARAM_ARGON2_PARALLELISM, 1} + }); + } + + return kdf; +} diff --git a/tests/TestKdbx4.h b/tests/TestKdbx4.h index efb3449f3..e278ebb02 100644 --- a/tests/TestKdbx4.h +++ b/tests/TestKdbx4.h @@ -44,6 +44,8 @@ protected: void readKdbx(QIODevice* device, CompositeKey const& key, QScopedPointer& db, bool& hasError, QString& errorString) override; void writeKdbx(QIODevice* device, Database* db, bool& hasError, QString& errorString) override; + + QSharedPointer fastKdf(QSharedPointer kdf); }; #endif // KEEPASSXC_TEST_KDBX4_H