aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-06-18 12:41:31 +0200
committerLinus Jahn <lnj@kaidan.im>2022-06-18 13:08:07 +0200
commit32ccc6358ba6433e6b870b238fba20ccf1862fe2 (patch)
tree81c4f8d5a1af484b7aad52ad2dcef4da556360ad
parentcb1c0ac7ba16590304c8fe7bd6d87b69dffe5c67 (diff)
downloadqxmpp-32ccc6358ba6433e6b870b238fba20ccf1862fe2.tar.gz
Move SecurityPolicy, TrustLevel intro extra headers
This avoids the need to include the whole TrustStorage in files like SendStanzaParams.h.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/client/QXmppAtmManager.cpp19
-rw-r--r--src/client/QXmppSendStanzaParams.cpp10
-rw-r--r--src/client/QXmppSendStanzaParams.h6
-rw-r--r--src/client/QXmppTrustLevel.h48
-rw-r--r--src/client/QXmppTrustManager.cpp20
-rw-r--r--src/client/QXmppTrustManager.h25
-rw-r--r--src/client/QXmppTrustMemoryStorage.cpp21
-rw-r--r--src/client/QXmppTrustMemoryStorage.h18
-rw-r--r--src/client/QXmppTrustSecurityPolicy.h30
-rw-r--r--src/client/QXmppTrustStorage.cpp14
-rw-r--r--src/client/QXmppTrustStorage.h46
-rw-r--r--tests/qxmppatmmanager/tst_qxmppatmmanager.cpp180
-rw-r--r--tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp188
14 files changed, 349 insertions, 278 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 85efa926..e3583c84 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -116,8 +116,10 @@ set(INSTALL_HEADER_FILES
client/QXmppSendStanzaParams.h
client/QXmppTransferManager.h
client/QXmppTransferManager_p.h
+ client/QXmppTrustLevel.h
client/QXmppTrustManager.h
client/QXmppTrustMemoryStorage.h
+ client/QXmppTrustSecurityPolicy.h
client/QXmppTrustStorage.h
client/QXmppUploadRequestManager.h
client/QXmppUserTuneManager.h
diff --git a/src/client/QXmppAtmManager.cpp b/src/client/QXmppAtmManager.cpp
index b7ea5660..4ea30cae 100644
--- a/src/client/QXmppAtmManager.cpp
+++ b/src/client/QXmppAtmManager.cpp
@@ -13,6 +13,7 @@
#include "QXmppTrustMessageKeyOwner.h"
#include "QXmppUtils.h"
+using namespace QXmpp;
using namespace QXmpp::Private;
///
@@ -79,10 +80,10 @@ QFuture<void> QXmppAtmManager::makeTrustDecisions(const QString &encryption, con
{
QFutureInterface<void> interface(QFutureInterfaceBase::Started);
- auto future = keys(encryption, QXmppTrustStorage::Authenticated | QXmppTrustStorage::ManuallyDistrusted);
- await(future, this, [=](const QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>> &&keys) mutable {
- const auto authenticatedKeys = keys.value(QXmppTrustStorage::Authenticated);
- const auto manuallyDistrustedKeys = keys.value(QXmppTrustStorage::ManuallyDistrusted);
+ auto future = keys(encryption, TrustLevel::Authenticated | TrustLevel::ManuallyDistrusted);
+ await(future, this, [=](QHash<TrustLevel, QMultiHash<QString, QByteArray>> keys) mutable {
+ const auto authenticatedKeys = keys.value(TrustLevel::Authenticated);
+ const auto manuallyDistrustedKeys = keys.value(TrustLevel::ManuallyDistrusted);
const auto ownJid = client()->configuration().jidBare();
const auto ownAuthenticatedKeys = authenticatedKeys.values(ownJid);
@@ -303,7 +304,7 @@ QFuture<void> QXmppAtmManager::handleMessage(const QXmppMessage &message)
auto future = trustLevel(encryption, senderJid, senderKey);
await(future, this, [=](const auto &&senderKeyTrustLevel) mutable {
- const auto isSenderKeyAuthenticated = senderKeyTrustLevel == QXmppTrustStorage::Authenticated;
+ const auto isSenderKeyAuthenticated = senderKeyTrustLevel == TrustLevel::Authenticated;
// key owner JIDs mapped to key IDs
QMultiHash<QString, QByteArray> keysBeingAuthenticated;
@@ -380,11 +381,11 @@ QFuture<void> QXmppAtmManager::authenticate(const QString &encryption, const QMu
QFutureInterface<void> interface(QFutureInterfaceBase::Started);
- auto future = setTrustLevel(encryption, keyIds, QXmppTrustStorage::Authenticated);
+ auto future = setTrustLevel(encryption, keyIds, TrustLevel::Authenticated);
await(future, this, [=]() mutable {
auto future = securityPolicy(encryption);
await(future, this, [=](auto securityPolicy) mutable {
- if (securityPolicy == QXmppTrustStorage::Toakafa) {
+ if (securityPolicy == Toakafa) {
auto future = distrustAutomaticallyTrustedKeys(encryption, keyIds.uniqueKeys());
await(future, this, [=]() mutable {
auto future = makePostponedTrustDecisions(encryption, keyIds.values());
@@ -418,7 +419,7 @@ QFuture<void> QXmppAtmManager::distrust(const QString &encryption, const QMultiH
QFutureInterface<void> interface(QFutureInterfaceBase::Started);
- auto future = setTrustLevel(encryption, keyIds, QXmppTrustStorage::ManuallyDistrusted);
+ auto future = setTrustLevel(encryption, keyIds, TrustLevel::ManuallyDistrusted);
await(future, this, [=]() mutable {
auto future = trustStorage()->removeKeysForPostponedTrustDecisions(encryption, keyIds.values());
await(future, this, [=]() mutable {
@@ -438,7 +439,7 @@ QFuture<void> QXmppAtmManager::distrust(const QString &encryption, const QMultiH
///
QFuture<void> QXmppAtmManager::distrustAutomaticallyTrustedKeys(const QString &encryption, const QList<QString> &keyOwnerJids)
{
- return setTrustLevel(encryption, keyOwnerJids, QXmppTrustStorage::AutomaticallyTrusted, QXmppTrustStorage::AutomaticallyDistrusted);
+ return setTrustLevel(encryption, keyOwnerJids, TrustLevel::AutomaticallyTrusted, TrustLevel::AutomaticallyDistrusted);
}
///
diff --git a/src/client/QXmppSendStanzaParams.cpp b/src/client/QXmppSendStanzaParams.cpp
index 6c8b6ccc..9711750d 100644
--- a/src/client/QXmppSendStanzaParams.cpp
+++ b/src/client/QXmppSendStanzaParams.cpp
@@ -6,6 +6,8 @@
#include <QVector>
+using namespace QXmpp;
+
///
/// \class QXmppSendStanzaParams
///
@@ -17,8 +19,8 @@
class QXmppSendStanzaParamsPrivate : public QSharedData
{
public:
+ TrustLevels acceptedTrustLevels;
QVector<QString> encryptionJids;
- QXmppTrustStorage::TrustLevels acceptedTrustLevels;
};
QXmppSendStanzaParams::QXmppSendStanzaParams()
@@ -65,7 +67,7 @@ void QXmppSendStanzaParams::setEncryptionJids(QVector<QString> encryptionJids)
///
/// \return the trust levels of the keys used for encryption
///
-std::optional<QXmppTrustStorage::TrustLevels> QXmppSendStanzaParams::acceptedTrustLevels() const
+std::optional<TrustLevels> QXmppSendStanzaParams::acceptedTrustLevels() const
{
if (d->acceptedTrustLevels) {
return d->acceptedTrustLevels;
@@ -80,7 +82,7 @@ std::optional<QXmppTrustStorage::TrustLevels> QXmppSendStanzaParams::acceptedTru
///
/// \param trustLevels trust levels of the keys used for encryption
///
-void QXmppSendStanzaParams::setAcceptedTrustLevels(std::optional<QXmppTrustStorage::TrustLevels> trustLevels)
+void QXmppSendStanzaParams::setAcceptedTrustLevels(std::optional<TrustLevels> trustLevels)
{
- d->acceptedTrustLevels = trustLevels.value_or(QXmppTrustStorage::TrustLevels());
+ d->acceptedTrustLevels = trustLevels.value_or(QXmpp::TrustLevels());
}
diff --git a/src/client/QXmppSendStanzaParams.h b/src/client/QXmppSendStanzaParams.h
index 70ef572a..56bb314b 100644
--- a/src/client/QXmppSendStanzaParams.h
+++ b/src/client/QXmppSendStanzaParams.h
@@ -6,7 +6,7 @@
#define QXMPPSENDSTANZAPARAMS_H
#include "QXmppGlobal.h"
-#include "QXmppTrustStorage.h"
+#include "QXmppTrustLevel.h"
#include <optional>
@@ -27,8 +27,8 @@ public:
QVector<QString> encryptionJids() const;
void setEncryptionJids(QVector<QString>);
- std::optional<QXmppTrustStorage::TrustLevels> acceptedTrustLevels() const;
- void setAcceptedTrustLevels(std::optional<QXmppTrustStorage::TrustLevels> trustLevels);
+ std::optional<QXmpp::TrustLevels> acceptedTrustLevels() const;
+ void setAcceptedTrustLevels(std::optional<QXmpp::TrustLevels> trustLevels);
private:
QSharedDataPointer<QXmppSendStanzaParamsPrivate> d;
diff --git a/src/client/QXmppTrustLevel.h b/src/client/QXmppTrustLevel.h
new file mode 100644
index 00000000..2cff9e2a
--- /dev/null
+++ b/src/client/QXmppTrustLevel.h
@@ -0,0 +1,48 @@
+// SPDX-FileCopyrightText: 2021 Melvin Keskin <melvo@olomono.de>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifndef QXMPPTRUSTLEVEL_H
+#define QXMPPTRUSTLEVEL_H
+
+#include <QFlags>
+#include <QHashFunctions>
+
+namespace QXmpp {
+
+///
+/// Trust level of public long-term keys used by end-to-end encryption
+/// protocols
+///
+/// \since QXmpp 1.5
+///
+enum class TrustLevel {
+ /// The key's trust is not decided.
+ Undecided = 1,
+ /// The key is automatically distrusted (e.g., by the security policy TOAKAFA).
+ /// \see SecurityPolicy
+ AutomaticallyDistrusted = 2,
+ /// The key is manually distrusted (e.g., by clicking a button or \xep{0450, Automatic Trust
+ /// Management (ATM)}).
+ ManuallyDistrusted = 4,
+ /// The key is automatically trusted (e.g., by the client for all keys of a bare JID until one
+ /// of it is authenticated).
+ AutomaticallyTrusted = 8,
+ /// The key is manually trusted (e.g., by clicking a button).
+ ManuallyTrusted = 16,
+ /// The key is authenticated (e.g., by QR code scanning or \xep{0450, Automatic Trust
+ /// Management (ATM)}).
+ Authenticated = 32,
+};
+
+Q_DECLARE_FLAGS(TrustLevels, TrustLevel)
+Q_DECLARE_OPERATORS_FOR_FLAGS(TrustLevels)
+
+} // namespace QXmpp
+
+/// \cond
+// Scoped enums (enum class) are not implicitly converted to int
+inline uint qHash(QXmpp::TrustLevel key, uint seed) noexcept { return qHash(std::underlying_type_t<QXmpp::TrustLevel>(key), seed); }
+/// \endcond
+
+#endif // QXMPPTRUSTLEVEL_H
diff --git a/src/client/QXmppTrustManager.cpp b/src/client/QXmppTrustManager.cpp
index e198255c..7b9b34ab 100644
--- a/src/client/QXmppTrustManager.cpp
+++ b/src/client/QXmppTrustManager.cpp
@@ -5,7 +5,9 @@
#include "QXmppTrustManager.h"
#include "QXmppFutureUtils_p.h"
+#include "QXmppTrustStorage.h"
+using namespace QXmpp;
using namespace QXmpp::Private;
///
@@ -38,7 +40,7 @@ QXmppTrustManager::~QXmppTrustManager() = default;
/// \param encryption encryption protocol namespace
/// \param securityPolicy security policy being applied
///
-QFuture<void> QXmppTrustManager::setSecurityPolicy(const QString &encryption, QXmppTrustStorage::SecurityPolicy securityPolicy)
+QFuture<void> QXmppTrustManager::setSecurityPolicy(const QString &encryption, TrustSecurityPolicy securityPolicy)
{
return m_trustStorage->setSecurityPolicy(encryption, securityPolicy);
}
@@ -60,7 +62,7 @@ QFuture<void> QXmppTrustManager::resetSecurityPolicy(const QString &encryption)
///
/// \return the set security policy
///
-QFuture<QXmppTrustStorage::SecurityPolicy> QXmppTrustManager::securityPolicy(const QString &encryption)
+QFuture<TrustSecurityPolicy> QXmppTrustManager::securityPolicy(const QString &encryption)
{
return m_trustStorage->securityPolicy(encryption);
}
@@ -109,7 +111,7 @@ QFuture<QByteArray> QXmppTrustManager::ownKey(const QString &encryption)
/// \param keyIds IDs of the keys
/// \param trustLevel trust level of the keys
///
-QFuture<void> QXmppTrustManager::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel)
+QFuture<void> QXmppTrustManager::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, TrustLevel trustLevel)
{
return m_trustStorage->addKeys(encryption, keyOwnerJid, keyIds, trustLevel);
}
@@ -157,7 +159,7 @@ QFuture<void> QXmppTrustManager::removeKeys(const QString &encryption)
///
/// \return the key owner JIDs mapped to their keys with specific trust levels
///
-QFuture<QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>>> QXmppTrustManager::keys(const QString &encryption, QXmppTrustStorage::TrustLevels trustLevels)
+QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> QXmppTrustManager::keys(const QString &encryption, QXmpp::TrustLevels trustLevels)
{
return m_trustStorage->keys(encryption, trustLevels);
}
@@ -175,7 +177,7 @@ QFuture<QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>>> Q
///
/// \return the key IDs mapped to their trust levels for specific key owners
///
-QFuture<QHash<QString, QHash<QByteArray, QXmppTrustStorage::TrustLevel>>> QXmppTrustManager::keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmppTrustStorage::TrustLevels trustLevels)
+QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> QXmppTrustManager::keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevels trustLevels)
{
return m_trustStorage->keys(encryption, keyOwnerJids, trustLevels);
}
@@ -190,7 +192,7 @@ QFuture<QHash<QString, QHash<QByteArray, QXmppTrustStorage::TrustLevel>>> QXmppT
///
/// \return whether a key of the key owner with a passed trust level is stored
///
-QFuture<bool> QXmppTrustManager::hasKey(const QString &encryption, const QString &keyOwnerJid, QXmppTrustStorage::TrustLevels trustLevels)
+QFuture<bool> QXmppTrustManager::hasKey(const QString &encryption, const QString &keyOwnerJid, TrustLevels trustLevels)
{
return m_trustStorage->hasKey(encryption, keyOwnerJid, trustLevels);
}
@@ -204,7 +206,7 @@ QFuture<bool> QXmppTrustManager::hasKey(const QString &encryption, const QString
/// \param keyIds key owners' bare JIDs mapped to the IDs of their keys
/// \param trustLevel trust level being set
///
-QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel)
+QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel)
{
QFutureInterface<void> interface(QFutureInterfaceBase::Started);
@@ -225,7 +227,7 @@ QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const
/// \param oldTrustLevel trust level being changed
/// \param newTrustLevel trust level being set
///
-QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmppTrustStorage::TrustLevel oldTrustLevel, QXmppTrustStorage::TrustLevel newTrustLevel)
+QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel)
{
QFutureInterface<void> interface(QFutureInterfaceBase::Started);
@@ -249,7 +251,7 @@ QFuture<void> QXmppTrustManager::setTrustLevel(const QString &encryption, const
///
/// \return the key's trust level
///
-QFuture<QXmppTrustStorage::TrustLevel> QXmppTrustManager::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
+QFuture<TrustLevel> QXmppTrustManager::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
{
return m_trustStorage->trustLevel(encryption, keyOwnerJid, keyId);
}
diff --git a/src/client/QXmppTrustManager.h b/src/client/QXmppTrustManager.h
index 9081af92..601bb9ac 100644
--- a/src/client/QXmppTrustManager.h
+++ b/src/client/QXmppTrustManager.h
@@ -6,7 +6,12 @@
#define QXMPPTRUSTMANAGER_H
#include "QXmppClientExtension.h"
-#include "QXmppTrustStorage.h"
+#include "QXmppTrustLevel.h"
+#include "QXmppTrustSecurityPolicy.h"
+
+#include <QFuture>
+
+class QXmppTrustStorage;
class QXMPP_EXPORT QXmppTrustManager : public QXmppClientExtension
{
@@ -16,25 +21,25 @@ public:
QXmppTrustManager(QXmppTrustStorage *trustStorage);
~QXmppTrustManager();
- QFuture<void> setSecurityPolicy(const QString &encryption, QXmppTrustStorage::SecurityPolicy securityPolicy);
+ QFuture<void> setSecurityPolicy(const QString &encryption, QXmpp::TrustSecurityPolicy securityPolicy);
QFuture<void> resetSecurityPolicy(const QString &encryption);
- QFuture<QXmppTrustStorage::SecurityPolicy> securityPolicy(const QString &encryption);
+ QFuture<QXmpp::TrustSecurityPolicy> securityPolicy(const QString &encryption);
QFuture<void> setOwnKey(const QString &encryption, const QByteArray &keyId);
QFuture<void> resetOwnKey(const QString &encryption);
QFuture<QByteArray> ownKey(const QString &encryption);
- QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel = QXmppTrustStorage::AutomaticallyDistrusted);
+ QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmpp::TrustLevel trustLevel = QXmpp::TrustLevel::AutomaticallyDistrusted);
QFuture<void> removeKeys(const QString &encryption, const QList<QByteArray> &keyIds);
QFuture<void> removeKeys(const QString &encryption, const QString &keyOwnerJid);
QFuture<void> removeKeys(const QString &encryption);
- QFuture<QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, QXmppTrustStorage::TrustLevels trustLevels = {});
- QFuture<QHash<QString, QHash<QByteArray, QXmppTrustStorage::TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmppTrustStorage::TrustLevels trustLevels = {});
- QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, QXmppTrustStorage::TrustLevels trustLevels);
+ QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, QXmpp::TrustLevels trustLevels = {});
+ QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevels trustLevels = {});
+ QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, QXmpp::TrustLevels trustLevels);
- QFuture<void> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel);
- QFuture<void> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmppTrustStorage::TrustLevel oldTrustLevel, QXmppTrustStorage::TrustLevel newTrustLevel);
- QFuture<QXmppTrustStorage::TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId);
+ QFuture<void> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmpp::TrustLevel trustLevel);
+ QFuture<void> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevel oldTrustLevel, QXmpp::TrustLevel newTrustLevel);
+ QFuture<QXmpp::TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId);
QFuture<void> resetAll(const QString &encryption);
diff --git a/src/client/QXmppTrustMemoryStorage.cpp b/src/client/QXmppTrustMemoryStorage.cpp
index a94768d2..daab2e73 100644
--- a/src/client/QXmppTrustMemoryStorage.cpp
+++ b/src/client/QXmppTrustMemoryStorage.cpp
@@ -6,6 +6,7 @@
#include "QXmppFutureUtils_p.h"
+using namespace QXmpp;
using namespace QXmpp::Private;
///
@@ -23,14 +24,14 @@ struct Key
{
QByteArray id;
QString ownerJid;
- QXmppTrustStorage::TrustLevel trustLevel;
+ TrustLevel trustLevel;
};
class QXmppTrustMemoryStoragePrivate
{
public:
// encryption protocols mapped to security policies
- QMap<QString, QXmppTrustStorage::SecurityPolicy> securityPolicies;
+ QMap<QString, TrustSecurityPolicy> securityPolicies;
// encryption protocols mapped to keys of this client instance
QMap<QString, QByteArray> ownKeys;
@@ -50,7 +51,7 @@ QXmppTrustMemoryStorage::QXmppTrustMemoryStorage()
QXmppTrustMemoryStorage::~QXmppTrustMemoryStorage() = default;
/// \cond
-QFuture<void> QXmppTrustMemoryStorage::setSecurityPolicy(const QString &encryption, QXmppTrustStorage::SecurityPolicy securityPolicy)
+QFuture<void> QXmppTrustMemoryStorage::setSecurityPolicy(const QString &encryption, TrustSecurityPolicy securityPolicy)
{
d->securityPolicies.insert(encryption, securityPolicy);
return makeReadyFuture();
@@ -62,7 +63,7 @@ QFuture<void> QXmppTrustMemoryStorage::resetSecurityPolicy(const QString &encryp
return makeReadyFuture();
}
-QFuture<QXmppTrustStorage::SecurityPolicy> QXmppTrustMemoryStorage::securityPolicy(const QString &encryption)
+QFuture<TrustSecurityPolicy> QXmppTrustMemoryStorage::securityPolicy(const QString &encryption)
{
return makeReadyFuture(std::move(d->securityPolicies.value(encryption)));
}
@@ -85,7 +86,7 @@ QFuture<QByteArray> QXmppTrustMemoryStorage::ownKey(const QString &encryption)
return makeReadyFuture(std::move(key));
}
-QFuture<void> QXmppTrustMemoryStorage::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel)
+QFuture<void> QXmppTrustMemoryStorage::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, TrustLevel trustLevel)
{
for (const auto &keyId : keyIds) {
Key key;
@@ -132,7 +133,7 @@ QFuture<void> QXmppTrustMemoryStorage::removeKeys(const QString &encryption)
return makeReadyFuture();
}
-QFuture<QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>>> QXmppTrustMemoryStorage::keys(const QString &encryption, TrustLevels trustLevels)
+QFuture<QHash<TrustLevel, QMultiHash<QString, QByteArray>>> QXmppTrustMemoryStorage::keys(const QString &encryption, TrustLevels trustLevels)
{
QHash<TrustLevel, QMultiHash<QString, QByteArray>> keys;
@@ -147,9 +148,9 @@ QFuture<QHash<QXmppTrustStorage::TrustLevel, QMultiHash<QString, QByteArray>>> Q
return makeReadyFuture(std::move(keys));
}
-QFuture<QHash<QString, QHash<QByteArray, QXmppTrustStorage::TrustLevel>>> QXmppTrustMemoryStorage::keys(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevels trustLevels)
+QFuture<QHash<QString, QHash<QByteArray, TrustLevel>>> QXmppTrustMemoryStorage::keys(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevels trustLevels)
{
- QHash<QString, QHash<QByteArray, QXmppTrustStorage::TrustLevel>> keys;
+ QHash<QString, QHash<QByteArray, TrustLevel>> keys;
const auto storedKeys = d->keys.values(encryption);
for (const auto &key : storedKeys) {
@@ -231,7 +232,7 @@ QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> QXmppTrustMemoryStorage
return makeReadyFuture(std::move(modifiedKeys));
}
-QFuture<QXmppTrustStorage::TrustLevel> QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
+QFuture<TrustLevel> QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
{
const auto keys = d->keys.values(encryption);
for (const auto &key : keys) {
@@ -240,7 +241,7 @@ QFuture<QXmppTrustStorage::TrustLevel> QXmppTrustMemoryStorage::trustLevel(const
}
}
- return makeReadyFuture(std::move(QXmppTrustStorage::Undecided));
+ return makeReadyFuture(std::move(TrustLevel::Undecided));
}
QFuture<void> QXmppTrustMemoryStorage::resetAll(const QString &encryption)
diff --git a/src/client/QXmppTrustMemoryStorage.h b/src/client/QXmppTrustMemoryStorage.h
index 1d0e2561..f5e92569 100644
--- a/src/client/QXmppTrustMemoryStorage.h
+++ b/src/client/QXmppTrustMemoryStorage.h
@@ -18,25 +18,25 @@ public:
~QXmppTrustMemoryStorage();
/// \cond
- QFuture<void> setSecurityPolicy(const QString &encryption, SecurityPolicy securityPolicy) override;
+ QFuture<void> setSecurityPolicy(const QString &encryption, QXmpp::TrustSecurityPolicy securityPolicy) override;
QFuture<void> resetSecurityPolicy(const QString &encryption) override;
- QFuture<SecurityPolicy> securityPolicy(const QString &encryption) override;
+ QFuture<QXmpp::TrustSecurityPolicy> securityPolicy(const QString &encryption) override;
QFuture<void> setOwnKey(const QString &encryption, const QByteArray &keyId) override;
QFuture<void> resetOwnKey(const QString &encryption) override;
QFuture<QByteArray> ownKey(const QString &encryption) override;
- QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, TrustLevel trustLevel = TrustLevel::AutomaticallyDistrusted) override;
+ QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmpp::TrustLevel trustLevel = QXmpp::TrustLevel::AutomaticallyDistrusted) override;
QFuture<void> removeKeys(const QString &encryption, const QList<QByteArray> &keyIds) override;
QFuture<void> removeKeys(const QString &encryption, const QString &keyOwnerJid) override;
QFuture<void> removeKeys(const QString &encryption) override;
- QFuture<QHash<TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, TrustLevels trustLevels = {}) override;
- QFuture<QHash<QString, QHash<QByteArray, TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevels trustLevels = {}) override;
- QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, TrustLevels trustLevels) override;
+ QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, QXmpp::TrustLevels trustLevels = {}) override;
+ QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevels trustLevels = {}) override;
+ QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, QXmpp::TrustLevels trustLevels) override;
- QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel) override;
- QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) override;
- QFuture<TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) override;
+ QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmpp::TrustLevel trustLevel) override;
+ QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevel oldTrustLevel, QXmpp::TrustLevel newTrustLevel) override;
+ QFuture<QXmpp::TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) override;
QFuture<void> resetAll(const QString &encryption) override;
/// \endcond
diff --git a/src/client/QXmppTrustSecurityPolicy.h b/src/client/QXmppTrustSecurityPolicy.h
new file mode 100644
index 00000000..5020b81d
--- /dev/null
+++ b/src/client/QXmppTrustSecurityPolicy.h
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 2021 Melvin Keskin <melvo@olomono.de>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifndef QXMPPTRUSTSECURITYPOLICY_H
+#define QXMPPTRUSTSECURITYPOLICY_H
+
+#include <QMetaType>
+
+namespace QXmpp {
+
+///
+/// Security policy to decide which public long-term keys are used for encryption because they are
+/// trusted
+///
+/// \since QXmpp 1.5
+///
+enum TrustSecurityPolicy {
+ /// New keys must be trusted manually.
+ NoSecurityPolicy,
+ /// New keys are trusted automatically until the first authentication but automatically
+ /// distrusted afterwards. \see \xep{0450, Automatic Trust Management (ATM)}
+ Toakafa,
+};
+
+} // namespace QXmpp
+
+Q_DECLARE_METATYPE(QXmpp::TrustSecurityPolicy)
+
+#endif // QXMPPTRUSTSECURITYPOLICY_H
diff --git a/src/client/QXmppTrustStorage.cpp b/src/client/QXmppTrustStorage.cpp
index 18637fab..50b39089 100644
--- a/src/client/QXmppTrustStorage.cpp
+++ b/src/client/QXmppTrustStorage.cpp
@@ -15,7 +15,7 @@
///
///
-/// \fn QXmppTrustStorage::setSecurityPolicy(const QString &encryption, SecurityPolicy securityPolicy)
+/// \fn QXmppTrustStorage::setSecurityPolicy(const QString &encryption, QXmpp::SecurityPolicy securityPolicy)
///
/// Sets the security policy for an encryption protocol.
///
@@ -72,7 +72,7 @@
///
///
-/// \fn QXmppTrustStorage::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmppTrustStorage::TrustLevel trustLevel)
+/// \fn QXmppTrustStorage::addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmpp::TrustLevel trustLevel)
///
/// Adds keys.
///
@@ -109,7 +109,7 @@
///
///
-/// \fn QXmppTrustStorage::keys(const QString &encryption, TrustLevels trustLevels = {})
+/// \fn QXmppTrustStorage::keys(const QString &encryption, QXmpp::TrustLevels trustLevels = {})
///
/// Returns the JIDs of all key owners mapped to the IDs of their keys with
/// specific trust levels.
@@ -123,7 +123,7 @@
///
///
-/// \fn QXmppTrustStorage::keys(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevels trustLevels = {})
+/// \fn QXmppTrustStorage::keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevels trustLevels = {})
///
/// Returns the IDs of keys mapped to their trust levels for specific key
/// owners.
@@ -139,7 +139,7 @@
///
///
-/// \fn QXmppTrustStorage::hasKey(const QString &encryption, const QString &keyOwnerJid, TrustLevels trustLevels)
+/// \fn QXmppTrustStorage::hasKey(const QString &encryption, const QString &keyOwnerJid, QXmpp::TrustLevels trustLevels)
///
/// Returns whether at least one key of a key owner with a specific trust level
/// is stored.
@@ -152,7 +152,7 @@
///
///
-/// \fn QXmppTrustStorage::setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel)
+/// \fn QXmppTrustStorage::setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmpp::TrustLevel trustLevel)
///
/// Sets the trust level of keys.
///
@@ -167,7 +167,7 @@
///
///
-/// \fn QXmppTrustStorage::setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel)
+/// \fn QXmppTrustStorage::setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevel oldTrustLevel, QXmpp::TrustLevel newTrustLevel)
///
/// Sets the trust level of keys specified by their key owner and trust level.
///
diff --git a/src/client/QXmppTrustStorage.h b/src/client/QXmppTrustStorage.h
index b93eae7b..0edc92a4 100644
--- a/src/client/QXmppTrustStorage.h
+++ b/src/client/QXmppTrustStorage.h
@@ -6,61 +6,37 @@
#define QXMPPTRUSTSTORAGE_H
#include "QXmppGlobal.h"
+#include "QXmppTrustLevel.h"
+#include "QXmppTrustSecurityPolicy.h"
#include <QFuture>
class QXMPP_EXPORT QXmppTrustStorage
{
public:
- ///
- /// Security policy to decide which public long-term keys are used for
- /// encryption because they are trusted
- ///
- enum SecurityPolicy {
- NoSecurityPolicy, ///< New keys must be trusted manually.
- Toakafa, ///< New keys are trusted automatically until the first authentication but automatically distrusted afterwards. \see \xep{0450, Automatic Trust Management (ATM)}
- };
-
- ///
- /// Trust level of public long-term keys used by end-to-end encryption
- /// protocols
- ///
- enum TrustLevel {
- Undecided = 1, ///< The key's trust is not decided.
- AutomaticallyDistrusted = 2, ///< The key is automatically distrusted (e.g., by the security policy TOAKAFA). \see SecurityPolicy
- ManuallyDistrusted = 4, ///< The key is manually distrusted (e.g., by clicking a button or \xep{0450, Automatic Trust Management (ATM)}).
- AutomaticallyTrusted = 8, ///< The key is automatically trusted (e.g., by the client for all keys of a bare JID until one of it is authenticated).
- ManuallyTrusted = 16, ///< The key is manually trusted (e.g., by clicking a button).
- Authenticated = 32, ///< The key is authenticated (e.g., by QR code scanning or \xep{0450, Automatic Trust Management (ATM)}).
- };
- Q_DECLARE_FLAGS(TrustLevels, TrustLevel)
-
virtual ~QXmppTrustStorage() = default;
- virtual QFuture<void> setSecurityPolicy(const QString &encryption, SecurityPolicy securityPolicy) = 0;
+ virtual QFuture<void> setSecurityPolicy(const QString &encryption, QXmpp::TrustSecurityPolicy securityPolicy) = 0;
virtual QFuture<void> resetSecurityPolicy(const QString &encryption) = 0;
- virtual QFuture<SecurityPolicy> securityPolicy(const QString &encryption) = 0;
+ virtual QFuture<QXmpp::TrustSecurityPolicy> securityPolicy(const QString &encryption) = 0;
virtual QFuture<void> setOwnKey(const QString &encryption, const QByteArray &keyId) = 0;
virtual QFuture<void> resetOwnKey(const QString &encryption) = 0;
virtual QFuture<QByteArray> ownKey(const QString &encryption) = 0;
- virtual QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, TrustLevel trustLevel = TrustLevel::AutomaticallyDistrusted) = 0;
+ virtual QFuture<void> addKeys(const QString &encryption, const QString &keyOwnerJid, const QList<QByteArray> &keyIds, QXmpp::TrustLevel trustLevel = QXmpp::TrustLevel::AutomaticallyDistrusted) = 0;
virtual QFuture<void> removeKeys(const QString &encryption, const QList<QByteArray> &keyIds) = 0;
virtual QFuture<void> removeKeys(const QString &encryption, const QString &keyOwnerJid) = 0;
virtual QFuture<void> removeKeys(const QString &encryption) = 0;
- virtual QFuture<QHash<TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, TrustLevels trustLevels = {}) = 0;
- virtual QFuture<QHash<QString, QHash<QByteArray, TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevels trustLevels = {}) = 0;
- virtual QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, TrustLevels trustLevels) = 0;
+ virtual QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> keys(const QString &encryption, QXmpp::TrustLevels trustLevels = {}) = 0;
+ virtual QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> keys(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevels trustLevels = {}) = 0;
+ virtual QFuture<bool> hasKey(const QString &encryption, const QString &keyOwnerJid, QXmpp::TrustLevels trustLevels) = 0;
- virtual QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel) = 0;
- virtual QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) = 0;
- virtual QFuture<TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) = 0;
+ virtual QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, QXmpp::TrustLevel trustLevel) = 0;
+ virtual QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, QXmpp::TrustLevel oldTrustLevel, QXmpp::TrustLevel newTrustLevel) = 0;
+ virtual QFuture<QXmpp::TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) = 0;
virtual QFuture<void> resetAll(const QString &encryption) = 0;
};
-Q_DECLARE_METATYPE(QXmppTrustStorage::SecurityPolicy)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppTrustStorage::TrustLevels)
-
#endif // QXMPPTRUSTSTORAGE_H
diff --git a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
index 944321f9..ad29d7ea 100644
--- a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
+++ b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
@@ -15,6 +15,8 @@
#include <QObject>
#include <QSet>
+using namespace QXmpp;
+
Q_DECLARE_METATYPE(QList<QXmppTrustMessageKeyOwner>)
// time period (in ms) to wait for a trust message that should not be sent.
@@ -211,13 +213,13 @@ void tst_QXmppAtmManager::testMakePostponedTrustDecisions()
QByteArray::fromBase64(QByteArrayLiteral("3bqdCfhQalsOp3LcrFVucCQB4pRRWCyoBTV8KM/oOhY=")) } };
auto future = m_manager.keys(ns_omemo,
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
QVERIFY(future.isFinished());
auto result = future.result();
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
QMultiHash<QString, QByteArray> manuallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
@@ -230,13 +232,13 @@ void tst_QXmppAtmManager::testMakePostponedTrustDecisions()
QByteArray::fromBase64(QByteArrayLiteral("U3+UnkTp12gusKbzWwN0lqDLEPb2CdMxP4bY85q9pxA=")) } };
future = m_manager.keys(ns_omemo,
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
QVERIFY(future.isFinished());
result = future.result();
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
}
@@ -249,25 +251,25 @@ void tst_QXmppAtmManager::testDistrustAutomaticallyTrustedKeys()
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_manager.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("GaHysNhcfDSzG2q6OAThRGUpuFB9E7iCRR/1mK1TL+Q=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("dZVdoBINK2n8BkWeTzVg0lVOah4n/9IA/IvQpzUuo1w=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("We+r1A/kixDad8e383oTmhPDy8g+F5/ircMJmEET8MA=")) },
- QXmppTrustStorage::ManuallyTrusted);
+ TrustLevel::ManuallyTrusted);
m_manager.distrustAutomaticallyTrustedKeys(ns_omemo,
{ QStringLiteral("alice@example.org"),
@@ -281,13 +283,13 @@ void tst_QXmppAtmManager::testDistrustAutomaticallyTrustedKeys()
QByteArray::fromBase64(QByteArrayLiteral("dZVdoBINK2n8BkWeTzVg0lVOah4n/9IA/IvQpzUuo1w=")) } };
auto future = m_manager.keys(ns_omemo,
- QXmppTrustStorage::AutomaticallyDistrusted);
+ TrustLevel::AutomaticallyDistrusted);
QVERIFY(future.isFinished());
auto result = future.result();
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys) }));
}
@@ -304,7 +306,7 @@ void tst_QXmppAtmManager::testDistrust()
ns_omemo,
QStringLiteral("alice@example.org"),
authenticatedKeys.values(),
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
QMultiHash<QString, QByteArray> automaticallyTrustedKeys = { { QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("mwT0Hwr7aG1p+x0q60H0UDSEnr8cr7hxvxDEhFGrLmY=")) } };
@@ -313,7 +315,7 @@ void tst_QXmppAtmManager::testDistrust()
ns_omemo,
QStringLiteral("bob@example.com"),
automaticallyTrustedKeys.values(),
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
QMultiHash<QString, QByteArray> manuallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("6FjJDKcwUxncGka8RvrTGSho+LVDX/7E0+pi5ueqOBQ=")) },
@@ -324,7 +326,7 @@ void tst_QXmppAtmManager::testDistrust()
ns_omemo,
QStringLiteral("alice@example.org"),
manuallyDistrustedKeys.values(),
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
QXmppTrustMessageKeyOwner keyOwnerAlice;
keyOwnerAlice.setJid(QStringLiteral("alice@example.org"));
@@ -362,13 +364,13 @@ void tst_QXmppAtmManager::testDistrust()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
futureVoid = m_manager.distrust(ns_omemo,
@@ -400,10 +402,10 @@ void tst_QXmppAtmManager::testDistrust()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
auto futurePostponed = m_trustStorage.keysForPostponedTrustDecisions(ns_omemo,
@@ -434,20 +436,20 @@ void tst_QXmppAtmManager::testDistrust()
void tst_QXmppAtmManager::testAuthenticate_data()
{
- QTest::addColumn<QXmppTrustStorage::SecurityPolicy>("securityPolicy");
+ QTest::addColumn<TrustSecurityPolicy>("securityPolicy");
QTest::newRow("noSecurityPolicy")
- << QXmppTrustStorage::NoSecurityPolicy;
+ << NoSecurityPolicy;
QTest::newRow("toakafa")
- << QXmppTrustStorage::Toakafa;
+ << Toakafa;
}
void tst_QXmppAtmManager::testAuthenticate()
{
clearTrustStorage();
- QFETCH(QXmppTrustStorage::SecurityPolicy, securityPolicy);
+ QFETCH(TrustSecurityPolicy, securityPolicy);
m_manager.setSecurityPolicy(ns_omemo, securityPolicy);
QMultiHash<QString, QByteArray> authenticatedKeys = { { QStringLiteral("alice@example.org"),
@@ -459,13 +461,13 @@ void tst_QXmppAtmManager::testAuthenticate()
ns_omemo,
QStringLiteral("alice@example.org"),
authenticatedKeys.values(QStringLiteral("alice@example.org")),
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
authenticatedKeys.values(QStringLiteral("carol@example.net")),
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
QMultiHash<QString, QByteArray> automaticallyTrustedKeys = { { QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("mwT0Hwr7aG1p+x0q60H0UDSEnr8cr7hxvxDEhFGrLmY=")) },
@@ -476,7 +478,7 @@ void tst_QXmppAtmManager::testAuthenticate()
ns_omemo,
QStringLiteral("bob@example.com"),
automaticallyTrustedKeys.values(),
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
QMultiHash<QString, QByteArray> manuallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("6FjJDKcwUxncGka8RvrTGSho+LVDX/7E0+pi5ueqOBQ=")) },
@@ -487,7 +489,7 @@ void tst_QXmppAtmManager::testAuthenticate()
ns_omemo,
QStringLiteral("alice@example.org"),
manuallyDistrustedKeys.values(),
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
QMultiHash<QString, QByteArray> automaticallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")) },
@@ -498,7 +500,7 @@ void tst_QXmppAtmManager::testAuthenticate()
ns_omemo,
QStringLiteral("alice@example.org"),
automaticallyDistrustedKeys.values(),
- QXmppTrustStorage::AutomaticallyDistrusted);
+ TrustLevel::AutomaticallyDistrusted);
QXmppTrustMessageKeyOwner keyOwnerAlice;
keyOwnerAlice.setJid(QStringLiteral("alice@example.org"));
@@ -562,16 +564,16 @@ void tst_QXmppAtmManager::testAuthenticate()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys) }));
futureVoid = m_manager.authenticate(ns_omemo,
@@ -613,13 +615,13 @@ void tst_QXmppAtmManager::testAuthenticate()
{ QStringLiteral("carol@example.net"),
QByteArray::fromBase64(QByteArrayLiteral("+CQZlFyxdeTGgbPby7YvvZT3YIVcIi+1E8N5nSc6QTA=")) } };
- if (securityPolicy == QXmppTrustStorage::NoSecurityPolicy) {
+ if (securityPolicy == NoSecurityPolicy) {
automaticallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) } };
automaticallyTrustedKeys = { { QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("/dqv0+RNyFIPdMQiJ7mSEJWKVExFeUBEvTXxOtqIMDg=")) } };
- } else if (securityPolicy == QXmppTrustStorage::Toakafa) {
+ } else if (securityPolicy == Toakafa) {
automaticallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
{ QStringLiteral("bob@example.com"),
@@ -630,33 +632,33 @@ void tst_QXmppAtmManager::testAuthenticate()
QVERIFY(future.isFinished());
result = future.result();
switch (securityPolicy) {
- case QXmppTrustStorage::NoSecurityPolicy:
+ case NoSecurityPolicy:
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys) }));
break;
- case QXmppTrustStorage::Toakafa:
+ case Toakafa:
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys) }));
break;
}
@@ -715,10 +717,10 @@ void tst_QXmppAtmManager::testMakeTrustDecisions()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
keysBeingAuthenticated),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
keysBeingDistrusted) }));
}
@@ -850,7 +852,7 @@ void tst_QXmppAtmManager::testHandleMessage()
m_manager.addKeys(ns_omemo,
senderJid,
{ senderKey },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
} else {
m_manager.addKeys(ns_omemo,
senderJid,
@@ -893,10 +895,10 @@ void tst_QXmppAtmManager::testHandleMessage()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
} else {
@@ -918,10 +920,10 @@ void tst_QXmppAtmManager::testHandleMessage()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
}
} else {
@@ -1006,14 +1008,14 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsNoKeys()
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoints
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
const QObject context;
@@ -1048,10 +1050,10 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsNoKeys()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys) }));
}
@@ -1065,31 +1067,31 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeys()
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("GaHysNhcfDSzG2q6OAThRGUpuFB9E7iCRR/1mK1TL+Q=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// keys of contact's endpoints
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1221,14 +1223,14 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysNoOwnEndpoints()
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1351,21 +1353,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysNoOwnEndpointsWithAuthent
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("GaHysNhcfDSzG2q6OAThRGUpuFB9E7iCRR/1mK1TL+Q=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1493,14 +1495,14 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysNoContactsWithAuthenticat
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// keys of contact's endpoints
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")) },
- QXmppTrustStorage::AutomaticallyDistrusted);
+ TrustLevel::AutomaticallyDistrusted);
int sentMessagesCount = 0;
const QObject context;
@@ -1586,21 +1588,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleOwnKeyDistrusted()
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1687,7 +1689,7 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleOwnKeyDistrusted()
QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")));
QVERIFY(futureTrustLevel.isFinished());
auto result = futureTrustLevel.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
}
void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeys()
@@ -1702,12 +1704,12 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeys()
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")),
QByteArray::fromBase64(QByteArrayLiteral("tfskruc1xcfC+VKzuqvLZUJVZccZX/Pg5j88ukpuY2M=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("GaHysNhcfDSzG2q6OAThRGUpuFB9E7iCRR/1mK1TL+Q=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// keys of contact's endpoints
m_manager.addKeys(
@@ -1715,19 +1717,19 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeys()
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")),
QByteArray::fromBase64(QByteArrayLiteral("T+dplAB8tGSdbYBbRiOm/jrS+8CPuzGHrH8ZmbjyvPo=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1830,14 +1832,14 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysNoOwnEndpoints()
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
const QObject context;
@@ -1873,21 +1875,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysNoOwnEndpointsWithAut
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("GaHysNhcfDSzG2q6OAThRGUpuFB9E7iCRR/1mK1TL+Q=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -1957,21 +1959,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleContactKeyDistrusted()
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
// key of contact's endpoint
m_manager.addKeys(
ns_omemo,
QStringLiteral("carol@example.net"),
{ QByteArray::fromBase64(QByteArrayLiteral("tVy3ygBnW4q6V2TYe8p4i904zD+x4rNMRegxPnPI7fw=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
int sentMessagesCount = 0;
const QObject context;
@@ -2031,7 +2033,7 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleContactKeyDistrusted()
QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")));
QVERIFY(futureTrustLevel.isFinished());
const auto result = futureTrustLevel.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
}
void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysDone()
@@ -2041,21 +2043,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysDone()
QByteArray::fromBase64(QByteArrayLiteral("0RcVsGk3LnpEFsqqztTzAgCDgVXlfa03paSqJFOOWOU=")));
QVERIFY(future.isFinished());
auto result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
future = m_manager.trustLevel(ns_omemo,
QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("tYn/wcIOxBSoW4W1UfPr/zgbLipBK2KsFfC7F1bzut0=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
future = m_manager.trustLevel(ns_omemo,
QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("4iBsyJPVAfNWM/OgyA9fasOvkJ8K1/0wuYpwVGw4Q5M=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
}
void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysDone()
@@ -2065,21 +2067,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysDone()
QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")));
QVERIFY(future.isFinished());
auto result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
future = m_manager.trustLevel(ns_omemo,
QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("mzDeKTQBVm1cTmzF9DjCGKa14pDADZOVLT9Kh7CK7AM=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
future = m_manager.trustLevel(ns_omemo,
QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
}
void tst_QXmppAtmManager::clearTrustStorage()
diff --git a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
index e0fab420..6696081d 100644
--- a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
+++ b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
@@ -8,6 +8,8 @@
#include "util.h"
+using namespace QXmpp;
+
static const char *ns_ox = "urn:xmpp:openpgp:0";
static const char *ns_omemo = "eu.siacs.conversations.axolotl";
@@ -37,26 +39,26 @@ void tst_QXmppTrustMemoryStorage::testSecurityPolicy()
auto future = m_trustStorage.securityPolicy(ns_ox);
QVERIFY(future.isFinished());
auto result = future.result();
- QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy);
+ QCOMPARE(result, NoSecurityPolicy);
- m_trustStorage.setSecurityPolicy(ns_omemo, QXmppTrustStorage::Toakafa);
+ m_trustStorage.setSecurityPolicy(ns_omemo, Toakafa);
future = m_trustStorage.securityPolicy(ns_ox);
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy);
+ QCOMPARE(result, NoSecurityPolicy);
future = m_trustStorage.securityPolicy(ns_omemo);
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Toakafa);
+ QCOMPARE(result, Toakafa);
m_trustStorage.resetSecurityPolicy(ns_omemo);
future = m_trustStorage.securityPolicy(ns_omemo);
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy);
+ QCOMPARE(result, NoSecurityPolicy);
}
void tst_QXmppTrustMemoryStorage::testOwnKeys()
@@ -112,7 +114,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// no automatically trusted and authenticated OMEMO keys
future = m_trustStorage.keys(ns_omemo,
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(future.isFinished());
result = future.result();
QVERIFY(result.isEmpty());
@@ -120,7 +122,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// no automatically trusted and authenticated OMEMO key from Alice
auto futureBool = m_trustStorage.hasKey(ns_omemo,
QStringLiteral("alice@example.org"),
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureBool.isFinished());
auto resultBool = futureBool.result();
QVERIFY(!resultBool);
@@ -136,39 +138,39 @@ void tst_QXmppTrustMemoryStorage::testKeys()
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")),
QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")) },
- QXmppTrustStorage::ManuallyTrusted);
+ TrustLevel::ManuallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_trustStorage.addKeys(
ns_ox,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")),
QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
QMultiHash<QString, QByteArray> automaticallyDistrustedKeys = { { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("WaAnpWyW1hnFooH3oJo9Ba5XYoksnLPeJRTAjxPbv38=")) },
@@ -187,22 +189,22 @@ 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 } };
+ QHash<QByteArray, TrustLevel> keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("WaAnpWyW1hnFooH3oJo9Ba5XYoksnLPeJRTAjxPbv38=")),
+ TrustLevel::AutomaticallyDistrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("/1eK3R2LtjPBT3el8f0q4DvzqUJSfFy5fkKkKPNFNYw=")),
+ TrustLevel::AutomaticallyDistrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")),
+ TrustLevel::ManuallyDistrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")),
+ TrustLevel::AutomaticallyTrusted } };
+ QHash<QByteArray, TrustLevel> keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")),
+ TrustLevel::AutomaticallyTrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")),
+ TrustLevel::ManuallyTrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")),
+ TrustLevel::ManuallyTrusted },
+ { QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")),
+ TrustLevel::Authenticated } };
// all OMEMO keys
future = m_trustStorage.keys(ns_omemo);
@@ -211,33 +213,33 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyTrusted,
+ TrustLevel::ManuallyTrusted,
manuallyTrustedKeys),
std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
// automatically trusted and authenticated OMEMO keys
future = m_trustStorage.keys(ns_omemo,
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(future.isFinished());
result = future.result();
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
// all OMEMO keys (via JIDs)
@@ -266,16 +268,16 @@ void tst_QXmppTrustMemoryStorage::testKeys()
keysAlice) }));
keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")),
- QXmppTrustStorage::AutomaticallyTrusted } };
+ TrustLevel::AutomaticallyTrusted } };
keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")),
- QXmppTrustStorage::AutomaticallyTrusted },
+ TrustLevel::AutomaticallyTrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")),
- QXmppTrustStorage::Authenticated } };
+ TrustLevel::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);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureForJids.isFinished());
resultForJids = futureForJids.result();
QCOMPARE(
@@ -290,7 +292,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// Alice's automatically trusted and authenticated OMEMO keys
futureForJids = m_trustStorage.keys(ns_omemo,
{ QStringLiteral("alice@example.org") },
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureForJids.isFinished());
resultForJids = futureForJids.result();
QCOMPARE(
@@ -302,7 +304,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// 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);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureBool.isFinished());
resultBool = futureBool.result();
QVERIFY(resultBool);
@@ -317,17 +319,17 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")) } };
keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("/1eK3R2LtjPBT3el8f0q4DvzqUJSfFy5fkKkKPNFNYw=")),
- QXmppTrustStorage::AutomaticallyDistrusted },
+ TrustLevel::AutomaticallyDistrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")),
- QXmppTrustStorage::ManuallyDistrusted } };
+ TrustLevel::ManuallyDistrusted } };
keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")),
- QXmppTrustStorage::AutomaticallyTrusted },
+ TrustLevel::AutomaticallyTrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")),
- QXmppTrustStorage::ManuallyTrusted },
+ TrustLevel::ManuallyTrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")),
- QXmppTrustStorage::ManuallyTrusted },
+ TrustLevel::ManuallyTrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")),
- QXmppTrustStorage::Authenticated } };
+ TrustLevel::Authenticated } };
// OMEMO keys after removal
future = m_trustStorage.keys(ns_omemo);
@@ -336,19 +338,19 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::AutomaticallyDistrusted,
+ TrustLevel::AutomaticallyDistrusted,
automaticallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyDistrusted,
+ TrustLevel::ManuallyDistrusted,
manuallyDistrustedKeys),
std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyTrusted,
+ TrustLevel::ManuallyTrusted,
manuallyTrustedKeys),
std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
// OMEMO keys after removal (via JIDs)
@@ -377,16 +379,16 @@ void tst_QXmppTrustMemoryStorage::testKeys()
keysAlice) }));
keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")),
- QXmppTrustStorage::AutomaticallyTrusted } };
+ TrustLevel::AutomaticallyTrusted } };
keysBob = { { QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")),
- QXmppTrustStorage::AutomaticallyTrusted },
+ TrustLevel::AutomaticallyTrusted },
{ QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")),
- QXmppTrustStorage::Authenticated } };
+ TrustLevel::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);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureForJids.isFinished());
resultForJids = futureForJids.result();
QCOMPARE(
@@ -398,7 +400,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// Alice's automatically trusted and authenticated OMEMO keys after removal
futureForJids = m_trustStorage.keys(ns_omemo,
{ QStringLiteral("alice@example.org") },
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureForJids.isFinished());
resultForJids = futureForJids.result();
QVERIFY(resultForJids.isEmpty());
@@ -412,13 +414,13 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::AutomaticallyTrusted,
+ TrustLevel::AutomaticallyTrusted,
automaticallyTrustedKeys),
std::pair(
- QXmppTrustStorage::ManuallyTrusted,
+ TrustLevel::ManuallyTrusted,
manuallyTrustedKeys),
std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
m_trustStorage.removeKeys(ns_omemo);
@@ -435,9 +437,9 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) } };
keysAlice = { { QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")),
- QXmppTrustStorage::Authenticated },
+ TrustLevel::Authenticated },
{ QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")),
- QXmppTrustStorage::Authenticated } };
+ TrustLevel::Authenticated } };
// remaining OX keys
future = m_trustStorage.keys(ns_ox);
@@ -446,7 +448,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
QCOMPARE(
result,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
// remaining OX keys (via JIDs)
@@ -489,7 +491,7 @@ void tst_QXmppTrustMemoryStorage::testKeys()
// no automatically trusted or authenticated OX key from Alice
futureBool = m_trustStorage.hasKey(ns_ox,
QStringLiteral("alice@example.org"),
- QXmppTrustStorage::AutomaticallyTrusted | QXmppTrustStorage::Authenticated);
+ TrustLevel::AutomaticallyTrusted | TrustLevel::Authenticated);
QVERIFY(futureBool.isFinished());
resultBool = futureBool.result();
QVERIFY(!resultBool);
@@ -501,26 +503,26 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
ns_ox,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")),
QByteArray::fromBase64(QByteArrayLiteral("JU4pT7Ivpigtl+7QE87Bkq4r/C/mhI1FCjY5Wmjbtwg=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")) },
- QXmppTrustStorage::ManuallyTrusted);
+ TrustLevel::ManuallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
auto future = m_trustStorage.trustLevel(
ns_omemo,
@@ -528,7 +530,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
auto result = future.result();
- QCOMPARE(result, QXmppTrustStorage::AutomaticallyTrusted);
+ QCOMPARE(result, TrustLevel::AutomaticallyTrusted);
m_trustStorage.setTrustLevel(
ns_omemo,
@@ -536,7 +538,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")) },
{ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")) } },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
future = m_trustStorage.trustLevel(
ns_omemo,
@@ -544,7 +546,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
future = m_trustStorage.trustLevel(
ns_omemo,
@@ -552,7 +554,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Authenticated);
+ QCOMPARE(result, TrustLevel::Authenticated);
// Set the trust level of a key that is not stored yet.
// It is added to the storage automatically.
@@ -560,7 +562,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
ns_omemo,
{ { QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("9w6oPjKyGSALd9gHq7sNOdOAkD5bHUVOKACNs89FjkA=")) } },
- QXmppTrustStorage::ManuallyTrusted);
+ TrustLevel::ManuallyTrusted);
future = m_trustStorage.trustLevel(
ns_omemo,
@@ -568,7 +570,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("9w6oPjKyGSALd9gHq7sNOdOAkD5bHUVOKACNs89FjkA=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyTrusted);
+ QCOMPARE(result, TrustLevel::ManuallyTrusted);
// Try to retrieve the trust level of a key that is not stored yet.
// The default value is returned.
@@ -578,7 +580,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("WXL4EDfzUGbVPQWjT9pmBeiCpCBzYZv3lUAaj+UbPyE=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Undecided);
+ QCOMPARE(result, TrustLevel::Undecided);
// Set the trust levels of all authenticated keys belonging to Alice and
// Bob.
@@ -586,8 +588,8 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
ns_omemo,
{ QStringLiteral("alice@example.org"),
QStringLiteral("bob@example.com") },
- QXmppTrustStorage::Authenticated,
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::Authenticated,
+ TrustLevel::ManuallyDistrusted);
future = m_trustStorage.trustLevel(
ns_omemo,
@@ -595,7 +597,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
future = m_trustStorage.trustLevel(
ns_omemo,
@@ -603,7 +605,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::ManuallyDistrusted);
+ QCOMPARE(result, TrustLevel::ManuallyDistrusted);
// Verify that the default trust level is returned for an unknown key.
future = m_trustStorage.trustLevel(
@@ -612,7 +614,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
QByteArray::fromBase64(QByteArrayLiteral("wE06Gwf8f4DvDLFDoaCsGs8ibcUjf84WIOA2FAjPI3o=")));
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Undecided);
+ QCOMPARE(result, TrustLevel::Undecided);
m_trustStorage.removeKeys(ns_ox);
m_trustStorage.removeKeys(ns_omemo);
@@ -620,8 +622,8 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
void tst_QXmppTrustMemoryStorage::testResetAll()
{
- m_trustStorage.setSecurityPolicy(ns_ox, QXmppTrustStorage::Toakafa);
- m_trustStorage.setSecurityPolicy(ns_omemo, QXmppTrustStorage::Toakafa);
+ m_trustStorage.setSecurityPolicy(ns_ox, Toakafa);
+ m_trustStorage.setSecurityPolicy(ns_omemo, Toakafa);
m_trustStorage.setOwnKey(ns_ox, QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")));
m_trustStorage.setOwnKey(ns_omemo, QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")));
@@ -636,51 +638,51 @@ void tst_QXmppTrustMemoryStorage::testResetAll()
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")) },
- QXmppTrustStorage::ManuallyDistrusted);
+ TrustLevel::ManuallyDistrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("Ciemp4ZNzRJxnRD+k28vAie0kXJrwl4IrbfDy7n6OxE=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("rvSXBRd+EICMhQvVgcREQJxxP+T4EBmai4mYHBfJQGg=")) },
- QXmppTrustStorage::AutomaticallyTrusted);
+ TrustLevel::AutomaticallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("tCP1CI3pqSTVGzFYFyPYUMfMZ9Ck/msmfD0wH/VtJBM=")),
QByteArray::fromBase64(QByteArrayLiteral("2fhJtrgoMJxfLI3084/YkYh9paqiSiLFDVL2m0qAgX4=")) },
- QXmppTrustStorage::ManuallyTrusted);
+ TrustLevel::ManuallyTrusted);
m_trustStorage.addKeys(
ns_omemo,
QStringLiteral("bob@example.com"),
{ QByteArray::fromBase64(QByteArrayLiteral("YjVI04NcbTPvXLaA95RO84HPcSvyOgEZ2r5cTyUs0C8=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_trustStorage.addKeys(
ns_ox,
QStringLiteral("alice@example.org"),
{ QByteArray::fromBase64(QByteArrayLiteral("aFABnX7Q/rbTgjBySYzrT2FsYCVYb49mbca5yB734KQ=")),
QByteArray::fromBase64(QByteArrayLiteral("IhpPjiKLchgrAG5cpSfTvdzPjZ5v6vTOluHEUehkgCA=")) },
- QXmppTrustStorage::Authenticated);
+ TrustLevel::Authenticated);
m_trustStorage.resetAll(ns_omemo);
auto future = m_trustStorage.securityPolicy(ns_omemo);
QVERIFY(future.isFinished());
auto result = future.result();
- QCOMPARE(result, QXmppTrustStorage::NoSecurityPolicy);
+ QCOMPARE(result, NoSecurityPolicy);
future = m_trustStorage.securityPolicy(ns_ox);
QVERIFY(future.isFinished());
result = future.result();
- QCOMPARE(result, QXmppTrustStorage::Toakafa);
+ QCOMPARE(result, Toakafa);
auto futureKey = m_trustStorage.ownKey(ns_omemo);
QVERIFY(futureKey.isFinished());
@@ -708,7 +710,7 @@ void tst_QXmppTrustMemoryStorage::testResetAll()
QCOMPARE(
resultKeys,
QHash({ std::pair(
- QXmppTrustStorage::Authenticated,
+ TrustLevel::Authenticated,
authenticatedKeys) }));
}