aboutsummaryrefslogtreecommitdiff
path: root/autotests/testolmsession.cpp
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-01-27 02:26:23 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:34:52 +0100
commit069602584e0f3ec10a26380af69b95f5da11a8b7 (patch)
tree9249878206903577a57ede697beb411f8f586556 /autotests/testolmsession.cpp
parentf3fdd967d544650f9af8aadbaddfcf6d8a9fe957 (diff)
downloadlibquotient-069602584e0f3ec10a26380af69b95f5da11a8b7.tar.gz
libquotient-069602584e0f3ec10a26380af69b95f5da11a8b7.zip
Add more test and methods in session handling
Diffstat (limited to 'autotests/testolmsession.cpp')
-rw-r--r--autotests/testolmsession.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/autotests/testolmsession.cpp b/autotests/testolmsession.cpp
index 6fa2a380..2f7a82e9 100644
--- a/autotests/testolmsession.cpp
+++ b/autotests/testolmsession.cpp
@@ -26,7 +26,7 @@ std::pair<std::unique_ptr<QOlmSession>, std::unique_ptr<QOlmSession>> createSess
const auto preKey = outbound->encrypt(""); // Payload does not matter for PreKey
- if (preKey.type() != Message::General) {
+ if (preKey.type() != Message::PreKey) {
throw "Wrong first message type received, can't create session";
}
auto inbound = std::get<std::unique_ptr<QOlmSession>>(accountB.createInboundSession(preKey));
@@ -42,4 +42,20 @@ void TestOlmSession::olmOutboundSessionCreation()
#endif
}
+void TestOlmSession::olmEncryptDecrypt()
+{
+#ifdef Quotient_E2EE_ENABLED
+ const auto [inboundSession, outboundSession] = createSessionPair();
+ const auto encrypted = outboundSession->encrypt("Hello world!");
+ if (encrypted.type() == Message::PreKey) {
+ Message m(encrypted); // clone
+ QVERIFY(std::get<bool>(inboundSession->matchesInboundSession(m)));
+ }
+
+ //const auto decrypted = inboundSession->decrypt(encrypted);
+
+ //QCOMPARE(decrypted, "Hello world!");
+#endif
+}
+
QTEST_MAIN(TestOlmSession)