mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 21:10:38 +02:00
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
#include "unittest.h"
|
|
|
|
void UnitTest::loginSuccessfully()
|
|
{
|
|
RequestManager* testAccess = new RequestManager();
|
|
QJsonDocument config = testAccess->getConfig();
|
|
QSignalSpy spy(testAccess, SIGNAL(successLogin()));
|
|
testAccess->login(host, email, password);
|
|
spy.wait();
|
|
QVERIFY(spy.isValid());
|
|
QCOMPARE(spy.count(), 1);
|
|
QString json = testAccess->getResponse();
|
|
qDebug() << json;
|
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
|
QVERIFY2(doc.object().value("id").isString(), "No parameter 'id' in response");
|
|
}
|
|
|
|
//POST request w/o datas
|
|
void UnitTest::getSubjects()
|
|
{
|
|
RequestManager* testAccess = new RequestManager();
|
|
testAccess->login(host, email, password);
|
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
|
testAccess->getRequest("/SubjectManager/getSubjects");
|
|
spy.wait();
|
|
QVERIFY(spy.isValid());
|
|
QCOMPARE(spy.count(), 1);
|
|
QString json = testAccess->getResponse();
|
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
|
QVERIFY(doc.isObject());
|
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
|
|
|
}
|
|
|
|
void UnitTest::getTokens()
|
|
{
|
|
RequestManager* testAccess = new RequestManager();
|
|
testAccess->login(host, email, password);
|
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
|
testAccess->getRequest("/TokenManager/getTokens");
|
|
QCOMPARE(spy.count(), 0);
|
|
spy.wait();
|
|
QVERIFY(spy.isValid());
|
|
QCOMPARE(spy.count(), 1);
|
|
qDebug() << testAccess->getResponse();
|
|
}
|
|
|
|
void UnitTest::getTokensOpenManager()
|
|
{
|
|
RequestManager* testAccess = new RequestManager();
|
|
testAccess->login(host, email, password);
|
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
|
testAccess->getRequest("/OpenManager/getTokenSubject");
|
|
QCOMPARE(spy.count(), 0);
|
|
spy.wait();
|
|
QVERIFY(spy.isValid());
|
|
QCOMPARE(spy.count(), 1);
|
|
QString response = testAccess->getResponse();
|
|
qDebug() << response;
|
|
QVERIFY(!response.isEmpty());
|
|
}
|
|
|
|
|
|
QTEST_MAIN(UnitTest)
|