aboutsummaryrefslogtreecommitdiff
path: root/autotests/testolmaccount.cpp
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-01-27 20:16:59 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:34:52 +0100
commit5910689306149cacf3ac644d3ea42e10f889e3fe (patch)
treecf72ee6902237c794226ace2c26729585dae6bdb /autotests/testolmaccount.cpp
parent7ad805492f8b42a4bc854313695a912c89019957 (diff)
downloadlibquotient-5910689306149cacf3ac644d3ea42e10f889e3fe.tar.gz
libquotient-5910689306149cacf3ac644d3ea42e10f889e3fe.zip
Add encrypted file struct
Diffstat (limited to 'autotests/testolmaccount.cpp')
-rw-r--r--autotests/testolmaccount.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index 9a8e253c..2fac53bd 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -5,6 +5,7 @@
#include "testolmaccount.h"
#include "olm/qolmaccount.h"
#include "csapi/definitions/device_keys.h"
+#include "events/encryptedfile.h"
using namespace Quotient;
@@ -132,4 +133,33 @@ void TestOlmAccount::deviceKeys()
// QCOMPARE(device2.unsignedInfo.deviceDisplayName, "Alice's mobile phone");
}
+void TestOlmAccount::encryptedFile()
+{
+ auto doc = QJsonDocument::fromJson(R"({
+ "url": "mxc://example.org/FHyPlCeYUSFFxlgbQYZmoEoe",
+ "v": "v2",
+ "key": {
+ "alg": "A256CTR",
+ "ext": true,
+ "k": "aWF6-32KGYaC3A_FEUCk1Bt0JA37zP0wrStgmdCaW-0",
+ "key_ops": ["encrypt","decrypt"],
+ "kty": "oct"
+ },
+ "iv": "w+sE15fzSc0AAAAAAAAAAA",
+ "hashes": {
+ "sha256": "fdSLu/YkRx3Wyh3KQabP3rd6+SFiKg5lsJZQHtkSAYA"
+ }})");
+
+ EncryptedFile file;
+ JsonObjectConverter<EncryptedFile>::fillFrom(doc.object(), file);
+
+ QCOMPARE(file.v, "v2");
+ QCOMPARE(file.iv, "w+sE15fzSc0AAAAAAAAAAA");
+ QCOMPARE(file.hashes["sha256"], "fdSLu/YkRx3Wyh3KQabP3rd6+SFiKg5lsJZQHtkSAYA");
+ QCOMPARE(file.key.alg, "A256CTR");
+ QCOMPARE(file.key.ext, true);
+ QCOMPARE(file.key.k, "aWF6-32KGYaC3A_FEUCk1Bt0JA37zP0wrStgmdCaW-0");
+ QCOMPARE(file.key.keyOps.count(), 2);
+ QCOMPARE(file.key.kty, "oct");
+}
QTEST_MAIN(TestOlmAccount)