From 2d33034a121bc5c2171c18a72abfd3746e19795c Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 24 Sep 2017 22:58:35 +0200 Subject: [PATCH] fix websocket server tests --- .../websocketserver/testwebsocketserver.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/auto/websocketserver/testwebsocketserver.cpp b/tests/auto/websocketserver/testwebsocketserver.cpp index 39a1de12..ba1721b6 100644 --- a/tests/auto/websocketserver/testwebsocketserver.cpp +++ b/tests/auto/websocketserver/testwebsocketserver.cpp @@ -40,6 +40,8 @@ class TestWebSocketServer: public GuhTestBase Q_OBJECT private slots: + void initTestCase(); + void testHandshake(); void pingTest(); @@ -63,6 +65,28 @@ private: }; +void TestWebSocketServer::initTestCase() +{ + GuhTestBase::initTestCase(); + + ServerConfiguration config; + foreach (const ServerConfiguration &c, GuhCore::instance()->configuration()->webSocketServerConfigurations()) { + if (c.port == 4444 && (c.address == QHostAddress("127.0.0.1") || c.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a websocketserver listening on 127.0.0.1:4444"; + config = c; + break; + } + } + + qDebug() << "Creating new websocketserver instance on 127.0.0.1:4444"; + config.address = QHostAddress("127.0.0.1"); + config.port = 4444; + config.sslEnabled = true; + config.authenticationEnabled = true; + GuhCore::instance()->configuration()->setWebSocketServerConfiguration(config); + +} + void TestWebSocketServer::testHandshake() { QWebSocket *socket = new QWebSocket("guh tests", QWebSocketProtocol::Version13);