aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-05-06 01:08:53 +0200
committerTobias Fella <fella@posteo.de>2021-12-01 21:34:52 +0100
commit0a75a095665101d4ffcbec10b43633eee5a0d6d3 (patch)
treebf88e94bf0b454fa8d409acd49c1cdc3f4658d43
parentc2836e007e2d46c0c20270b99ede5b78d2c7170b (diff)
downloadlibquotient-0a75a095665101d4ffcbec10b43633eee5a0d6d3.tar.gz
libquotient-0a75a095665101d4ffcbec10b43633eee5a0d6d3.zip
Fix everything
-rw-r--r--autotests/testolmaccount.cpp3
-rw-r--r--autotests/testolmaccount.h2
-rw-r--r--autotests/testolmsession.cpp3
-rw-r--r--autotests/testolmsession.h2
-rw-r--r--autotests/testolmutility.cpp2
-rw-r--r--lib/connection.cpp5
-rw-r--r--lib/connection.h5
-rw-r--r--lib/connectiondata.cpp6
-rw-r--r--lib/connectiondata.h1
-rw-r--r--lib/crypto/qolmaccount.cpp6
-rw-r--r--lib/crypto/qolmaccount.h2
-rw-r--r--lib/crypto/qolmoutboundsession.h2
12 files changed, 12 insertions, 27 deletions
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index eb44791a..1c296db9 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -6,6 +6,7 @@
#include "crypto/qolmaccount.h"
#include "connection.h"
#include "events/encryptedfile.h"
+#include "networkaccessmanager.h"
using namespace Quotient;
@@ -164,8 +165,8 @@ void TestOlmAccount::encryptedFile()
}
#define CREATE_CONNECTION(VAR, USERNAME, SECRET, DEVICE_NAME) \
+ NetworkAccessManager::instance()->ignoreSslErrors(true); \
auto VAR = std::make_shared<Connection>(); \
- VAR->ignoreSslErrors(true); \
(VAR) ->resolveServer("@alice:localhost:" + QString::number(443)); \
connect( (VAR) .get(), &Connection::loginFlowsChanged, this, [this, VAR ] () { \
(VAR) ->loginWithPassword( (USERNAME) , SECRET , DEVICE_NAME , ""); \
diff --git a/autotests/testolmaccount.h b/autotests/testolmaccount.h
index 8901f095..bab9eed2 100644
--- a/autotests/testolmaccount.h
+++ b/autotests/testolmaccount.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#include <QTest>
+#include <QtTest/QtTest>
#include <QString>
namespace Quotient {
diff --git a/autotests/testolmsession.cpp b/autotests/testolmsession.cpp
index 0803cc6d..dba78277 100644
--- a/autotests/testolmsession.cpp
+++ b/autotests/testolmsession.cpp
@@ -26,7 +26,8 @@ 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() != QOlmMessage::PreKey) {
- QFAIL("Wrong first message type received, can't create session");
+ // We can't call QFail here because it's an helper function returning a value
+ throw "Wrong first message type received, can't create session";
}
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));
diff --git a/autotests/testolmsession.h b/autotests/testolmsession.h
index bd670c9b..9a5798fa 100644
--- a/autotests/testolmsession.h
+++ b/autotests/testolmsession.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#include <QTest>
+#include <QtTest/QtTest>
class TestOlmSession : public QObject
{
diff --git a/autotests/testolmutility.cpp b/autotests/testolmutility.cpp
index 1d9978d3..2eec7e00 100644
--- a/autotests/testolmutility.cpp
+++ b/autotests/testolmutility.cpp
@@ -118,7 +118,7 @@ void TestOlmUtility::validUploadKeysRequest()
}
};
- DeviceKeys deviceKeys = alice->getDeviceKeys();
+ DeviceKeys deviceKeys = alice->deviceKeys();
QCOMPARE(QJsonDocument(toJson(deviceKeys)).toJson(QJsonDocument::Compact),
QJsonDocument(body).toJson(QJsonDocument::Compact));
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 62427ae1..704bc1b4 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -572,11 +572,6 @@ void Connection::sync(int timeout)
});
}
-void Connection::ignoreSslErrors(bool ignore)
-{
- connectionData()->ignoreSslErrors(ignore);
-}
-
void Connection::syncLoop(int timeout)
{
if (d->syncLoopConnection && d->syncTimeout == timeout) {
diff --git a/lib/connection.h b/lib/connection.h
index 93e22da2..6729b23d 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -476,11 +476,6 @@ public:
setUserFactory(defaultUserFactory<T>());
}
- /// Ignore ssl errors (usefull for automated testing with local synapse
- /// instance).
- /// \internal
- void ignoreSslErrors(bool ignore);
-
public Q_SLOTS:
/// \brief Set the homeserver base URL and retrieve its login flows
///
diff --git a/lib/connectiondata.cpp b/lib/connectiondata.cpp
index 672feb06..87ad4577 100644
--- a/lib/connectiondata.cpp
+++ b/lib/connectiondata.cpp
@@ -128,12 +128,6 @@ bool ConnectionData::needsToken(const QString& requestName) const
!= d->needToken.cend();
}
-void ConnectionData::ignoreSslErrors(bool ignore) const
-{
- auto quotientNam = static_cast<NetworkAccessManager>(nam());
- quotientNam.ignoreSslErrors(ignore);
-}
-
void ConnectionData::setDeviceId(const QString& deviceId)
{
d->deviceId = deviceId;
diff --git a/lib/connectiondata.h b/lib/connectiondata.h
index 203dc9e8..e16a2dac 100644
--- a/lib/connectiondata.h
+++ b/lib/connectiondata.h
@@ -29,7 +29,6 @@ public:
bool needsToken(const QString& requestName) const;
QNetworkAccessManager* nam() const;
- void ignoreSslErrors(bool ignore = true) const;
void setBaseUrl(QUrl baseUrl);
void setToken(QByteArray accessToken);
void setDeviceId(const QString& deviceId);
diff --git a/lib/crypto/qolmaccount.cpp b/lib/crypto/qolmaccount.cpp
index 8b964c9f..9368de4f 100644
--- a/lib/crypto/qolmaccount.cpp
+++ b/lib/crypto/qolmaccount.cpp
@@ -243,10 +243,10 @@ DeviceKeys QOlmAccount::deviceKeys() const
UploadKeysJob *QOlmAccount::createUploadKeyRequest(const OneTimeKeys &oneTimeKeys)
{
- auto deviceKeys = deviceKeys();
+ auto keys = deviceKeys();
if (oneTimeKeys.curve25519().isEmpty()) {
- return new UploadKeysJob(deviceKeys);
+ return new UploadKeysJob(keys);
}
// Sign & append the one time keys.
@@ -256,7 +256,7 @@ UploadKeysJob *QOlmAccount::createUploadKeyRequest(const OneTimeKeys &oneTimeKey
oneTimeKeysSigned[keyId] = QVariant::fromValue(key);
}
- return new UploadKeysJob(deviceKeys, oneTimeKeysSigned);
+ return new UploadKeysJob(keys, oneTimeKeysSigned);
}
std::variant<std::unique_ptr<QOlmSession>, QOlmError> QOlmAccount::createInboundSession(const QOlmMessage &preKeyMessage)
diff --git a/lib/crypto/qolmaccount.h b/lib/crypto/qolmaccount.h
index c93a8354..f3ca82f0 100644
--- a/lib/crypto/qolmaccount.h
+++ b/lib/crypto/qolmaccount.h
@@ -73,7 +73,7 @@ public:
UploadKeysJob *createUploadKeyRequest(const OneTimeKeys &oneTimeKeys);
- DeviceKeys getDeviceKeys() const;
+ DeviceKeys deviceKeys() const;
//! Remove the one time key used to create the supplied session.
[[nodiscard]] std::optional<QOlmError> removeOneTimeKeys(const std::unique_ptr<QOlmSession> &session) const;
diff --git a/lib/crypto/qolmoutboundsession.h b/lib/crypto/qolmoutboundsession.h
index 201a178a..4e06561e 100644
--- a/lib/crypto/qolmoutboundsession.h
+++ b/lib/crypto/qolmoutboundsession.h
@@ -26,7 +26,7 @@ public:
std::variant<QByteArray, QOlmError> pickle(const PicklingMode &mode);
//! Deserialises from encrypted Base64 that was previously obtained by
//! pickling a `QOlmOutboundGroupSession`.
- static std::variant<std::unique_ptr<QOlmOutboundGroupSession>, QOlmError> unpickle(const QByteArray &pickled, const PicklingMode &mode);
+ static std::variant<std::unique_ptr<QOlmOutboundGroupSession>, QOlmError> unpickle(QByteArray &pickled, const PicklingMode &mode);
//! Encrypts a plaintext message using the session.
std::variant<QByteArray, QOlmError> encrypt(const QString &plaintext);