mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-06 05:24:13 -04:00
Complete refactor of Browser Integration classes
* Removed option to attach KeePassXC to the browser extension. Users must use the proxy application to communicate with KeePassXC. * Significantly streamlined proxy code. Used same implementation of stdin/stdout interface across all platforms. * Moved browser service entry point to BrowserService class instead of NativeMessagingHost. BrowserService now coordinates the communication to/from clients. * Moved settings page definition out of MainWindow * Decoupled BrowserService from DatabaseTabWidget * Reduced complexity of various functions and cleaned the ABI (public vs private). * Eliminated BrowserClients class, moved functionality into the BrowserService * Renamed HostInstaller to NativeMessageInstaller and renamed NativeMessageHost to BrowserHost. * Recognize XDG_CONFIG_HOME when installing native message file on Linux. Fix #4121 and fix #4123.
This commit is contained in:
parent
3b4057a78c
commit
a145bf9119
43 changed files with 1221 additions and 1919 deletions
|
@ -16,11 +16,13 @@
|
|||
*/
|
||||
|
||||
#include "TestBrowser.h"
|
||||
|
||||
#include "TestGlobal.h"
|
||||
#include "browser/BrowserSettings.h"
|
||||
#include "core/Tools.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "sodium/crypto_box.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
QTEST_GUILESS_MAIN(TestBrowser)
|
||||
|
@ -35,12 +37,12 @@ const QString CLIENTID = "testClient";
|
|||
void TestBrowser::initTestCase()
|
||||
{
|
||||
QVERIFY(Crypto::init());
|
||||
m_browserService.reset(new BrowserService(nullptr));
|
||||
m_browserAction.reset(new BrowserAction(*m_browserService.data()));
|
||||
m_browserService = browserService();
|
||||
}
|
||||
|
||||
void TestBrowser::cleanupTestCase()
|
||||
void TestBrowser::init()
|
||||
{
|
||||
m_browserAction.reset(new BrowserAction());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +56,7 @@ void TestBrowser::testChangePublicKeys()
|
|||
json["publicKey"] = PUBLICKEY;
|
||||
json["nonce"] = NONCE;
|
||||
|
||||
auto response = m_browserAction->handleAction(json);
|
||||
auto response = m_browserAction->processClientMessage(json);
|
||||
QCOMPARE(response["action"].toString(), QString("change-public-keys"));
|
||||
QCOMPARE(response["publicKey"].toString() == PUBLICKEY, false);
|
||||
QCOMPARE(response["success"].toString(), TRUE_STR);
|
||||
|
@ -393,62 +395,6 @@ void TestBrowser::testSortEntries()
|
|||
QCOMPARE(result[3]->url(), QString("github.com/login"));
|
||||
}
|
||||
|
||||
void TestBrowser::testGetDatabaseGroups()
|
||||
{
|
||||
auto db = QSharedPointer<Database>::create();
|
||||
auto* root = db->rootGroup();
|
||||
|
||||
QScopedPointer<Group> group1(new Group());
|
||||
group1->setParent(root);
|
||||
group1->setName("group1");
|
||||
|
||||
QScopedPointer<Group> group2(new Group());
|
||||
group2->setParent(root);
|
||||
group2->setName("group2");
|
||||
|
||||
QScopedPointer<Group> group3(new Group());
|
||||
group3->setParent(root);
|
||||
group3->setName("group3");
|
||||
|
||||
QScopedPointer<Group> group2_1(new Group());
|
||||
group2_1->setParent(group2.data());
|
||||
group2_1->setName("group2_1");
|
||||
|
||||
QScopedPointer<Group> group2_2(new Group());
|
||||
group2_2->setParent(group2.data());
|
||||
group2_2->setName("group2_2");
|
||||
|
||||
QScopedPointer<Group> group2_1_1(new Group());
|
||||
group2_1_1->setParent(group2_1.data());
|
||||
group2_1_1->setName("group2_1_1");
|
||||
|
||||
auto result = m_browserService->getDatabaseGroups(db);
|
||||
QCOMPARE(result.length(), 1);
|
||||
|
||||
auto groups = result["groups"].toArray();
|
||||
auto first = groups.at(0);
|
||||
auto children = first.toObject()["children"].toArray();
|
||||
QCOMPARE(first.toObject()["name"].toString(), QString("Root"));
|
||||
QCOMPARE(children.size(), 3);
|
||||
|
||||
auto firstChild = children.at(0);
|
||||
auto secondChild = children.at(1);
|
||||
auto thirdChild = children.at(2);
|
||||
QCOMPARE(firstChild.toObject()["name"].toString(), QString("group1"));
|
||||
QCOMPARE(secondChild.toObject()["name"].toString(), QString("group2"));
|
||||
QCOMPARE(thirdChild.toObject()["name"].toString(), QString("group3"));
|
||||
|
||||
auto childrenOfSecond = secondChild.toObject()["children"].toArray();
|
||||
auto firstOfCOS = childrenOfSecond.at(0);
|
||||
auto secondOfCOS = childrenOfSecond.at(1);
|
||||
QCOMPARE(firstOfCOS.toObject()["name"].toString(), QString("group2_1"));
|
||||
QCOMPARE(secondOfCOS.toObject()["name"].toString(), QString("group2_2"));
|
||||
|
||||
auto lastChildren = firstOfCOS.toObject()["children"].toArray();
|
||||
auto lastChild = lastChildren.at(0);
|
||||
QCOMPARE(lastChild.toObject()["name"].toString(), QString("group2_1_1"));
|
||||
}
|
||||
|
||||
QList<Entry*> TestBrowser::createEntries(QStringList& urls, Group* root) const
|
||||
{
|
||||
QList<Entry*> entries;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue