diff options
author | Tobias Fella <fella@posteo.de> | 2022-02-24 15:53:15 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2022-02-24 15:53:15 +0100 |
commit | 110ca4b01ae86216ee8c03cd2b4eda5ac351df2a (patch) | |
tree | cba65c32505c70b4a7ef61585063640afebb516c /autotests | |
parent | fb406897292184c46432ed0247ca9bdbef666f69 (diff) | |
download | libquotient-110ca4b01ae86216ee8c03cd2b4eda5ac351df2a.tar.gz libquotient-110ca4b01ae86216ee8c03cd2b4eda5ac351df2a.zip |
Fix test
Diffstat (limited to 'autotests')
-rwxr-xr-x | autotests/run-tests.sh | 1 | ||||
-rw-r--r-- | autotests/testolmaccount.cpp | 52 | ||||
-rw-r--r-- | autotests/testolmaccount.h | 3 |
3 files changed, 22 insertions, 34 deletions
diff --git a/autotests/run-tests.sh b/autotests/run-tests.sh index 74a8c544..0d58e460 100755 --- a/autotests/run-tests.sh +++ b/autotests/run-tests.sh @@ -28,7 +28,6 @@ echo Register bob docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob1 -p secret -c /data/homeserver.yaml https://localhost:8008' docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob2 -p secret -c /data/homeserver.yaml https://localhost:8008' docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob3 -p secret -c /data/homeserver.yaml https://localhost:8008' -docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob4 -p secret -c /data/homeserver.yaml https://localhost:8008' echo Register carl docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u carl -p secret -c /data/homeserver.yaml https://localhost:8008' diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp index 033fff32..04e23db6 100644 --- a/autotests/testolmaccount.cpp +++ b/autotests/testolmaccount.cpp @@ -490,44 +490,30 @@ void TestOlmAccount::claimMultipleKeys() void TestOlmAccount::enableEncryption() { CREATE_CONNECTION(alice, "alice9", "secret", "AlicePhone") - CREATE_CONNECTION(bob, "bob4", "secret", "BobPhone") - QString joinedRoomId; - - auto job = alice->createRoom(Connection::PublishRoom, {}, {}, {}, - { "@bob:localhost" }); + auto job = alice->createRoom(Connection::PublishRoom, {}, {}, {}, {}); + bool encryptedEmitted = false; connect(alice.get(), &Connection::newRoom, this, - [alice, bob, &joinedRoomId](Quotient::Room* room) { - room->activateEncryption(); - QSignalSpy spy(room, &Room::encryption); - - joinedRoomId = room->id(); - auto job = bob->joinRoom(room->id()); - QSignalSpy spy1(job, &BaseJob::result); - QVERIFY(spy.wait(10000)); - QVERIFY(spy1.wait(10000)); + [alice, this, &encryptedEmitted](Quotient::Room* room) { + room->activateEncryption(); + connect(room, &Room::encryption, this, [&encryptedEmitted, this](){ + encryptedEmitted = true; + Q_EMIT enableEncryptionFinished(); + }); + connect(alice.get(), &Connection::syncDone, this, [alice, room](){ + if (!room->usesEncryption()) { + alice->sync(); + } }); + alice->sync(); + }); + QSignalSpy createRoomSpy(job, &BaseJob::success); + QVERIFY(createRoomSpy.wait(10000)); alice->sync(); - QSignalSpy spy(job, &BaseJob::result); - QVERIFY(spy.wait(10000)); - bob->sync(); - connect(bob.get(), &Connection::syncDone, this, [bob, joinedRoomId] { - const auto* joinedRoom = bob->room(joinedRoomId); - const auto& events = joinedRoom->messageEvents(); - bool hasEncryption = false; - for (auto it = events.rbegin(); it != events.rend(); ++it) { - const auto& event = it->event(); - if (is<EncryptionEvent>(*event)) { - hasEncryption = true; - break; - } - } - QVERIFY(bob->room(joinedRoomId)->usesEncryption()); - QVERIFY(hasEncryption); - }); - QSignalSpy spy2(bob.get(), &Connection::syncDone); - QVERIFY(spy2.wait(10000)); + QSignalSpy finishedSpy(this, &TestOlmAccount::enableEncryptionFinished); + QVERIFY(finishedSpy.wait(10000)); + QVERIFY(encryptedEmitted); } QTEST_GUILESS_MAIN(TestOlmAccount) diff --git a/autotests/testolmaccount.h b/autotests/testolmaccount.h index 367092f6..1d3da837 100644 --- a/autotests/testolmaccount.h +++ b/autotests/testolmaccount.h @@ -13,6 +13,9 @@ class TestOlmAccount : public QObject { Q_OBJECT +Q_SIGNALS: + void enableEncryptionFinished(); + private Q_SLOTS: void pickleUnpickledTest(); void identityKeysValid(); |