diff options
author | Aetf <aetf@unlimited-code.works> | 2022-02-27 01:22:20 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2022-03-21 15:42:17 +0300 |
commit | 7d3c3b09fb158adbbc9078a374705bff448f944f (patch) | |
tree | 6520a21da0622d32f686f6683ba820167338ff13 /tests | |
parent | 1e73d549edc15a329f0c124ef6c5fe24421246bd (diff) |
FdoSecrest: allow remember decision for future entries
Also added a reset decision button in session management tab
Fixes #7464
* Fix distorted button in settings page: the default margin in QToolBar is too large for our use case in a table row.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gui/TestGuiFdoSecrets.cpp | 66 | ||||
-rw-r--r-- | tests/gui/TestGuiFdoSecrets.h | 3 |
2 files changed, 66 insertions, 3 deletions
diff --git a/tests/gui/TestGuiFdoSecrets.cpp b/tests/gui/TestGuiFdoSecrets.cpp index 5e2a52e2e..a2b5647df 100644 --- a/tests/gui/TestGuiFdoSecrets.cpp +++ b/tests/gui/TestGuiFdoSecrets.cpp @@ -608,6 +608,62 @@ void TestGuiFdoSecrets::testServiceUnlockItems() DBUS_COMPARE(item->locked(), false); } +void TestGuiFdoSecrets::testServiceUnlockItemsIncludeFutureEntries() +{ + FdoSecrets::settings()->setConfirmAccessItem(true); + + auto service = enableService(); + VERIFY(service); + auto coll = getDefaultCollection(service); + VERIFY(coll); + auto item = getFirstItem(coll); + VERIFY(item); + auto sess = openSession(service, DhIetf1024Sha256Aes128CbcPkcs7::Algorithm); + VERIFY(sess); + + DBUS_COMPARE(item->locked(), true); + + { + DBUS_GET2(unlocked, promptPath, service->Unlock({QDBusObjectPath(item->path())})); + // nothing is unlocked immediately without user's action + COMPARE(unlocked, {}); + + auto prompt = getProxy<PromptProxy>(promptPath); + VERIFY(prompt); + QSignalSpy spyPromptCompleted(prompt.data(), SIGNAL(Completed(bool, QDBusVariant))); + VERIFY(spyPromptCompleted.isValid()); + + // nothing is unlocked yet + COMPARE(spyPromptCompleted.count(), 0); + DBUS_COMPARE(item->locked(), true); + + // drive the prompt + DBUS_VERIFY(prompt->Prompt("")); + // remember and include future entries + VERIFY(driveAccessControlDialog(true, true)); + + VERIFY(waitForSignal(spyPromptCompleted, 1)); + { + auto args = spyPromptCompleted.takeFirst(); + COMPARE(args.size(), 2); + COMPARE(args.at(0).toBool(), false); + COMPARE(getSignalVariantArgument<QList<QDBusObjectPath>>(args.at(1)), {QDBusObjectPath(item->path())}); + } + + // unlocked + DBUS_COMPARE(item->locked(), false); + } + + // check other entries are also unlocked + { + DBUS_GET(itemPaths, coll->items()); + VERIFY(itemPaths.size() > 1); + auto anotherItem = getProxy<ItemProxy>(itemPaths.last()); + VERIFY(anotherItem); + DBUS_COMPARE(anotherItem->locked(), false); + } +} + void TestGuiFdoSecrets::testServiceLock() { auto service = enableService(); @@ -1635,7 +1691,7 @@ TestGuiFdoSecrets::encryptPassword(QByteArray value, QString contentType, const return m_clientCipher->encrypt(ss.unmarshal(m_plugin->dbus())).marshal(); } -bool TestGuiFdoSecrets::driveAccessControlDialog(bool remember) +bool TestGuiFdoSecrets::driveAccessControlDialog(bool remember, bool includeFutureEntries) { processEvents(); for (auto w : QApplication::topLevelWidgets()) { @@ -1647,7 +1703,13 @@ bool TestGuiFdoSecrets::driveAccessControlDialog(bool remember) auto rememberCheck = dlg->findChild<QCheckBox*>("rememberCheck"); VERIFY(rememberCheck); rememberCheck->setChecked(remember); - dlg->done(AccessControlDialog::AllowSelected); + + if (includeFutureEntries) { + dlg->done(AccessControlDialog::AllowAll); + } else { + dlg->done(AccessControlDialog::AllowSelected); + } + processEvents(); VERIFY(dlg->isHidden()); return true; diff --git a/tests/gui/TestGuiFdoSecrets.h b/tests/gui/TestGuiFdoSecrets.h index 285619f86..03f84adce 100644 --- a/tests/gui/TestGuiFdoSecrets.h +++ b/tests/gui/TestGuiFdoSecrets.h @@ -71,6 +71,7 @@ private slots: void testServiceUnlock(); void testServiceUnlockDatabaseConcurrent(); void testServiceUnlockItems(); + void testServiceUnlockItemsIncludeFutureEntries(); void testServiceLock(); void testServiceLockConcurrent(); @@ -103,7 +104,7 @@ private slots: private: bool driveUnlockDialog(); bool driveNewDatabaseWizard(); - bool driveAccessControlDialog(bool remember = true); + bool driveAccessControlDialog(bool remember = true, bool includeFutureEntries = false); bool waitForSignal(QSignalSpy& spy, int expectedCount); void processEvents(); |