aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-01-27 16:12:17 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:34:52 +0100
commitefe7e4ebc9c71f68d29c5c1a5a6bacbaea6fd146 (patch)
treea496c2f76e9cbdeee700791baf98dbe8f23e3501
parent583d484b2dc27d3216706a1e0858b794d4c5fe19 (diff)
downloadlibquotient-efe7e4ebc9c71f68d29c5c1a5a6bacbaea6fd146.tar.gz
libquotient-efe7e4ebc9c71f68d29c5c1a5a6bacbaea6fd146.zip
Disable olm test when disabling encryption
-rw-r--r--autotests/CMakeLists.txt8
-rw-r--r--autotests/testgroupsession.cpp2
-rw-r--r--autotests/testgroupsession.h2
-rw-r--r--autotests/testolmaccount.cpp2
-rw-r--r--autotests/testolmaccount.h2
-rw-r--r--autotests/testolmsession.cpp8
-rw-r--r--autotests/testolmsession.h2
7 files changed, 5 insertions, 21 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index f35890a5..6afdf8cc 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -12,6 +12,8 @@ function(QUOTIENT_ADD_TEST)
endfunction()
quotient_add_test(NAME callcandidateseventtest)
-quotient_add_test(NAME testolmaccount)
-quotient_add_test(NAME testgroupsession)
-quotient_add_test(NAME testolmsession)
+if(${PROJECT_NAME}_ENABLE_E2EE)
+ quotient_add_test(NAME testolmaccount)
+ quotient_add_test(NAME testgroupsession)
+ quotient_add_test(NAME testolmsession)
+endif()
diff --git a/autotests/testgroupsession.cpp b/autotests/testgroupsession.cpp
index a99172d7..23c5bf8f 100644
--- a/autotests/testgroupsession.cpp
+++ b/autotests/testgroupsession.cpp
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#ifdef Quotient_E2EE_ENABLED
#include "testgroupsession.h"
#include "olm/qolminboundsession.h"
#include "olm/qolmoutboundsession.h"
@@ -54,4 +53,3 @@ void TestOlmSession::groupSessionCryptoValid()
QCOMPARE(0, decryptionResult.second);
}
QTEST_MAIN(TestOlmSession)
-#endif
diff --git a/autotests/testgroupsession.h b/autotests/testgroupsession.h
index c9192990..27f34bec 100644
--- a/autotests/testgroupsession.h
+++ b/autotests/testgroupsession.h
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#ifdef Quotient_E2EE_ENABLED
#include <QtTest/QtTest>
class TestOlmSession : public QObject
@@ -13,4 +12,3 @@ private Q_SLOTS:
void groupSessionPicklingValid();
void groupSessionCryptoValid();
};
-#endif
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index 75102c32..9f85e77e 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#ifdef Quotient_E2EE_ENABLED
#include "testolmaccount.h"
#include "olm/qolmaccount.h"
@@ -69,4 +68,3 @@ void TestOlmAccount::oneTimeKeysValid()
}
QTEST_MAIN(TestOlmAccount)
-#endif
diff --git a/autotests/testolmaccount.h b/autotests/testolmaccount.h
index c3297b5f..e7b32b8b 100644
--- a/autotests/testolmaccount.h
+++ b/autotests/testolmaccount.h
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#ifdef Quotient_E2EE_ENABLED
#include <QtTest/QtTest>
class TestOlmAccount : public QObject
@@ -16,4 +15,3 @@ private Q_SLOTS:
void oneTimeKeysValid();
//void removeOneTimeKeys();
};
-#endif
diff --git a/autotests/testolmsession.cpp b/autotests/testolmsession.cpp
index 77ba35ef..da0e36e3 100644
--- a/autotests/testolmsession.cpp
+++ b/autotests/testolmsession.cpp
@@ -7,7 +7,6 @@
using namespace Quotient;
-#ifdef Quotient_E2EE_ENABLED
std::pair<std::unique_ptr<QOlmSession>, std::unique_ptr<QOlmSession>> createSessionPair()
{
QByteArray pickledAccountA("eOBXIKivUT6YYowRH031BNv7zNmzqM5B7CpXdyeaPvala5mt7/OeqrG1qVA7vA1SYloFyvJPIy0QNkD3j1HiPl5vtZHN53rtfZ9exXDok03zjmssqn4IJsqcA7Fbo1FZeKafG0NFcWwCPTdmcV7REqxjqGm3I4K8MQFa45AdTGSUu2C12cWeOcbSMlcINiMral+Uyah1sgPmLJ18h1qcnskXUXQvpffZ5DiUw1Iz5zxnwOQF1GVyowPJD7Zdugvj75RQnDxAn6CzyvrY2k2CuedwqDC3fIXM2xdUNWttW4nC2g4InpBhCVvNwhZYxlUb5BUEjmPI2AB3dAL5ry6o9MFncmbN6x5x");
@@ -32,19 +31,15 @@ std::pair<std::unique_ptr<QOlmSession>, std::unique_ptr<QOlmSession>> createSess
auto inbound = std::get<std::unique_ptr<QOlmSession>>(accountB.createInboundSession(preKey));
return std::make_pair<std::unique_ptr<QOlmSession>, std::unique_ptr<QOlmSession>>(std::move(inbound), std::move(outbound));
}
-#endif
void TestOlmSession::olmOutboundSessionCreation()
{
-#ifdef Quotient_E2EE_ENABLED
const auto [_, outboundSession] = createSessionPair();
QCOMPARE(0, outboundSession->hasReceivedMessage());
-#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) {
@@ -55,12 +50,10 @@ void TestOlmSession::olmEncryptDecrypt()
const auto decrypted = std::get<QString>(inboundSession->decrypt(encrypted));
QCOMPARE(decrypted, "Hello world!");
-#endif
}
void TestOlmSession::correctSessionOrdering()
{
-#ifdef Quotient_E2EE_ENABLED
// n0W5IJ2ZmaI9FxKRj/wohUQ6WEU0SfoKsgKKHsr4VbM
auto session1 = std::get<std::unique_ptr<QOlmSession>>(QOlmSession::unpickle("7g5cfQRsDk2ROXf9S01n2leZiFRon+EbvXcMOADU0UGvlaV6t/0ihD2/0QGckDIvbmE1aV+PxB0zUtHXh99bI/60N+PWkCLA84jEY4sz3d45ui/TVoFGLDHlymKxvlj7XngXrbtlxSkVntsPzDiNpKEXCa26N2ubKpQ0fbjrV5gbBTYWfU04DXHPXFDTksxpNALYt/h0eVMVhf6hB0ZzpLBsOG0mpwkLufwub0CuDEDGGmRddz3TcNCLq5NnI8R9udDWvHAkTS1UTbHuIf/y6cZg875nJyXpAvd8/XhL8TOo8ot2sE1fElBa4vrH/m9rBQMC1GPkhLBIizmY44C+Sq9PQRnF+uCZ", Unencrypted{}));
// +9pHJhP3K4E5/2m8PYBPLh8pS9CJodwUOh8yz3mnmw0
@@ -81,7 +74,6 @@ void TestOlmSession::correctSessionOrdering()
QCOMPARE(sessionList[0]->sessionId(), session2Id);
QCOMPARE(sessionList[1]->sessionId(), session3Id);
QCOMPARE(sessionList[2]->sessionId(), session1Id);
-#endif
}
QTEST_MAIN(TestOlmSession)
diff --git a/autotests/testolmsession.h b/autotests/testolmsession.h
index c03b7b6a..9a5798fa 100644
--- a/autotests/testolmsession.h
+++ b/autotests/testolmsession.h
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#ifdef Quotient_E2EE_ENABLED
#include <QtTest/QtTest>
class TestOlmSession : public QObject
@@ -13,4 +12,3 @@ private Q_SLOTS:
void olmEncryptDecrypt();
void correctSessionOrdering();
};
-#endif