diff --git a/tests/auto/guhtestbase.cpp b/tests/auto/guhtestbase.cpp index e1d8ec54..a48ebb7f 100644 --- a/tests/auto/guhtestbase.cpp +++ b/tests/auto/guhtestbase.cpp @@ -304,6 +304,7 @@ QVariant GuhTestBase::getAndWait(const QNetworkRequest &request, const int &expe if (clientSpy.count() == 0) { clientSpy.wait(); } + qDebug() << "*** finished" << reply->isFinished() << reply->error() << reply->errorString(); if (clientSpy.count() == 0) { qWarning() << "Got no response for get request"; diff --git a/tests/auto/restdeviceclasses/testrestdeviceclasses.cpp b/tests/auto/restdeviceclasses/testrestdeviceclasses.cpp index cb51b17d..fade40b3 100644 --- a/tests/auto/restdeviceclasses/testrestdeviceclasses.cpp +++ b/tests/auto/restdeviceclasses/testrestdeviceclasses.cpp @@ -42,6 +42,8 @@ class TestRestDeviceClasses: public GuhTestBase Q_OBJECT private slots: + void initTestCase(); + void getSupportedDevices(); void invalidMethod(); @@ -62,6 +64,25 @@ private slots: #include "testrestdeviceclasses.moc" +void TestRestDeviceClasses::initTestCase() +{ + GuhTestBase::initTestCase(); + + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestDeviceClasses::getSupportedDevices() { // Get all deviceclasses diff --git a/tests/auto/restdevices/testrestdevices.cpp b/tests/auto/restdevices/testrestdevices.cpp index 973620c7..189a52e9 100644 --- a/tests/auto/restdevices/testrestdevices.cpp +++ b/tests/auto/restdevices/testrestdevices.cpp @@ -42,6 +42,8 @@ class TestRestDevices: public GuhTestBase Q_OBJECT private slots: + void initTestCase(); + void getConfiguredDevices(); void addConfiguredDevice_data(); @@ -72,6 +74,24 @@ private slots: }; +void TestRestDevices::initTestCase() +{ + GuhTestBase::initTestCase(); + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestDevices::getConfiguredDevices() { // Get all devices diff --git a/tests/auto/restlogging/testrestlogging.cpp b/tests/auto/restlogging/testrestlogging.cpp index 3b567fdf..5bd09f90 100644 --- a/tests/auto/restlogging/testrestlogging.cpp +++ b/tests/auto/restlogging/testrestlogging.cpp @@ -40,6 +40,8 @@ class TestRestLogging : public GuhTestBase private: private slots: + void initTestCase(); + void initLogs(); void invalidFilter_data(); @@ -55,6 +57,25 @@ private slots: void removeDevice(); }; +void TestRestLogging::initTestCase() +{ + GuhTestBase::initTestCase(); + + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestLogging::initLogs() { QNetworkRequest request(QUrl("https://localhost:3333/api/v1/logs")); diff --git a/tests/auto/restplugins/testrestplugins.cpp b/tests/auto/restplugins/testrestplugins.cpp index 44a729de..983aa9b0 100644 --- a/tests/auto/restplugins/testrestplugins.cpp +++ b/tests/auto/restplugins/testrestplugins.cpp @@ -42,6 +42,8 @@ class TestRestPlugins: public GuhTestBase Q_OBJECT private slots: + void initTestCase(); + void getPlugins(); void invalidMethod(); void invalidPath(); @@ -55,6 +57,25 @@ private slots: // void setPluginConfiguration(); }; +void TestRestPlugins::initTestCase() +{ + GuhTestBase::initTestCase(); + + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestPlugins::getPlugins() { // Get all plugins diff --git a/tests/auto/restrules/testrestrules.cpp b/tests/auto/restrules/testrestrules.cpp index 4395281b..4168491a 100644 --- a/tests/auto/restrules/testrestrules.cpp +++ b/tests/auto/restrules/testrestrules.cpp @@ -42,6 +42,7 @@ class TestRestRules: public GuhTestBase Q_OBJECT private: + void cleanupMockHistory(); void cleanupRules(); @@ -53,6 +54,8 @@ private: QVariant validIntStateBasedRule(const QString &name, const bool &executable, const bool &enabled); private slots: + void initTestCase(); + void getRules(); void findRule(); void invalidMethod(); @@ -75,6 +78,25 @@ private slots: }; +void TestRestRules::initTestCase() +{ + GuhTestBase::initTestCase(); + + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestRules::cleanupMockHistory() { QNetworkAccessManager nam; diff --git a/tests/auto/restvendors/testrestvendors.cpp b/tests/auto/restvendors/testrestvendors.cpp index 89c08145..35caa582 100644 --- a/tests/auto/restvendors/testrestvendors.cpp +++ b/tests/auto/restvendors/testrestvendors.cpp @@ -42,6 +42,8 @@ class TestRestVendors: public GuhTestBase Q_OBJECT private slots: + void initTestCase(); + void getVendors(); void invalidMethod(); void invalidPath(); @@ -50,6 +52,25 @@ private slots: void invalidVendor(); }; +void TestRestVendors::initTestCase() +{ + GuhTestBase::initTestCase(); + + foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { + if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { + qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; + return; + } + } + + qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + WebServerConfiguration config; + config.address = QHostAddress("127.0.0.1"); + config.port = 3333; + config.sslEnabled = true; + GuhCore::instance()->configuration()->setWebServerConfiguration(config); +} + void TestRestVendors::getVendors() { // Get all vendors diff --git a/tests/auto/webserver/testwebserver.cpp b/tests/auto/webserver/testwebserver.cpp index 215895d7..b0f64933 100644 --- a/tests/auto/webserver/testwebserver.cpp +++ b/tests/auto/webserver/testwebserver.cpp @@ -90,7 +90,7 @@ void TestWebserver::initTestCase() qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; WebServerConfiguration config; - config.address = QHostAddress("0.0.0.0"); + config.address = QHostAddress("127.0.0.1"); config.port = 3333; config.sslEnabled = true; GuhCore::instance()->configuration()->setWebServerConfiguration(config);