update tests
This commit is contained in:
parent
b46eea1d61
commit
86c7a7bec6
@ -6,7 +6,7 @@ NYMEA_PLUGINS_PATH=/usr/lib/$$system('dpkg-architecture -q DEB_HOST_MULTIARCH')/
|
|||||||
|
|
||||||
# define protocol versions
|
# define protocol versions
|
||||||
JSON_PROTOCOL_VERSION_MAJOR=1
|
JSON_PROTOCOL_VERSION_MAJOR=1
|
||||||
JSON_PROTOCOL_VERSION_MINOR=2
|
JSON_PROTOCOL_VERSION_MINOR=3
|
||||||
REST_API_VERSION=1
|
REST_API_VERSION=1
|
||||||
|
|
||||||
DEFINES += NYMEA_VERSION_STRING=\\\"$${NYMEA_VERSION_STRING}\\\" \
|
DEFINES += NYMEA_VERSION_STRING=\\\"$${NYMEA_VERSION_STRING}\\\" \
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
1.2
|
1.3
|
||||||
{
|
{
|
||||||
"methods": {
|
"methods": {
|
||||||
"Actions.ExecuteAction": {
|
"Actions.ExecuteAction": {
|
||||||
@ -134,7 +134,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Configuration.SetServerName": {
|
"Configuration.SetServerName": {
|
||||||
"description": "Set the name of the server. Default is guhIO.",
|
"description": "Set the name of the server. Default is nymea.",
|
||||||
"params": {
|
"params": {
|
||||||
"serverName": "String"
|
"serverName": "String"
|
||||||
},
|
},
|
||||||
@ -426,7 +426,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"JSONRPC.CreateUser": {
|
"JSONRPC.CreateUser": {
|
||||||
"description": "Create a new user in the API. Currently this is only allowed to be called once when a new guh instance is set up. Call Authenticate after this to obtain a device token for this user.",
|
"description": "Create a new user in the API. Currently this is only allowed to be called once when a new nymea instance is set up. Call Authenticate after this to obtain a device token for this user.",
|
||||||
"params": {
|
"params": {
|
||||||
"password": "String",
|
"password": "String",
|
||||||
"username": "String"
|
"username": "String"
|
||||||
@ -436,7 +436,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"JSONRPC.Hello": {
|
"JSONRPC.Hello": {
|
||||||
"description": "Upon first connection, guh will automatically send a welcome message containing information about the setup. If this message is lost for whatever reason (connections with multiple hops might drop this if guh sends it too early), the exact same message can be retrieved multiple times by calling this Hello method. Note that the contents might change if the system changed its state in the meantime, e.g. initialSetupRequired might turn false if the initial setup has been performed in the meantime.",
|
"description": "Upon first connection, nymea will automatically send a welcome message containing information about the setup. If this message is lost for whatever reason (connections with multiple hops might drop this if nymea sends it too early), the exact same message can be retrieved multiple times by calling this Hello method. Note that the contents might change if the system changed its state in the meantime, e.g. initialSetupRequired might turn false if the initial setup has been performed in the meantime.",
|
||||||
"params": {
|
"params": {
|
||||||
},
|
},
|
||||||
"returns": {
|
"returns": {
|
||||||
@ -528,7 +528,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"JSONRPC.Version": {
|
"JSONRPC.Version": {
|
||||||
"description": "Version of this Guh/JSONRPC interface.",
|
"description": "Version of this nymea/JSONRPC interface.",
|
||||||
"params": {
|
"params": {
|
||||||
},
|
},
|
||||||
"returns": {
|
"returns": {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
include(../../../guh.pri)
|
include(../../../nymea.pri)
|
||||||
include(../autotests.pri)
|
include(../autotests.pri)
|
||||||
|
|
||||||
TARGET = coaptests
|
TARGET = coaptests
|
||||||
|
|||||||
@ -191,7 +191,7 @@ void CoapTests::broken()
|
|||||||
|
|
||||||
void CoapTests::query()
|
void CoapTests::query()
|
||||||
{
|
{
|
||||||
CoapRequest request(QUrl("coap://coap.me/query?guh=awesome"));
|
CoapRequest request(QUrl("coap://coap.me/query?nymea=awesome"));
|
||||||
qDebug() << request.url().toString();
|
qDebug() << request.url().toString();
|
||||||
|
|
||||||
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
||||||
@ -203,7 +203,7 @@ void CoapTests::query()
|
|||||||
QCOMPARE(reply->statusCode(), CoapPdu::Content);
|
QCOMPARE(reply->statusCode(), CoapPdu::Content);
|
||||||
QCOMPARE(reply->contentType(), CoapPdu::TextPlain);
|
QCOMPARE(reply->contentType(), CoapPdu::TextPlain);
|
||||||
QCOMPARE(reply->error(), CoapReply::NoError);
|
QCOMPARE(reply->error(), CoapReply::NoError);
|
||||||
QVERIFY2(reply->payload() == "You asked me about: guh=awesome", "Invalid payload");
|
QVERIFY2(reply->payload() == "You asked me about: nymea=awesome", "Invalid payload");
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ void CoapTests::post()
|
|||||||
qDebug() << request.url().toString();
|
qDebug() << request.url().toString();
|
||||||
|
|
||||||
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
||||||
CoapReply *reply = m_coap->post(request, "guh is awesome");
|
CoapReply *reply = m_coap->post(request, "nymea is awesome");
|
||||||
spy.wait();
|
spy.wait();
|
||||||
|
|
||||||
QVERIFY2(spy.count() > 0, "Did not get a response.");
|
QVERIFY2(spy.count() > 0, "Did not get a response.");
|
||||||
@ -372,7 +372,7 @@ void CoapTests::put()
|
|||||||
qDebug() << request.url().toString();
|
qDebug() << request.url().toString();
|
||||||
|
|
||||||
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
QSignalSpy spy(m_coap, SIGNAL(replyFinished(CoapReply*)));
|
||||||
CoapReply *reply = m_coap->put(request, "guh is awesome");
|
CoapReply *reply = m_coap->put(request, "nymea is awesome");
|
||||||
spy.wait();
|
spy.wait();
|
||||||
|
|
||||||
QVERIFY2(spy.count() > 0, "Did not get a response.");
|
QVERIFY2(spy.count() > 0, "Did not get a response.");
|
||||||
|
|||||||
@ -140,8 +140,8 @@ void TestJSONRPC::testHandshake()
|
|||||||
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(spy.first().at(1).toByteArray());
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(spy.first().at(1).toByteArray());
|
||||||
QVariantMap handShake = jsonDoc.toVariant().toMap();
|
QVariantMap handShake = jsonDoc.toVariant().toMap();
|
||||||
QString guhVersionString(NYMEA_VERSION_STRING);
|
QString nymeaVersionString(NYMEA_VERSION_STRING);
|
||||||
QVERIFY2(handShake.value("version").toString() == guhVersionString, "Handshake version doesn't match Guh version.");
|
QVERIFY2(handShake.value("version").toString() == nymeaVersionString, "Handshake version doesn't match nymea version.");
|
||||||
|
|
||||||
// Check whether pushButtonAuth is disabled
|
// Check whether pushButtonAuth is disabled
|
||||||
QCOMPARE(handShake.value("pushButtonAuthAvailable").toBool(), false);
|
QCOMPARE(handShake.value("pushButtonAuthAvailable").toBool(), false);
|
||||||
@ -152,7 +152,7 @@ void TestJSONRPC::testHandshake()
|
|||||||
|
|
||||||
// And now check if it is sent again when calling JSONRPC.Hello
|
// And now check if it is sent again when calling JSONRPC.Hello
|
||||||
handShake = injectAndWait("JSONRPC.Hello").toMap();
|
handShake = injectAndWait("JSONRPC.Hello").toMap();
|
||||||
QCOMPARE(handShake.value("params").toMap().value("version").toString(), guhVersionString);
|
QCOMPARE(handShake.value("params").toMap().value("version").toString(), nymeaVersionString);
|
||||||
|
|
||||||
m_mockTcpServer->clientDisconnected(newClientId);
|
m_mockTcpServer->clientDisconnected(newClientId);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ void TestJSONRPC::testHandshake()
|
|||||||
|
|
||||||
// And now check if it is sent again when calling JSONRPC.Hello
|
// And now check if it is sent again when calling JSONRPC.Hello
|
||||||
handShake = injectAndWait("JSONRPC.Hello").toMap();
|
handShake = injectAndWait("JSONRPC.Hello").toMap();
|
||||||
QCOMPARE(handShake.value("params").toMap().value("version").toString(), guhVersionString);
|
QCOMPARE(handShake.value("params").toMap().value("version").toString(), nymeaVersionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestJSONRPC::testInitialSetup()
|
void TestJSONRPC::testInitialSetup()
|
||||||
@ -464,7 +464,7 @@ void TestJSONRPC::testBasicCall()
|
|||||||
QCOMPARE(jsonDoc.toVariant().toMap().value("id").toInt(), 42);
|
QCOMPARE(jsonDoc.toVariant().toMap().value("id").toInt(), 42);
|
||||||
}
|
}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
QVERIFY2(jsonDoc.toVariant().toMap().value("status").toString() == "success", "Call wasn't parsed correctly by guh.");
|
QVERIFY2(jsonDoc.toVariant().toMap().value("status").toString() == "success", "Call wasn't parsed correctly by nymea.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void TestLoggingDirect::benchmarkDB_data() {
|
|||||||
QTest::newRow("empty, trim") << 1 << 1;
|
QTest::newRow("empty, trim") << 1 << 1;
|
||||||
QTest::newRow("10000, no trim") << 10000 << 20000;
|
QTest::newRow("10000, no trim") << 10000 << 20000;
|
||||||
QTest::newRow("10000, trim") << 10000 << 10000;
|
QTest::newRow("10000, trim") << 10000 << 10000;
|
||||||
QTest::newRow("20000, no trim") << 20000 << 30000;
|
// QTest::newRow("20000, no trim") << 20000 << 30000;
|
||||||
// QTest::newRow("20000, trim") << 20000 << 20000;
|
// QTest::newRow("20000, trim") << 20000 << 20000;
|
||||||
// QTest::newRow("30000, no trim") << 30000 << 40000;
|
// QTest::newRow("30000, no trim") << 30000 << 40000;
|
||||||
// QTest::newRow("30000, trim") << 30000 << 30000;
|
// QTest::newRow("30000, trim") << 30000 << 30000;
|
||||||
|
|||||||
@ -121,8 +121,8 @@ void TestWebserver::httpVersion()
|
|||||||
QSignalSpy clientSpy(socket, SIGNAL(readyRead()));
|
QSignalSpy clientSpy(socket, SIGNAL(readyRead()));
|
||||||
|
|
||||||
QByteArray requestData;
|
QByteArray requestData;
|
||||||
requestData.append("GET /hello/guh HTTP/1\r\n");
|
requestData.append("GET /hello/nymea HTTP/1\r\n");
|
||||||
requestData.append("User-Agent: guh webserver test\r\n\r\n");
|
requestData.append("User-Agent: nymea webserver test\r\n\r\n");
|
||||||
|
|
||||||
quint64 count = socket->write(requestData);
|
quint64 count = socket->write(requestData);
|
||||||
QVERIFY2(count > 0, "could not write to webserver.");
|
QVERIFY2(count > 0, "could not write to webserver.");
|
||||||
@ -234,9 +234,9 @@ void TestWebserver::checkAllowedMethodCall()
|
|||||||
if (method == "GET") {
|
if (method == "GET") {
|
||||||
reply = nam.get(request);
|
reply = nam.get(request);
|
||||||
} else if(method == "PUT") {
|
} else if(method == "PUT") {
|
||||||
reply = nam.put(request, QByteArray("Hello guh!"));
|
reply = nam.put(request, QByteArray("Hello nymea!"));
|
||||||
} else if(method == "POST") {
|
} else if(method == "POST") {
|
||||||
reply = nam.post(request, QByteArray("Hello guh!"));
|
reply = nam.post(request, QByteArray("Hello nymea!"));
|
||||||
} else if(method == "DELETE") {
|
} else if(method == "DELETE") {
|
||||||
reply = nam.deleteResource(request);
|
reply = nam.deleteResource(request);
|
||||||
} else if(method == "HEAD") {
|
} else if(method == "HEAD") {
|
||||||
@ -381,7 +381,7 @@ void TestWebserver::getFiles_data()
|
|||||||
QTest::newRow("get /../../etc/passwd") << "/../../etc/passwd" << 404;
|
QTest::newRow("get /../../etc/passwd") << "/../../etc/passwd" << 404;
|
||||||
QTest::newRow("get /../../") << "/../../" << 403;
|
QTest::newRow("get /../../") << "/../../" << 403;
|
||||||
QTest::newRow("get /../") << "/../" << 403;
|
QTest::newRow("get /../") << "/../" << 403;
|
||||||
QTest::newRow("get /etc/guh/nymead.conf") << "/etc/guh/nymead.conf" << 404;
|
QTest::newRow("get /etc/nymea/nymead.conf") << "/etc/nymea/nymead.conf" << 404;
|
||||||
QTest::newRow("get /etc/sudoers") << "/etc/sudoers" << 404;
|
QTest::newRow("get /etc/sudoers") << "/etc/sudoers" << 404;
|
||||||
QTest::newRow("get /root/.ssh/id_rsa.pub") << "/root/.ssh/id_rsa.pub" << 404;
|
QTest::newRow("get /root/.ssh/id_rsa.pub") << "/root/.ssh/id_rsa.pub" << 404;
|
||||||
}
|
}
|
||||||
@ -439,16 +439,16 @@ void TestWebserver::getIcons_data()
|
|||||||
QTest::addColumn<QString>("query");
|
QTest::addColumn<QString>("query");
|
||||||
QTest::addColumn<int>("iconSize");
|
QTest::addColumn<int>("iconSize");
|
||||||
|
|
||||||
QTest::newRow("get /icons/guh-logo-8x8.png") << "/icons/guh-logo-8x8.png" << 228;
|
QTest::newRow("get /icons/nymea-logo-8x8.png") << "/icons/nymea-logo-8x8.png" << 228;
|
||||||
QTest::newRow("get /icons/guh-logo-16x16.png") << "/icons/guh-logo-16x16.png" << 392;
|
QTest::newRow("get /icons/nymea-logo-16x16.png") << "/icons/nymea-logo-16x16.png" << 392;
|
||||||
QTest::newRow("get /icons/guh-logo-22x22.png") << "/icons/guh-logo-22x22.png" << 512;
|
QTest::newRow("get /icons/nymea-logo-22x22.png") << "/icons/nymea-logo-22x22.png" << 512;
|
||||||
QTest::newRow("get /icons/guh-logo-32x32.png") << "/icons/guh-logo-32x32.png" << 747;
|
QTest::newRow("get /icons/nymea-logo-32x32.png") << "/icons/nymea-logo-32x32.png" << 747;
|
||||||
QTest::newRow("get /icons/guh-logo-48x48.png") << "/icons/guh-logo-48x48.png" << 1282;
|
QTest::newRow("get /icons/nymea-logo-48x48.png") << "/icons/nymea-logo-48x48.png" << 1282;
|
||||||
QTest::newRow("get /icons/guh-logo-64x64.png") << "/icons/guh-logo-64x64.png" << 1825;
|
QTest::newRow("get /icons/nymea-logo-64x64.png") << "/icons/nymea-logo-64x64.png" << 1825;
|
||||||
QTest::newRow("get /icons/guh-logo-120x120.png") << "/icons/guh-logo-120x120.png" << 4090;
|
QTest::newRow("get /icons/nymea-logo-120x120.png") << "/icons/nymea-logo-120x120.png" << 4090;
|
||||||
QTest::newRow("get /icons/guh-logo-128x128.png") << "/icons/guh-logo-128x128.png" << 4453;
|
QTest::newRow("get /icons/nymea-logo-128x128.png") << "/icons/nymea-logo-128x128.png" << 4453;
|
||||||
QTest::newRow("get /icons/guh-logo-256x256.png") << "/icons/guh-logo-256x256.png" << 10763;
|
QTest::newRow("get /icons/nymea-logo-256x256.png") << "/icons/nymea-logo-256x256.png" << 10763;
|
||||||
QTest::newRow("get /icons/guh-logo-512x512.png") << "/icons/guh-logo-512x512.png" << 24287;
|
QTest::newRow("get /icons/nymea-logo-512x512.png") << "/icons/nymea-logo-512x512.png" << 24287;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWebserver::getIcons()
|
void TestWebserver::getIcons()
|
||||||
|
|||||||
@ -89,7 +89,7 @@ void TestWebSocketServer::initTestCase()
|
|||||||
|
|
||||||
void TestWebSocketServer::testHandshake()
|
void TestWebSocketServer::testHandshake()
|
||||||
{
|
{
|
||||||
QWebSocket *socket = new QWebSocket("guh tests", QWebSocketProtocol::Version13);
|
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
|
||||||
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
||||||
QSignalSpy spy(socket, SIGNAL(textMessageReceived(QString)));
|
QSignalSpy spy(socket, SIGNAL(textMessageReceived(QString)));
|
||||||
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
||||||
@ -98,9 +98,9 @@ void TestWebSocketServer::testHandshake()
|
|||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(spy.first().first().toByteArray());
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(spy.first().first().toByteArray());
|
||||||
QVariantMap handShake = jsonDoc.toVariant().toMap();
|
QVariantMap handShake = jsonDoc.toVariant().toMap();
|
||||||
|
|
||||||
QString guhVersionString(NYMEA_VERSION_STRING);
|
QString nymeaVersionString(NYMEA_VERSION_STRING);
|
||||||
QString jsonProtocolVersionString(JSON_PROTOCOL_VERSION);
|
QString jsonProtocolVersionString(JSON_PROTOCOL_VERSION);
|
||||||
QCOMPARE(handShake.value("version").toString(), guhVersionString);
|
QCOMPARE(handShake.value("version").toString(), nymeaVersionString);
|
||||||
QCOMPARE(handShake.value("protocol version").toString(), jsonProtocolVersionString);
|
QCOMPARE(handShake.value("protocol version").toString(), jsonProtocolVersionString);
|
||||||
|
|
||||||
socket->close();
|
socket->close();
|
||||||
@ -109,7 +109,7 @@ void TestWebSocketServer::testHandshake()
|
|||||||
|
|
||||||
void TestWebSocketServer::pingTest()
|
void TestWebSocketServer::pingTest()
|
||||||
{
|
{
|
||||||
QWebSocket *socket = new QWebSocket("guh tests", QWebSocketProtocol::Version13);
|
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
|
||||||
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
||||||
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
||||||
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
||||||
@ -147,7 +147,7 @@ void TestWebSocketServer::testBasicCall()
|
|||||||
|
|
||||||
QVariant response = injectSocketData(data);
|
QVariant response = injectSocketData(data);
|
||||||
if (valid)
|
if (valid)
|
||||||
QVERIFY2(response.toMap().value("status").toString() == "success", "Call wasn't parsed correctly by guh.");
|
QVERIFY2(response.toMap().value("status").toString() == "success", "Call wasn't parsed correctly by nymea.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ QVariant TestWebSocketServer::injectSocketAndWait(const QString &method, const Q
|
|||||||
call.insert("params", params);
|
call.insert("params", params);
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(call);
|
QJsonDocument jsonDoc = QJsonDocument::fromVariant(call);
|
||||||
|
|
||||||
QWebSocket *socket = new QWebSocket("guh tests", QWebSocketProtocol::Version13);
|
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
|
||||||
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
||||||
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
||||||
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
||||||
@ -214,7 +214,7 @@ QVariant TestWebSocketServer::injectSocketAndWait(const QString &method, const Q
|
|||||||
|
|
||||||
QVariant TestWebSocketServer::injectSocketData(const QByteArray &data)
|
QVariant TestWebSocketServer::injectSocketData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QWebSocket *socket = new QWebSocket("guh tests", QWebSocketProtocol::Version13);
|
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
|
||||||
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
|
||||||
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
QSignalSpy spyConnection(socket, SIGNAL(connected()));
|
||||||
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
|
||||||
|
|||||||
Reference in New Issue
Block a user