diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-01-24 01:45:43 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:34:52 +0100 |
commit | 8706c055e69b01097b702403aaa0d222e5ab0d29 (patch) | |
tree | 063534b589d598a14af2018c516ce5eb992399ff /autotests/testgroupsession.cpp | |
parent | c8d67f737e84bbec98a54fc19a8aa56dbc39d542 (diff) | |
download | libquotient-8706c055e69b01097b702403aaa0d222e5ab0d29.tar.gz libquotient-8706c055e69b01097b702403aaa0d222e5ab0d29.zip |
Implement outboundsession
Diffstat (limited to 'autotests/testgroupsession.cpp')
-rw-r--r-- | autotests/testgroupsession.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 |