mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
FdoSecrets: ask to unlock the database when creating items
Also only emit databaseUnlockFinished after the database is unlocked Fix #7989
This commit is contained in:
@@ -1094,6 +1094,31 @@ void TestGuiFdoSecrets::testItemCreate()
|
||||
}
|
||||
}
|
||||
|
||||
void TestGuiFdoSecrets::testItemCreateUnlock()
|
||||
{
|
||||
auto service = enableService();
|
||||
VERIFY(service);
|
||||
auto coll = getDefaultCollection(service);
|
||||
VERIFY(coll);
|
||||
auto sess = openSession(service, DhIetf1024Sha256Aes128CbcPkcs7::Algorithm);
|
||||
VERIFY(sess);
|
||||
|
||||
// NOTE: entries are no longer valid after locking
|
||||
lockDatabaseInBackend();
|
||||
|
||||
QSignalSpy spyItemCreated(coll.data(), SIGNAL(ItemCreated(QDBusObjectPath)));
|
||||
VERIFY(spyItemCreated.isValid());
|
||||
|
||||
// create item
|
||||
StringStringMap attributes{
|
||||
{"application", "fdosecrets-test"},
|
||||
{"attr-i[bute]", "![some] -value*"},
|
||||
};
|
||||
|
||||
auto item = createItem(sess, coll, "abc", "Password", attributes, false, false, true);
|
||||
VERIFY(item);
|
||||
}
|
||||
|
||||
void TestGuiFdoSecrets::testItemChange()
|
||||
{
|
||||
auto service = enableService();
|
||||
@@ -1678,7 +1703,8 @@ QSharedPointer<ItemProxy> TestGuiFdoSecrets::createItem(const QSharedPointer<Ses
|
||||
const QString& pass,
|
||||
const StringStringMap& attr,
|
||||
bool replace,
|
||||
bool expectPrompt)
|
||||
bool expectPrompt,
|
||||
bool expectUnlockPrompt)
|
||||
{
|
||||
VERIFY(sess);
|
||||
VERIFY(coll);
|
||||
@@ -1703,6 +1729,10 @@ QSharedPointer<ItemProxy> TestGuiFdoSecrets::createItem(const QSharedPointer<Ses
|
||||
|
||||
// drive the prompt
|
||||
DBUS_VERIFY(prompt->Prompt(""));
|
||||
|
||||
bool unlockFound = driveUnlockDialog();
|
||||
COMPARE(unlockFound, expectUnlockPrompt);
|
||||
|
||||
bool found = driveAccessControlDialog();
|
||||
COMPARE(found, expectPrompt);
|
||||
|
||||
@@ -1800,6 +1830,9 @@ bool TestGuiFdoSecrets::driveUnlockDialog()
|
||||
processEvents();
|
||||
auto dbOpenDlg = m_tabWidget->findChild<DatabaseOpenDialog*>();
|
||||
VERIFY(dbOpenDlg);
|
||||
if (!dbOpenDlg->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
auto editPassword = dbOpenDlg->findChild<PasswordWidget*>("editPassword")->findChild<QLineEdit*>("passwordEdit");
|
||||
VERIFY(editPassword);
|
||||
editPassword->setFocus();
|
||||
|
||||
@@ -84,6 +84,7 @@ private slots:
|
||||
void testCollectionChange();
|
||||
|
||||
void testItemCreate();
|
||||
void testItemCreateUnlock();
|
||||
void testItemChange();
|
||||
void testItemReplace();
|
||||
void testItemReplaceExistingLocked();
|
||||
@@ -122,7 +123,8 @@ private:
|
||||
const QString& pass,
|
||||
const FdoSecrets::wire::StringStringMap& attr,
|
||||
bool replace,
|
||||
bool expectPrompt = false);
|
||||
bool expectPrompt = false,
|
||||
bool expectUnlockPrompt = false);
|
||||
FdoSecrets::wire::Secret
|
||||
encryptPassword(QByteArray value, QString contentType, const QSharedPointer<SessionProxy>& sess);
|
||||
template <typename Proxy> QSharedPointer<Proxy> getProxy(const QDBusObjectPath& path) const
|
||||
|
||||
Reference in New Issue
Block a user