aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
Diffstat (limited to 'autotests')
-rw-r--r--autotests/testgroupsession.cpp17
-rw-r--r--autotests/testolmaccount.cpp6
-rw-r--r--autotests/testolmsession.cpp14
-rw-r--r--autotests/testolmutility.cpp15
4 files changed, 30 insertions, 22 deletions
diff --git a/autotests/testgroupsession.cpp b/autotests/testgroupsession.cpp
index 3c329a8a..1054a160 100644
--- a/autotests/testgroupsession.cpp
+++ b/autotests/testgroupsession.cpp
@@ -16,11 +16,13 @@ void TestGroupSession::groupSessionPicklingValid()
QVERIFY(QByteArray::fromBase64(ogsId).size() > 0);
QCOMPARE(0, ogs->sessionMessageIndex());
- auto ogsPickled = ogs->pickle(Unencrypted {}).value();
- auto ogs2 = QOlmOutboundGroupSession::unpickle(ogsPickled, Unencrypted {}).value();
+ auto&& ogsPickled = ogs->pickle(Unencrypted {});
+ auto ogs2 =
+ QOlmOutboundGroupSession::unpickle(std::move(ogsPickled), Unencrypted{})
+ .value();
QCOMPARE(ogsId, ogs2->sessionId());
- auto igs = QOlmInboundGroupSession::create(ogs->sessionKey().value());
+ auto igs = QOlmInboundGroupSession::create(ogs->sessionKey()).value();
const auto igsId = igs->sessionId();
// ID is valid base64?
QVERIFY(QByteArray::fromBase64(igsId).size() > 0);
@@ -29,18 +31,19 @@ void TestGroupSession::groupSessionPicklingValid()
QCOMPARE(0, igs->firstKnownIndex());
auto igsPickled = igs->pickle(Unencrypted {});
- igs = QOlmInboundGroupSession::unpickle(igsPickled, Unencrypted {}).value();
+ igs = QOlmInboundGroupSession::unpickle(std::move(igsPickled), Unencrypted{})
+ .value();
QCOMPARE(igsId, igs->sessionId());
}
void TestGroupSession::groupSessionCryptoValid()
{
auto ogs = QOlmOutboundGroupSession::create();
- auto igs = QOlmInboundGroupSession::create(ogs->sessionKey().value());
+ auto igs = QOlmInboundGroupSession::create(ogs->sessionKey()).value();
QCOMPARE(ogs->sessionId(), igs->sessionId());
- const auto plainText = QStringLiteral("Hello world!");
- const auto ciphertext = ogs->encrypt(plainText).value();
+ const auto plainText = "Hello world!";
+ const auto ciphertext = ogs->encrypt(plainText);
// ciphertext valid base64?
QVERIFY(QByteArray::fromBase64(ciphertext).size() > 0);
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index a41af268..53a0c955 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -23,9 +23,11 @@ void TestOlmAccount::pickleUnpickledTest()
QOlmAccount olmAccount(QStringLiteral("@foo:bar.com"), QStringLiteral("QuotientTestDevice"));
olmAccount.createNewAccount();
auto identityKeys = olmAccount.identityKeys();
- auto pickled = olmAccount.pickle(Unencrypted{}).value();
+ auto pickled = olmAccount.pickle(Unencrypted{});
QOlmAccount olmAccount2(QStringLiteral("@foo:bar.com"), QStringLiteral("QuotientTestDevice"));
- olmAccount2.unpickle(pickled, Unencrypted{});
+ auto unpickleResult = olmAccount2.unpickle(std::move(pickled),
+ Unencrypted{});
+ QCOMPARE(unpickleResult, 0);
auto identityKeys2 = olmAccount2.identityKeys();
QCOMPARE(identityKeys.curve25519, identityKeys2.curve25519);
QCOMPARE(identityKeys.ed25519, identityKeys2.ed25519);
diff --git a/autotests/testolmsession.cpp b/autotests/testolmsession.cpp
index 182659e7..18b0d5f2 100644
--- a/autotests/testolmsession.cpp
+++ b/autotests/testolmsession.cpp
@@ -11,10 +11,16 @@ std::pair<QOlmSessionPtr, QOlmSessionPtr> createSessionPair()
{
QByteArray pickledAccountA("eOBXIKivUT6YYowRH031BNv7zNmzqM5B7CpXdyeaPvala5mt7/OeqrG1qVA7vA1SYloFyvJPIy0QNkD3j1HiPl5vtZHN53rtfZ9exXDok03zjmssqn4IJsqcA7Fbo1FZeKafG0NFcWwCPTdmcV7REqxjqGm3I4K8MQFa45AdTGSUu2C12cWeOcbSMlcINiMral+Uyah1sgPmLJ18h1qcnskXUXQvpffZ5DiUw1Iz5zxnwOQF1GVyowPJD7Zdugvj75RQnDxAn6CzyvrY2k2CuedwqDC3fIXM2xdUNWttW4nC2g4InpBhCVvNwhZYxlUb5BUEjmPI2AB3dAL5ry6o9MFncmbN6x5x");
QByteArray pickledAccountB("eModTvoFi9oOIkax4j4nuxw9Tcl/J8mOmUctUWI68Q89HSaaPTqR+tdlKQ85v2GOs5NlZCp7EuycypN9GQ4fFbHUCrS7nspa3GFBWsR8PnM8+wez5PWmfFZLg3drOvT0jbMjpDx0MjGYClHBqcrEpKx9oFaIRGBaX6HXzT4lRaWSJkXxuX92q8iGNrLn96PuAWFNcD+2JXpPcNFntslwLUNgqzpZ04aIFYwL80GmzyOgq3Bz1GO6u3TgCQEAmTIYN2QkO0MQeuSfe7UoMumhlAJ6R8GPcdSSPtmXNk4tdyzzlgpVq1hm7ZLKto+g8/5Aq3PvnvA8wCqno2+Pi1duK1pZFTIlActr");
- auto accountA = QOlmAccount("accountA:foo.com", "Device1UserA");
- accountA.unpickle(pickledAccountA, Unencrypted{});
- auto accountB = QOlmAccount("accountB:foo.com", "Device1UserB");
- accountB.unpickle(pickledAccountB, Unencrypted{});
+ auto accountA = QOlmAccount(u"accountA:foo.com", u"Device1UserA");
+ if (accountA.unpickle(std::move(pickledAccountA), Unencrypted{})
+ != OLM_SUCCESS)
+ qFatal("Failed to unpickle account A: %s", accountA.lastError());
+
+ auto accountB = QOlmAccount(u"accountB:foo.com", u"Device1UserB");
+ if (accountB.unpickle(std::move(pickledAccountB), Unencrypted{})
+ != OLM_SUCCESS)
+ qFatal("Failed to unpickle account B: %s", accountB.lastError());
+
const QByteArray identityKeyA("qIEr3TWcJQt4CP8QoKKJcCaukByIOpgh6erBkhLEa2o");
const QByteArray oneTimeKeyA("WzsbsjD85iB1R32iWxfJdwkgmdz29ClMbJSJziECYwk");
diff --git a/autotests/testolmutility.cpp b/autotests/testolmutility.cpp
index 1d461a94..4de5afdf 100644
--- a/autotests/testolmutility.cpp
+++ b/autotests/testolmutility.cpp
@@ -49,7 +49,7 @@ void TestOlmUtility::canonicalJSON()
void TestOlmUtility::verifySignedOneTimeKey()
{
- QOlmAccount aliceOlm { "@alice:matrix.org", "aliceDevice" };
+ QOlmAccount aliceOlm { u"@alice:matrix.org", u"aliceDevice" };
aliceOlm.createNewAccount();
aliceOlm.generateOneTimeKeys(1);
auto keys = aliceOlm.oneTimeKeys();
@@ -64,16 +64,13 @@ void TestOlmUtility::verifySignedOneTimeKey()
auto utility = olm_utility(utilityBuf);
- QByteArray signatureBuf1(sig.length(), '0');
+ QByteArray signatureBuf1(sig.length(), '\0');
std::copy(sig.begin(), sig.end(), signatureBuf1.begin());
- auto res = olm_ed25519_verify(utility,
- aliceOlm.identityKeys().ed25519.data(),
- aliceOlm.identityKeys().ed25519.size(),
- msg.data(),
- msg.size(),
- (void *)sig.data(),
- sig.size());
+ auto res =
+ olm_ed25519_verify(utility, aliceOlm.identityKeys().ed25519.data(),
+ aliceOlm.identityKeys().ed25519.size(), msg.data(),
+ msg.size(), sig.data(), sig.size());
QCOMPARE(std::string(olm_utility_last_error(utility)), "SUCCESS");
QCOMPARE(res, 0);