aboutsummaryrefslogtreecommitdiff
path: root/autotests/testolmaccount.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-31 18:58:27 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-31 18:58:27 +0200
commit21ae4eca4c06e500ec04a52ad42772bf8e8e9b6f (patch)
tree271fe41d8d9d0a5eecfd07d16973c30b4b1c9e8c /autotests/testolmaccount.cpp
parent42811660094c88a4a1bfa8bd8ace5f4b148c246a (diff)
downloadlibquotient-21ae4eca4c06e500ec04a52ad42772bf8e8e9b6f.tar.gz
libquotient-21ae4eca4c06e500ec04a52ad42772bf8e8e9b6f.zip
Tweak QOlmAccount and data structures around
This is mainly to plug the definition of a string-to-variant map for one-time keys (see https://spec.matrix.org/v1.2/client-server-api/#key-algorithms) into the CS API generated code (see the "shortcut OneTimeKeys" commit for gtad.yaml); but along with it came considerable streamlining of code in qolmaccount.cpp. Using std::variant to store that map also warranted converters.h to gain support for that type (even wider than toJson() that is already in dev - a non-trivial merge from dev is in order).
Diffstat (limited to 'autotests/testolmaccount.cpp')
-rw-r--r--autotests/testolmaccount.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index e31ff6d3..c85718dd 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -198,7 +198,7 @@ void TestOlmAccount::uploadIdentityKey()
QVERIFY(idKeys.curve25519.size() > 10);
- OneTimeKeys unused;
+ UnsignedOneTimeKeys unused;
auto request = olmAccount->createUploadKeyRequest(unused);
connect(request, &BaseJob::result, this, [request, conn] {
QCOMPARE(request->oneTimeKeyCounts().size(), 0);
@@ -221,7 +221,7 @@ void TestOlmAccount::uploadOneTimeKeys()
auto oneTimeKeys = olmAccount->oneTimeKeys();
- QHash<QString, QVariant> oneTimeKeysHash;
+ OneTimeKeys oneTimeKeysHash;
const auto curve = oneTimeKeys.curve25519();
for (const auto &[keyId, key] : asKeyValueRange(curve)) {
oneTimeKeysHash["curve25519:"+keyId] = key;
@@ -247,12 +247,10 @@ void TestOlmAccount::uploadSignedOneTimeKeys()
QCOMPARE(nKeys, 5);
auto oneTimeKeys = olmAccount->oneTimeKeys();
- QHash<QString, QVariant> oneTimeKeysHash;
+ OneTimeKeys oneTimeKeysHash;
const auto signedKey = olmAccount->signOneTimeKeys(oneTimeKeys);
for (const auto &[keyId, key] : asKeyValueRange(signedKey)) {
- QVariant var;
- var.setValue(key);
- oneTimeKeysHash[keyId] = var;
+ oneTimeKeysHash[keyId] = key;
}
auto request = new UploadKeysJob(none, oneTimeKeysHash);
connect(request, &BaseJob::result, this, [request, nKeys, conn] {
@@ -410,11 +408,9 @@ void TestOlmAccount::claimKeys()
// The key is the one bob sent.
const auto& oneTimeKey =
job->oneTimeKeys().value(userId).value(deviceId);
- QVERIFY(oneTimeKey.canConvert<QVariantMap>());
-
- const auto varMap = oneTimeKey.toMap();
- QVERIFY(std::any_of(varMap.constKeyValueBegin(),
- varMap.constKeyValueEnd(), [](const auto& kv) {
+ QVERIFY(std::any_of(oneTimeKey.constKeyValueBegin(),
+ oneTimeKey.constKeyValueEnd(),
+ [](const auto& kv) {
return kv.first.startsWith(
SignedCurve25519Key);
}));