Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2018-05-14 00:21:43 +0300
committerJanek Bevendorff <janek@jbev.net>2018-09-25 22:12:47 +0300
commite443cde45280512c39b918d60d98a933b9804751 (patch)
treebca157f0775765a4256578ae6d0c74468327254d /tests/TestKdbx4.cpp
parente4ded388b480bdd3b2f02bee39298053eb400acf (diff)
Add a new database settings wizard
This patch implements a new database wizard to guide users through the process of setting up a new database and choosing sane encryption settings. It also reimplements the master key settings to be more user-friendly. Users can now add, change, or remove individual composite key components instead of having to set all components at once. This avoids confusion about a password being reset if the user only wants to add a key file. With these changes comes a major refactor of how database composite keys and key components are handled. Copying of keys is prohibited and each key exists only once in memory and is referenced via shared pointers. GUI components for changing individual keys are encapsulated into separate classes to be more reusable. The password edit and generator widgets have also been refactored to be more reusable.
Diffstat (limited to 'tests/TestKdbx4.cpp')
-rw-r--r--tests/TestKdbx4.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/TestKdbx4.cpp b/tests/TestKdbx4.cpp
index 9758ac13f..72c2d4c83 100644
--- a/tests/TestKdbx4.cpp
+++ b/tests/TestKdbx4.cpp
@@ -66,7 +66,7 @@ void TestKdbx4::writeXml(QBuffer* buf, Database* db, bool& hasError, QString& er
}
void TestKdbx4::readKdbx(QIODevice* device,
- CompositeKey const& key,
+ QSharedPointer<const CompositeKey> key,
QScopedPointer<Database>& db,
bool& hasError,
QString& errorString)
@@ -81,7 +81,7 @@ void TestKdbx4::readKdbx(QIODevice* device,
}
void TestKdbx4::readKdbx(const QString& path,
- CompositeKey const& key,
+ QSharedPointer<const CompositeKey> key,
QScopedPointer<Database>& db,
bool& hasError,
QString& errorString)
@@ -113,8 +113,8 @@ Q_DECLARE_METATYPE(QUuid)
void TestKdbx4::testFormat400()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format400.kdbx");
- CompositeKey key;
- key.addKey(PasswordKey("t"));
+ auto key = QSharedPointer<CompositeKey>::create();
+ key->addKey(QSharedPointer<PasswordKey>::create("t"));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QCOMPARE(reader.version(), KeePass2::FILE_VERSION_4);
@@ -146,8 +146,8 @@ void TestKdbx4::testFormat400Upgrade()
sourceDb->metadata()->setName("Wubba lubba dub dub");
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!"));
+ auto key = QSharedPointer<CompositeKey>::create();
+ key->addKey(QSharedPointer<PasswordKey>::create("I am in great pain, please help me!"));
sourceDb->setKey(key, true, true);
QBuffer buffer;
@@ -228,20 +228,20 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity()
QFETCH(quint32, expectedVersion);
// prepare composite key
- PasswordKey passwordKey("turXpGMQiUE6CkPvWacydAKsnp4cxz");
+ auto passwordKey = QSharedPointer<PasswordKey>::create("turXpGMQiUE6CkPvWacydAKsnp4cxz");
QByteArray fileKeyBytes("Ma6hHov98FbPeyAL22XhcgmpJk8xjQ");
QBuffer fileKeyBuffer(&fileKeyBytes);
fileKeyBuffer.open(QBuffer::ReadOnly);
- FileKey fileKey;
- fileKey.load(&fileKeyBuffer);
+ auto fileKey = QSharedPointer<FileKey>::create();
+ fileKey->load(&fileKeyBuffer);
auto crKey = QSharedPointer<MockChallengeResponseKey>::create(QByteArray("azdJnbVCFE76vV6t9RJ2DS6xvSS93k"));
- CompositeKey compositeKey;
- compositeKey.addKey(passwordKey);
- compositeKey.addKey(fileKey);
- compositeKey.addChallengeResponseKey(crKey);
+ auto compositeKey = QSharedPointer<CompositeKey>::create();
+ compositeKey->addKey(passwordKey);
+ compositeKey->addKey(fileKey);
+ compositeKey->addChallengeResponseKey(crKey);
QScopedPointer<Database> db(new Database());
db->changeKdf(fastKdf(db->kdf()));
@@ -293,7 +293,7 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity()
buffer.seek(0);
KeePass2Reader reader;
QScopedPointer<Database> db2;
- db2.reset(reader.readDatabase(&buffer, CompositeKey()));
+ db2.reset(reader.readDatabase(&buffer, QSharedPointer<CompositeKey>::create()));
QVERIFY(reader.hasError());
// check that we can read back the database with the original composite key,
@@ -396,7 +396,7 @@ void TestKdbx4::testCustomData()
// read buffer back
buffer.seek(0);
KeePass2Reader reader;
- QSharedPointer<Database> newDb(reader.readDatabase(&buffer, CompositeKey()));
+ QSharedPointer<Database> newDb(reader.readDatabase(&buffer, QSharedPointer<CompositeKey>::create()));
// test all custom data are read back successfully from KDBX
QCOMPARE(newDb->publicCustomData(), publicCustomData);