diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/qxmppatmmanager/tst_qxmppatmmanager.cpp | 16 | ||||
| -rw-r--r-- | tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp | 550 |
2 files changed, 498 insertions, 68 deletions
diff --git a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp index c5899e0a..4ff4e079 100644 --- a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp +++ b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp @@ -3,12 +3,14 @@ // SPDX-License-Identifier: LGPL-2.1-or-later #include "QXmppAtmManager.h" +#include "QXmppAtmTrustMemoryStorage.h" #include "QXmppCarbonManager.h" #include "QXmppClient.h" #include "QXmppConstants.cpp" #include "QXmppConstants_p.h" -#include "QXmppTrustMemoryStorage.h" +#include "QXmppMessage.h" #include "QXmppTrustMessageElement.h" +#include "QXmppTrustMessageKeyOwner.h" #include "QXmppUtils.h" #include "util.h" @@ -57,13 +59,13 @@ private: QXmppClient m_client; QXmppLogger m_logger; QXmppAtmManager *m_manager; - QXmppTrustMemoryStorage *m_trustStorage; + QXmppAtmTrustMemoryStorage *m_trustStorage; QXmppCarbonManager *m_carbonManager; }; void tst_QXmppAtmManager::initTestCase() { - m_trustStorage = new QXmppTrustMemoryStorage; + m_trustStorage = new QXmppAtmTrustMemoryStorage; m_manager = new QXmppAtmManager(m_trustStorage); m_client.addExtension(m_manager); m_client.configuration().setJid("alice@example.org/phone"); @@ -446,7 +448,7 @@ void tst_QXmppAtmManager::testAuthenticate() clearTrustStorage(); QFETCH(QXmppTrustStorage::SecurityPolicy, securityPolicy); - m_trustStorage->setSecurityPolicies(ns_omemo, securityPolicy); + m_trustStorage->setSecurityPolicy(ns_omemo, securityPolicy); QMultiHash<QString, QByteArray> authenticatedKeys = { { QStringLiteral("alice@example.org"), QByteArray::fromBase64(QByteArrayLiteral("rQIL2albuSR1i06EZAp1uZ838zUeEgGIq2whwu3s+Zg=")) }, @@ -859,7 +861,7 @@ void tst_QXmppAtmManager::testHandleMessage() // Remove the sender key as soon as the method being tested is executed. if (areTrustDecisionsValid) { - m_trustStorage->removeKeys(ns_omemo, { senderKey }); + m_trustStorage->removeKeys(ns_omemo, QList { senderKey }); } if (areTrustDecisionsValid) { @@ -2070,8 +2072,8 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysDone() void tst_QXmppAtmManager::clearTrustStorage() { - m_trustStorage->removeKeys(); - m_trustStorage->removeKeysForPostponedTrustDecisions(); + m_trustStorage->removeKeys(ns_omemo); + m_trustStorage->removeKeysForPostponedTrustDecisions(ns_omemo); } QTEST_MAIN(tst_QXmppAtmManager) diff --git a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp index d7827b7f..ff7537dc 100644 --- a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp +++ b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: LGPL-2.1-or-later +#include "QXmppAtmTrustMemoryStorage.h" #include "QXmppConstants.cpp" #include "QXmppConstants_p.h" #include "QXmppTrustMemoryStorage.h" @@ -14,44 +15,42 @@ class tst_QXmppTrustMemoryStorage : public QObject Q_OBJECT private slots: - void testSecurityPolicies(); + // QXmppTrustMemoryStorage + void testSecurityPolicy(); void testOwnKeys(); void testKeys(); void testTrustLevels(); - void testKeysForPostponedTrustDecisions(); + void testResetAll(); + + // QXmppAtmTrustMemoryStorage + void atmTestKeysForPostponedTrustDecisions(); + void atmTestResetAll(); private: QXmppTrustMemoryStorage m_trustStorage; + QXmppAtmTrustMemoryStorage m_atmTrustStorage; }; -void tst_QXmppTrustMemoryStorage::testSecurityPolicies() +void tst_QXmppTrustMemoryStorage::testSecurityPolicy() { auto future = m_trustStorage.securityPolicy(ns_ox); QVERIFY(future.isFinished()); auto result = future.result(); QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy); - m_trustStorage.setSecurityPolicies(ns_ox, QXmppTrustStorage::Toakafa); - m_trustStorage.setSecurityPolicies(ns_omemo, QXmppTrustStorage::Toakafa); + m_trustStorage.setSecurityPolicy(ns_omemo, QXmppTrustStorage::Toakafa); future = m_trustStorage.securityPolicy(ns_ox); QVERIFY(future.isFinished()); result = future.result(); - QCOMPARE(result, QXmppTrustStorage::Toakafa); + QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy); future = m_trustStorage.securityPolicy(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE(result, QXmppTrustStorage::Toakafa); - m_trustStorage.setSecurityPolicies(ns_ox); - - future = m_trustStorage.securityPolicy(ns_ox); - QVERIFY(future.isFinished()); - result = future.result(); - QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy); - - m_trustStorage.setSecurityPolicies(); + m_trustStorage.resetSecurityPolicy(ns_omemo); future = m_trustStorage.securityPolicy(ns_omemo); QVERIFY(future.isFinished()); @@ -61,13 +60,18 @@ void tst_QXmppTrustMemoryStorage::testSecurityPolicies() void tst_QXmppTrustMemoryStorage::testOwnKeys() { - m_trustStorage.addOwnKey(ns_ox, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); - m_trustStorage.addOwnKey(ns_omemo, QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA="))); - - // own OX key auto future = m_trustStorage.ownKey(ns_ox); QVERIFY(future.isFinished()); auto result = future.result(); + QVERIFY(result.isEmpty()); + + m_trustStorage.setOwnKey(ns_ox, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); + m_trustStorage.setOwnKey(ns_omemo, QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA="))); + + // own OX key + future = m_trustStorage.ownKey(ns_ox); + QVERIFY(future.isFinished()); + result = future.result(); QCOMPARE(result, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); // own OMEMO key @@ -76,9 +80,15 @@ void tst_QXmppTrustMemoryStorage::testOwnKeys() result = future.result(); QCOMPARE(result, QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA="))); - m_trustStorage.removeOwnKey(ns_omemo); + m_trustStorage.resetOwnKey(ns_omemo); + + // own OX key + future = m_trustStorage.ownKey(ns_ox); + QVERIFY(future.isFinished()); + result = future.result(); + QCOMPARE(result, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); - // no stored own OMEMO key + // no own OMEMO key future = m_trustStorage.ownKey(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); @@ -87,6 +97,33 @@ void tst_QXmppTrustMemoryStorage::testOwnKeys() void tst_QXmppTrustMemoryStorage::testKeys() { + // no OMEMO keys + auto future = m_trustStorage.keys(ns_omemo); + QVERIFY(future.isFinished()); + auto result = future.result(); + QVERIFY(result.isEmpty()); + + // no OMEMO keys (via JIDs) + auto futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }); + QVERIFY(futureForJids.isFinished()); + auto resultForJids = futureForJids.result(); + + // no automatically trusted and authenticated OMEMO keys + future = m_trustStorage.keys(ns_omemo, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(future.isFinished()); + result = future.result(); + QVERIFY(result.isEmpty()); + + // no automatically trusted and authenticated OMEMO key from Alice + auto futureBool = m_trustStorage.hasKey(ns_omemo, + QStringLiteral("alice@example.org"), + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureBool.isFinished()); + auto resultBool = futureBool.result(); + QVERIFY(!resultBool); + // Store keys with the default trust level. m_trustStorage.addKeys( ns_omemo, @@ -149,10 +186,27 @@ void tst_QXmppTrustMemoryStorage::testKeys() QMultiHash<QString, QByteArray> authenticatedKeys = { { QStringLiteral("bob@example.com"), QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")) } }; + QHash<QByteArray, QXmppTrustStorage::TrustLevel> keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("WaAnpWyW1hnFooH3oJo9Ba5XYoksnLPeJRTAjxPbv38=")), + QXmppTrustStorage::AutomaticallyDistrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("/1eK3R2LtjPBT3el8f0q4DvzqUJSfFy5fkKkKPNFNYw=")), + QXmppTrustStorage::AutomaticallyDistrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")), + QXmppTrustStorage::ManuallyDistrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")), + QXmppTrustStorage::AutomaticallyTrusted } }; + QHash<QByteArray, QXmppTrustStorage::TrustLevel> keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")), + QXmppTrustStorage::AutomaticallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")), + QXmppTrustStorage::ManuallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")), + QXmppTrustStorage::ManuallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")), + QXmppTrustStorage::Authenticated } }; + // all OMEMO keys - auto future = m_trustStorage.keys(ns_omemo); + future = m_trustStorage.keys(ns_omemo); QVERIFY(future.isFinished()); - auto result = future.result(); + result = future.result(); QCOMPARE( result, QHash({ std::pair( @@ -172,7 +226,8 @@ void tst_QXmppTrustMemoryStorage::testKeys() authenticatedKeys) })); // automatically trusted and authenticated OMEMO keys - future = m_trustStorage.keys(ns_omemo, QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + future = m_trustStorage.keys(ns_omemo, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -184,6 +239,73 @@ void tst_QXmppTrustMemoryStorage::testKeys() QXmppTrustStorage::Authenticated, authenticatedKeys) })); + // all OMEMO keys (via JIDs) + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice), + std::pair( + QStringLiteral("bob@example.com"), + keysBob) })); + + // Alice's OMEMO keys + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice) })); + + keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")), + QXmppTrustStorage::AutomaticallyTrusted } }; + keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")), + QXmppTrustStorage::AutomaticallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")), + QXmppTrustStorage::Authenticated } }; + + // automatically trusted and authenticated OMEMO keys (via JIDs) + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice), + std::pair( + QStringLiteral("bob@example.com"), + keysBob) })); + + // Alice's automatically trusted and authenticated OMEMO keys + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org") }, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice) })); + + // at least one automatically trusted or authenticated OMEMO key from Alice + futureBool = m_trustStorage.hasKey(ns_omemo, + QStringLiteral("alice@example.org"), + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureBool.isFinished()); + resultBool = futureBool.result(); + QVERIFY(resultBool); + m_trustStorage.removeKeys(ns_omemo, { QByteArray::fromBase64(QByteArrayLiteral("WaAnpWyW1hnFooH3oJo9Ba5XYoksnLPeJRTAjxPbv38=")), QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")) }); @@ -193,7 +315,20 @@ void tst_QXmppTrustMemoryStorage::testKeys() automaticallyTrustedKeys = { { QStringLiteral("bob@example.com"), QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")) } }; - // all OMEMO keys after removal + keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("/1eK3R2LtjPBT3el8f0q4DvzqUJSfFy5fkKkKPNFNYw=")), + QXmppTrustStorage::AutomaticallyDistrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")), + QXmppTrustStorage::ManuallyDistrusted } }; + keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")), + QXmppTrustStorage::AutomaticallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")), + QXmppTrustStorage::ManuallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")), + QXmppTrustStorage::ManuallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")), + QXmppTrustStorage::Authenticated } }; + + // OMEMO keys after removal future = m_trustStorage.keys(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); @@ -215,6 +350,76 @@ void tst_QXmppTrustMemoryStorage::testKeys() QXmppTrustStorage::Authenticated, authenticatedKeys) })); + // OMEMO keys after removal (via JIDs) + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice), + std::pair( + QStringLiteral("bob@example.com"), + keysBob) })); + + // Alice's OMEMO keys after removal + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice) })); + + keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")), + QXmppTrustStorage::AutomaticallyTrusted } }; + keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")), + QXmppTrustStorage::AutomaticallyTrusted }, + { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")), + QXmppTrustStorage::Authenticated } }; + + // automatically trusted and authenticated OMEMO keys after removal (via JIDs) + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("bob@example.com"), + keysBob) })); + + // Alice's automatically trusted and authenticated OMEMO keys after removal + futureForJids = m_trustStorage.keys(ns_omemo, + { QStringLiteral("alice@example.org") }, + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QVERIFY(resultForJids.isEmpty()); + + m_trustStorage.removeKeys(ns_omemo, QStringLiteral("alice@example.org")); + + // OMEMO keys after removing Alice's keys + future = m_trustStorage.keys(ns_omemo); + QVERIFY(future.isFinished()); + result = future.result(); + QCOMPARE( + result, + QHash({ std::pair( + QXmppTrustStorage::AutomaticallyTrusted, + automaticallyTrustedKeys), + std::pair( + QXmppTrustStorage::ManuallyTrusted, + manuallyTrustedKeys), + std::pair( + QXmppTrustStorage::Authenticated, + authenticatedKeys) })); + m_trustStorage.removeKeys(ns_omemo); // no stored OMEMO keys @@ -228,6 +433,11 @@ void tst_QXmppTrustMemoryStorage::testKeys() { QStringLiteral("alice@example.org"), QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) } }; + keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")), + QXmppTrustStorage::Authenticated }, + { QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")), + QXmppTrustStorage::Authenticated } }; + // remaining OX keys future = m_trustStorage.keys(ns_ox); QVERIFY(future.isFinished()); @@ -238,13 +448,50 @@ void tst_QXmppTrustMemoryStorage::testKeys() QXmppTrustStorage::Authenticated, authenticatedKeys) })); - m_trustStorage.removeKeys(); + // remaining OX keys (via JIDs) + futureForJids = m_trustStorage.keys(ns_ox, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice) })); + + // Alice's remaining OX keys + futureForJids = m_trustStorage.keys(ns_ox, + { QStringLiteral("alice@example.org") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QCOMPARE( + resultForJids, + QHash({ std::pair( + QStringLiteral("alice@example.org"), + keysAlice) })); + + m_trustStorage.removeKeys(ns_ox); // no stored OX keys future = m_trustStorage.keys(ns_ox); QVERIFY(future.isFinished()); result = future.result(); QVERIFY(result.isEmpty()); + + // no stored OX keys (via JIDs) + futureForJids = m_trustStorage.keys(ns_ox, + { QStringLiteral("alice@example.org"), QStringLiteral("bob@example.com") }); + QVERIFY(futureForJids.isFinished()); + resultForJids = futureForJids.result(); + QVERIFY(resultForJids.isEmpty()); + + // no automatically trusted or authenticated OX key from Alice + futureBool = m_trustStorage.hasKey(ns_ox, + QStringLiteral("alice@example.org"), + QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated); + QVERIFY(futureBool.isFinished()); + resultBool = futureBool.result(); + QVERIFY(!resultBool); } void tst_QXmppTrustMemoryStorage::testTrustLevels() @@ -325,7 +572,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels() QByteArray::fromBase64(QByteArrayLiteral("WXL4EDfzUGbVPQWjT9pmBeiCpCBzYZv3lUAaj+UbPyE="))); QVERIFY(future.isFinished()); result = future.result(); - QCOMPARE(result, QXmppTrustStorage::AutomaticallyDistrusted); + QCOMPARE(result, QXmppTrustStorage::Undecided); // Set the trust levels of all authenticated keys belonging to Alice and // Bob. @@ -356,13 +603,111 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels() QByteArray::fromBase64(QByteArrayLiteral("wE06Gwf8f4DvDLFDoaCsGs8ibcUjf84WIOA2FAjPI3o="))); QVERIFY(future.isFinished()); result = future.result(); - QCOMPARE(result, QXmppTrustStorage::AutomaticallyDistrusted); + QCOMPARE(result, QXmppTrustStorage::Undecided); - m_trustStorage.removeKeys(); + m_trustStorage.removeKeys(ns_ox); + m_trustStorage.removeKeys(ns_omemo); } -void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() +void tst_QXmppTrustMemoryStorage::testResetAll() { + m_trustStorage.setSecurityPolicy(ns_ox, QXmppTrustStorage::Toakafa); + m_trustStorage.setSecurityPolicy(ns_omemo, QXmppTrustStorage::Toakafa); + + m_trustStorage.setOwnKey(ns_ox, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); + m_trustStorage.setOwnKey(ns_omemo, QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA="))); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("alice@example.org"), + { QByteArray::fromBase64(QByteArrayLiteral("WaAnpWyW1hnFooH3oJo9Ba5XYoksnLPeJRTAjxPbv38=")), + QByteArray::fromBase64(QByteArrayLiteral("/1eK3R2LtjPBT3el8f0q4DvzqUJSfFy5fkKkKPNFNYw=")) }); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("alice@example.org"), + { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")) }, + QXmppTrustStorage::ManuallyDistrusted); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("alice@example.org"), + { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")) }, + QXmppTrustStorage::AutomaticallyTrusted); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("bob@example.com"), + { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")) }, + QXmppTrustStorage::AutomaticallyTrusted); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("bob@example.com"), + { QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")), + QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")) }, + QXmppTrustStorage::ManuallyTrusted); + + m_trustStorage.addKeys( + ns_omemo, + QStringLiteral("bob@example.com"), + { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")) }, + QXmppTrustStorage::Authenticated); + + m_trustStorage.addKeys( + ns_ox, + QStringLiteral("alice@example.org"), + { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")), + QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) }, + QXmppTrustStorage::Authenticated); + + m_trustStorage.resetAll(ns_omemo); + + auto future = m_trustStorage.securityPolicy(ns_omemo); + QVERIFY(future.isFinished()); + auto result = future.result(); + QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy); + + future = m_trustStorage.securityPolicy(ns_ox); + QVERIFY(future.isFinished()); + result = future.result(); + QCOMPARE(result, QXmppTrustStorage::Toakafa); + + auto futureKey = m_trustStorage.ownKey(ns_omemo); + QVERIFY(futureKey.isFinished()); + auto resultKey = futureKey.result(); + QVERIFY(resultKey.isEmpty()); + + futureKey = m_trustStorage.ownKey(ns_ox); + QVERIFY(futureKey.isFinished()); + resultKey = futureKey.result(); + QCOMPARE(resultKey, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ="))); + + auto futureKeys = m_trustStorage.keys(ns_omemo); + QVERIFY(futureKeys.isFinished()); + auto resultKeys = futureKeys.result(); + QVERIFY(resultKeys.isEmpty()); + + const QMultiHash<QString, QByteArray> authenticatedKeys = { { QStringLiteral("alice@example.org"), + QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")) }, + { QStringLiteral("alice@example.org"), + QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) } }; + + futureKeys = m_trustStorage.keys(ns_ox); + QVERIFY(futureKeys.isFinished()); + resultKeys = futureKeys.result(); + QCOMPARE( + resultKeys, + QHash({ std::pair( + QXmppTrustStorage::Authenticated, + authenticatedKeys) })); +} + +void tst_QXmppTrustMemoryStorage::atmTestKeysForPostponedTrustDecisions() +{ + // The key 7y1t0LnmNBeXJka43XejFPLrKtQlSFATrYmy7xHaKYU= + // is set for both postponed authentication and distrusting. + // Thus, it is only stored for postponed distrusting. QXmppTrustMessageKeyOwner keyOwnerAlice; keyOwnerAlice.setJid(QStringLiteral("alice@example.org")); keyOwnerAlice.setTrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("Wl53ZchbtAtCZQCHROiD20W7UnKTQgWQrjTHAVNw1ic=")), @@ -375,21 +720,18 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() keyOwnerBobTrustedKeys.setJid(QStringLiteral("bob@example.com")); keyOwnerBobTrustedKeys.setTrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("GgTqeRLp1M+MEenzFQym2oqer9PfHukS4brJDQl5ARE=")) }); - // The key 7y1t0LnmNBeXJka43XejFPLrKtQlSFATrYmy7xHaKYU= - // is passed for both postponed authentication and distrusting. - // Thus, it is only stored for postponed distrusting. - m_trustStorage.addKeysForPostponedTrustDecisions(ns_omemo, - QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), - { keyOwnerAlice, keyOwnerBobTrustedKeys }); + m_atmTrustStorage.addKeysForPostponedTrustDecisions(ns_omemo, + QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), + { keyOwnerAlice, keyOwnerBobTrustedKeys }); QXmppTrustMessageKeyOwner keyOwnerBobDistrustedKeys; keyOwnerBobDistrustedKeys.setJid(QStringLiteral("bob@example.com")); keyOwnerBobDistrustedKeys.setDistrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("sD6ilugEBeKxPsdDEyX43LSGKHKWd5MFEdhT+4RpsxA=")), QByteArray::fromBase64(QByteArrayLiteral("X5tJ1D5rEeaeQE8eqhBKAj4KUZGYe3x+iHifaTBY1kM=")) }); - m_trustStorage.addKeysForPostponedTrustDecisions(ns_omemo, - QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), - { keyOwnerBobDistrustedKeys }); + m_atmTrustStorage.addKeysForPostponedTrustDecisions(ns_omemo, + QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), + { keyOwnerBobDistrustedKeys }); QXmppTrustMessageKeyOwner keyOwnerCarol; keyOwnerCarol.setJid(QStringLiteral("carol@example.net")); @@ -398,9 +740,9 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() keyOwnerCarol.setDistrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("N0B2StHKk1/slwg1rzybTFzjdg7FChc+3cXmTU/rS8g=")), QByteArray::fromBase64(QByteArrayLiteral("wsEN32UHCiNjYqTG/J63hY4Nu8tZT42Ni1FxrgyRQ5g=")) }); - m_trustStorage.addKeysForPostponedTrustDecisions(ns_ox, - QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), - { keyOwnerCarol }); + m_atmTrustStorage.addKeysForPostponedTrustDecisions(ns_ox, + QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), + { keyOwnerCarol }); QMultiHash<QString, QByteArray> trustedKeys = { { QStringLiteral("alice@example.org"), QByteArray::fromBase64(QByteArrayLiteral("Wl53ZchbtAtCZQCHROiD20W7UnKTQgWQrjTHAVNw1ic=")) }, @@ -413,8 +755,8 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() { QStringLiteral("alice@example.org"), QByteArray::fromBase64(QByteArrayLiteral("7y1t0LnmNBeXJka43XejFPLrKtQlSFATrYmy7xHaKYU=")) } }; - auto future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo, - { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")) }); + auto future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo, + { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")) }); QVERIFY(future.isFinished()); auto result = future.result(); QCOMPARE( @@ -435,9 +777,9 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() { QStringLiteral("bob@example.com"), QByteArray::fromBase64(QByteArrayLiteral("X5tJ1D5rEeaeQE8eqhBKAj4KUZGYe3x+iHifaTBY1kM=")) } }; - future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo, - { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), - QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")) }); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo, + { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), + QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")) }); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -450,7 +792,7 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() distrustedKeys) })); // Retrieve all keys. - future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -468,7 +810,7 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() // sD6ilugEBeKxPsdDEyX43LSGKHKWd5MFEdhT+4RpsxA= for the // sending endpoint with the key // IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=. - m_trustStorage.addKeysForPostponedTrustDecisions( + m_atmTrustStorage.addKeysForPostponedTrustDecisions( ns_omemo, QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), { keyOwnerBobTrustedKeys }); @@ -478,8 +820,8 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() distrustedKeys = { { QStringLiteral("bob@example.com"), QByteArray::fromBase64(QByteArrayLiteral("X5tJ1D5rEeaeQE8eqhBKAj4KUZGYe3x+iHifaTBY1kM=")) } }; - future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo, - { QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")) }); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo, + { QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")) }); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -491,10 +833,10 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() false, distrustedKeys) })); - m_trustStorage.removeKeysForPostponedTrustDecisions(ns_omemo, - { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")) }); + m_atmTrustStorage.removeKeysForPostponedTrustDecisions(ns_omemo, + { QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")) }); - future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -506,11 +848,43 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() false, distrustedKeys) })); - // Remove all OMEMO keys including those stored for sender key - // IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=. - m_trustStorage.removeKeysForPostponedTrustDecisions(ns_omemo); + m_atmTrustStorage.addKeysForPostponedTrustDecisions( + ns_omemo, + QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), + { keyOwnerAlice }); + + // The key QR05jrab7PFkSLhtdzyXrPfCqhkNCYCrlWATaBMTenE= is not removed + // because its ID is passed within the parameter "keyIdsForDistrusting" but + // stored for postponed authentication. + m_atmTrustStorage.removeKeysForPostponedTrustDecisions(ns_omemo, + { QByteArray::fromBase64(QByteArrayLiteral("Wl53ZchbtAtCZQCHROiD20W7UnKTQgWQrjTHAVNw1ic=")), + QByteArray::fromBase64(QByteArrayLiteral("sD6ilugEBeKxPsdDEyX43LSGKHKWd5MFEdhT+4RpsxA=")) }, + { QByteArray::fromBase64(QByteArrayLiteral("mB98hhdVps++skUuy4TGy/Vp6RQXLJO4JGf86FAUjyc=")), + QByteArray::fromBase64(QByteArrayLiteral("QR05jrab7PFkSLhtdzyXrPfCqhkNCYCrlWATaBMTenE=")) }); + + trustedKeys = { { QStringLiteral("alice@example.org"), + QByteArray::fromBase64(QByteArrayLiteral("QR05jrab7PFkSLhtdzyXrPfCqhkNCYCrlWATaBMTenE=")) } }; + distrustedKeys = { { QStringLiteral("alice@example.org"), + QByteArray::fromBase64(QByteArrayLiteral("7y1t0LnmNBeXJka43XejFPLrKtQlSFATrYmy7xHaKYU=")) }, + { QStringLiteral("bob@example.com"), + QByteArray::fromBase64(QByteArrayLiteral("X5tJ1D5rEeaeQE8eqhBKAj4KUZGYe3x+iHifaTBY1kM=")) } }; + + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo); + QVERIFY(future.isFinished()); + result = future.result(); + QCOMPARE( + result, + QHash({ std::pair( + true, + trustedKeys), + std::pair( + false, + distrustedKeys) })); + + // Remove all OMEMO keys. + m_atmTrustStorage.removeKeysForPostponedTrustDecisions(ns_omemo); - future = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo); QVERIFY(future.isFinished()); result = future.result(); QVERIFY(result.isEmpty()); @@ -525,7 +899,7 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() QByteArray::fromBase64(QByteArrayLiteral("wsEN32UHCiNjYqTG/J63hY4Nu8tZT42Ni1FxrgyRQ5g=")) } }; // remaining OX keys - future = m_trustStorage.keysForPostponedTrustDecisions(ns_ox); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_ox); QVERIFY(future.isFinished()); result = future.result(); QCOMPARE( @@ -537,15 +911,69 @@ void tst_QXmppTrustMemoryStorage::testKeysForPostponedTrustDecisions() false, distrustedKeys) })); - m_trustStorage.removeKeysForPostponedTrustDecisions(); + m_atmTrustStorage.removeKeysForPostponedTrustDecisions(ns_ox); // no OX keys - future = m_trustStorage.keysForPostponedTrustDecisions(ns_ox); + future = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_ox); QVERIFY(future.isFinished()); result = future.result(); QVERIFY(result.isEmpty()); +} - m_trustStorage.removeKeys(); +void tst_QXmppTrustMemoryStorage::atmTestResetAll() +{ + QXmppTrustMessageKeyOwner keyOwnerAlice; + keyOwnerAlice.setJid(QStringLiteral("alice@example.org")); + keyOwnerAlice.setTrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("Wl53ZchbtAtCZQCHROiD20W7UnKTQgWQrjTHAVNw1ic=")), + QByteArray::fromBase64(QByteArrayLiteral("QR05jrab7PFkSLhtdzyXrPfCqhkNCYCrlWATaBMTenE=")) }); + keyOwnerAlice.setDistrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("mB98hhdVps++skUuy4TGy/Vp6RQXLJO4JGf86FAUjyc=")) }); + + QXmppTrustMessageKeyOwner keyOwnerBobTrustedKeys; + keyOwnerBobTrustedKeys.setJid(QStringLiteral("bob@example.com")); + keyOwnerBobTrustedKeys.setTrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("GgTqeRLp1M+MEenzFQym2oqer9PfHukS4brJDQl5ARE=")) }); + + m_atmTrustStorage.addKeysForPostponedTrustDecisions(ns_omemo, + QByteArray::fromBase64(QByteArrayLiteral("Mp6Y4wOF3aMcl38lb/VNbdPF9ucGFqSx2eyaEsqyHKE=")), + { keyOwnerAlice, keyOwnerBobTrustedKeys }); + + QXmppTrustMessageKeyOwner keyOwnerCarol; + keyOwnerCarol.setJid(QStringLiteral("carol@example.net")); + keyOwnerCarol.setTrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("WcL+cEMpEeK+dpqg3Xd3amctzwP8h2MqwXcEzFf6LpU=")), + QByteArray::fromBase64(QByteArrayLiteral("bH3R31z0N97K1fUwG3+bdBrVPuDfXguQapHudkfa5nE=")) }); + keyOwnerCarol.setDistrustedKeys({ QByteArray::fromBase64(QByteArrayLiteral("N0B2StHKk1/slwg1rzybTFzjdg7FChc+3cXmTU/rS8g=")), + QByteArray::fromBase64(QByteArrayLiteral("wsEN32UHCiNjYqTG/J63hY4Nu8tZT42Ni1FxrgyRQ5g=")) }); + + m_atmTrustStorage.addKeysForPostponedTrustDecisions(ns_ox, + QByteArray::fromBase64(QByteArrayLiteral("IL5iwDQwquH7yjb5RAiIP+nvYiBUsNCXtKB8IpKc9QU=")), + { keyOwnerCarol }); + + m_atmTrustStorage.resetAll(ns_omemo); + + auto futureKeysForPostponedTrustDecisions = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_omemo); + QVERIFY(futureKeysForPostponedTrustDecisions.isFinished()); + auto resultKeysForPostponedTrustDecisions = futureKeysForPostponedTrustDecisions.result(); + QVERIFY(resultKeysForPostponedTrustDecisions.isEmpty()); + + QMultiHash<QString, QByteArray> trustedKeys = { { QStringLiteral("carol@example.net"), + QByteArray::fromBase64(QByteArrayLiteral("WcL+cEMpEeK+dpqg3Xd3amctzwP8h2MqwXcEzFf6LpU=")) }, + { QStringLiteral("carol@example.net"), + QByteArray::fromBase64(QByteArrayLiteral("bH3R31z0N97K1fUwG3+bdBrVPuDfXguQapHudkfa5nE=")) } }; + QMultiHash<QString, QByteArray> distrustedKeys = { { QStringLiteral("carol@example.net"), + QByteArray::fromBase64(QByteArrayLiteral("N0B2StHKk1/slwg1rzybTFzjdg7FChc+3cXmTU/rS8g=")) }, + { QStringLiteral("carol@example.net"), + QByteArray::fromBase64(QByteArrayLiteral("wsEN32UHCiNjYqTG/J63hY4Nu8tZT42Ni1FxrgyRQ5g=")) } }; + + futureKeysForPostponedTrustDecisions = m_atmTrustStorage.keysForPostponedTrustDecisions(ns_ox); + QVERIFY(futureKeysForPostponedTrustDecisions.isFinished()); + resultKeysForPostponedTrustDecisions = futureKeysForPostponedTrustDecisions.result(); + QCOMPARE( + resultKeysForPostponedTrustDecisions, + QHash({ std::pair( + true, + trustedKeys), + std::pair( + false, + distrustedKeys) })); } QTEST_MAIN(tst_QXmppTrustMemoryStorage) |
