aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
Diffstat (limited to 'autotests')
-rw-r--r--autotests/CMakeLists.txt1
-rw-r--r--autotests/testgroupsession.cpp39
-rw-r--r--autotests/testgroupsession.h15
-rw-r--r--autotests/testolmaccount.cpp2
4 files changed, 57 insertions, 0 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 07c22ad6..31cdb446 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -13,3 +13,4 @@ endfunction()
quotient_add_test(NAME callcandidateseventtest)
quotient_add_test(NAME testolmaccount)
+quotient_add_test(NAME testgroupsession)
diff --git a/autotests/testgroupsession.cpp b/autotests/testgroupsession.cpp
new file mode 100644
index 00000000..02892366
--- /dev/null
+++ b/autotests/testgroupsession.cpp
@@ -0,0 +1,39 @@
+// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifdef Quotient_E2EE_ENABLED
+#include "testgroupsession.h"
+#include "olm/qolminboundsession.h"
+#include "olm/qolmoutboundsession.h"
+#include "olm/utils.h"
+
+using namespace Quotient;
+
+void TestOlmSession::groupSessionPicklingValid()
+{
+ auto ogs = std::get<QOlmOutboundGroupSession>(QOlmOutboundGroupSession::create());
+ const auto ogsId = std::get<QByteArray>(ogs.sessionId());
+ QVERIFY(QByteArray::fromBase64Encoding(ogsId).decodingStatus == QByteArray::Base64DecodingStatus::Ok);
+ QCOMPARE(0, ogs.sessionMessageIndex());
+
+ auto ogsPickled = std::get<QByteArray>(ogs.pickle(Unencrypted {}));
+ ogs = std::get<QOlmOutboundGroupSession>(QOlmOutboundGroupSession::unpickle(ogsPickled, Unencrypted {}));
+ QCOMPARE(ogsId, std::get<QByteArray>(ogs.sessionId()));
+
+ qDebug() << std::get<QByteArray>(ogs.sessionKey());
+ auto igs = std::get<QOlmInboundGroupSession>(QOlmInboundGroupSession::create(std::get<QByteArray>(ogs.sessionKey())));
+ const auto igsId = std::get<QByteArray>(igs.sessionId());
+ // ID is valid base64?
+ QVERIFY(QByteArray::fromBase64Encoding(igsId).decodingStatus == QByteArray::Base64DecodingStatus::Ok);
+
+ //// no messages have been sent yet
+ QCOMPARE(0, igs.firstKnownIndex());
+
+ auto igsPickled = std::get<QByteArray>(igs.pickle(Unencrypted {}));
+ igs = std::get<QOlmInboundGroupSession>(QOlmInboundGroupSession::unpickle(igsPickled, Unencrypted {}));
+ QCOMPARE(igsId, std::get<QByteArray>(igs.sessionId()));
+}
+
+QTEST_MAIN(TestOlmSession)
+#endif
diff --git a/autotests/testgroupsession.h b/autotests/testgroupsession.h
new file mode 100644
index 00000000..28ebf4c9
--- /dev/null
+++ b/autotests/testgroupsession.h
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifdef Quotient_E2EE_ENABLED
+#include <QtTest/QtTest>
+
+class TestOlmSession : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void groupSessionPicklingValid();
+};
+#endif
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index 549f07ea..45a7e3a5 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -6,6 +6,8 @@
#include "testolmaccount.h"
#include "olm/qolmaccount.h"
+using namespace Quotient;
+
void TestOlmAccount::pickleUnpickedTest()
{
auto olmAccount = QOlmAccount::create().value();