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
path: root/tests/gui
diff options
context:
space:
mode:
authorAetf <aetf@unlimited-code.works>2022-05-07 08:50:25 +0300
committerJonathan White <support@dmapps.us>2022-06-04 22:49:34 +0300
commite2bf537c4acaa689f60a76ab09c01d2a62ce2d43 (patch)
tree7162f45298e2c8257ac159a419f6193439d63748 /tests/gui
parentc5467c43bf0c59684d00e03d5335e85c7a50a156 (diff)
FdoSecrets: ask to unlock the database when creating items
Also only emit databaseUnlockFinished after the database is unlocked Fix #7989
Diffstat (limited to 'tests/gui')
-rw-r--r--tests/gui/TestGuiFdoSecrets.cpp35
-rw-r--r--tests/gui/TestGuiFdoSecrets.h4
2 files changed, 37 insertions, 2 deletions
diff --git a/tests/gui/TestGuiFdoSecrets.cpp b/tests/gui/TestGuiFdoSecrets.cpp
index ec9a16b5c..656ea135f 100644
--- a/tests/gui/TestGuiFdoSecrets.cpp
+++ b/tests/gui/TestGuiFdoSecrets.cpp
@@ -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();
diff --git a/tests/gui/TestGuiFdoSecrets.h b/tests/gui/TestGuiFdoSecrets.h
index ab0909b30..9a43b78a3 100644
--- a/tests/gui/TestGuiFdoSecrets.h
+++ b/tests/gui/TestGuiFdoSecrets.h
@@ -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