fix websocket server tests

This commit is contained in:
Michael Zanetti 2017-09-24 22:58:35 +02:00
parent b0098701d4
commit 2d33034a12

View File

@ -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);