aboutsummaryrefslogtreecommitdiff
path: root/autotests/testkeyverification.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-09-10 13:50:13 +0200
committerTobias Fella <fella@posteo.de>2022-09-10 14:21:07 +0200
commitfa34778cc377ab98a0b8f3944063e426c73a3941 (patch)
tree58812471c038d9df72f13ce201fe89260e49a0a5 /autotests/testkeyverification.cpp
parent83746abdf677f573287be2c93d2ad12b1aa84b3f (diff)
downloadlibquotient-fa34778cc377ab98a0b8f3944063e426c73a3941.tar.gz
libquotient-fa34778cc377ab98a0b8f3944063e426c73a3941.zip
Remove header for keyverificationtest
Diffstat (limited to 'autotests/testkeyverification.cpp')
-rw-r--r--autotests/testkeyverification.cpp83
1 files changed, 46 insertions, 37 deletions
diff --git a/autotests/testkeyverification.cpp b/autotests/testkeyverification.cpp
index fbbb7614..59a1c934 100644
--- a/autotests/testkeyverification.cpp
+++ b/autotests/testkeyverification.cpp
@@ -2,49 +2,58 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later
-#include "testkeyverification.h"
-#include "qt_connection_util.h"
-void TestKeyVerificationSession::testVerification()
+#include <QTest>
+#include "testutils.h"
+#include <qt_connection_util.h>
+
+class TestKeyVerificationSession : public QObject
{
- CREATE_CONNECTION(a, "alice1", "secret", "AliceDesktop")
- CREATE_CONNECTION(b, "alice1", "secret", "AlicePhone")
+ Q_OBJECT
+
+private Q_SLOTS:
+ void testVerification()
+ {
+ CREATE_CONNECTION(a, "alice1", "secret", "AliceDesktop")
+ CREATE_CONNECTION(b, "alice1", "secret", "AlicePhone")
- KeyVerificationSession *aSession = nullptr;
- connect(a.get(), &Connection::newKeyVerificationSession, this, [&](KeyVerificationSession* session) {
- aSession = session;
- QVERIFY(session->remoteDeviceId() == b->deviceId());
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORREADY);
- connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=](){
- QVERIFY(session->state() == KeyVerificationSession::ACCEPTED);
+ KeyVerificationSession *aSession = nullptr;
+ connect(a.get(), &Connection::newKeyVerificationSession, this, [&](KeyVerificationSession* session) {
+ aSession = session;
+ QVERIFY(session->remoteDeviceId() == b->deviceId());
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORREADY);
connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=](){
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORVERIFICATION);
- session->sendMac();
+ QVERIFY(session->state() == KeyVerificationSession::ACCEPTED);
+ connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=](){
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORVERIFICATION);
+ session->sendMac();
+ });
});
});
- });
- a->startKeyVerificationSession(b->deviceId());
- connect(b.get(), &Connection::newKeyVerificationSession, this, [=](KeyVerificationSession* session) {
- QVERIFY(session->remoteDeviceId() == a->deviceId());
- QVERIFY(session->state() == KeyVerificationSession::INCOMING);
- session->sendReady();
- // KeyVerificationSession::READY is skipped because we have only one method
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORACCEPT);
- connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=](){
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORKEY || session->state() == KeyVerificationSession::ACCEPTED);
- connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=]() {
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORVERIFICATION);
- QVERIFY(aSession);
- QVERIFY(aSession->sasEmojis() == session->sasEmojis());
- session->sendMac();
- QVERIFY(session->state() == KeyVerificationSession::WAITINGFORMAC);
+ a->startKeyVerificationSession(b->deviceId());
+ connect(b.get(), &Connection::newKeyVerificationSession, this, [=](KeyVerificationSession* session) {
+ QVERIFY(session->remoteDeviceId() == a->deviceId());
+ QVERIFY(session->state() == KeyVerificationSession::INCOMING);
+ session->sendReady();
+ // KeyVerificationSession::READY is skipped because we have only one method
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORACCEPT);
+ connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=](){
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORKEY || session->state() == KeyVerificationSession::ACCEPTED);
+ connectSingleShot(session, &KeyVerificationSession::stateChanged, this, [=]() {
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORVERIFICATION);
+ QVERIFY(aSession);
+ QVERIFY(aSession->sasEmojis() == session->sasEmojis());
+ session->sendMac();
+ QVERIFY(session->state() == KeyVerificationSession::WAITINGFORMAC);
+ });
});
- });
- });
- b->syncLoop();
- a->syncLoop();
- QSignalSpy spy(b.get(), &Connection::incomingKeyVerificationDone);
- spy.wait(10000);
-}
+ });
+ b->syncLoop();
+ a->syncLoop();
+ QSignalSpy spy(b.get(), &Connection::incomingKeyVerificationDone);
+ spy.wait(10000);
+ }
+};
QTEST_GUILESS_MAIN(TestKeyVerificationSession)
+#include "testkeyverification.moc"