This should allow for creating tests more easily than the python-based server, since we can poke at it from C++ code. The idea is that each test creates the things it needs (rooms in a certain state, etc) programmatically instead of through the json files we use for the other tests. This allows us to adapt the test data to each test as needed, without having to copy it around a lot.
34 lines
855 B
C++
34 lines
855 B
C++
// SPDX-FileCopyrightText: 2025 Tobias Fella <tobias.fella@kde.org>
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
#include <QHttpServer>
|
|
#include <QSslServer>
|
|
|
|
class Server
|
|
{
|
|
public:
|
|
Server();
|
|
|
|
void start();
|
|
|
|
/**
|
|
* Create a room and place the user with id matrixId in it.
|
|
* Returns the room's id
|
|
*/
|
|
QString createRoom(const QString &matrixId);
|
|
|
|
void inviteUser(const QString &roomId, const QString &matrixId);
|
|
void banUser(const QString &roomId, const QString &matrixId);
|
|
void joinUser(const QString &roomId, const QString &matrixId);
|
|
|
|
private:
|
|
QHttpServer m_server;
|
|
QSslServer m_sslServer;
|
|
|
|
QHash<QString, QList<QString>> m_invitedUsers;
|
|
QHash<QString, QList<QString>> m_bannedUsers;
|
|
QHash<QString, QList<QString>> m_joinedUsers;
|
|
|
|
QList<std::pair<QString, QString>> m_roomsToCreate;
|
|
};
|