fix rest tests

This commit is contained in:
Michael Zanetti 2017-09-24 22:46:31 +02:00
parent daea0fa44b
commit b0098701d4
8 changed files with 128 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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