mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 14:30:50 +02:00
fix memory leaks
This commit is contained in:
parent
bd6b1f4224
commit
811345c301
@ -7,14 +7,14 @@ void UnitTest::initTestCase()
|
|||||||
|
|
||||||
void UnitTest::loginSuccessfully()
|
void UnitTest::loginSuccessfully()
|
||||||
{
|
{
|
||||||
auto testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(successLogin()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
testAccess->login();
|
testAccess.login();
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
|
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = testAccess->jsonResponse;
|
QString json = testAccess.jsonResponse;
|
||||||
qDebug() << json;
|
qDebug() << json;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QVERIFY2(doc.object().value("id").isString(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("id").isString(), "No parameter 'id' in response");
|
||||||
@ -23,14 +23,12 @@ void UnitTest::loginSuccessfully()
|
|||||||
//POST request w/o datas
|
//POST request w/o datas
|
||||||
void UnitTest::getSubjects()
|
void UnitTest::getSubjects()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
Response* response = testAccess->getSubjects();
|
Response* response = testAccess.getSubjects();
|
||||||
QSignalSpy spy1(response, &Response::ready);
|
QSignalSpy spy1(response, &Response::ready);
|
||||||
|
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
|
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QCOMPARE(spy1.count(), 1);
|
QCOMPARE(spy1.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
@ -39,13 +37,13 @@ void UnitTest::getSubjects()
|
|||||||
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||||
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||||
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokens()
|
void UnitTest::getTokens()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
Response* response = testAccess->getTokens();
|
Response* response = testAccess.getTokens();
|
||||||
QSignalSpy spy(response, &Response::ready);
|
QSignalSpy spy(response, &Response::ready);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
@ -57,149 +55,161 @@ void UnitTest::getTokens()
|
|||||||
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||||
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||||
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokenSubject()
|
void UnitTest::getTokenSubject()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getTokenSubject();
|
Response* response = testAccess.getTokenSubject();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getSubjectsUpdated()
|
void UnitTest::getSubjectsUpdated()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getSubjectsUpdated(epochMS);
|
Response* response = testAccess.getSubjectsUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getSubjectsDeleted()
|
void UnitTest::getSubjectsDeleted()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getSubjectsDeleted(epochMS);
|
Response* response = testAccess.getSubjectsDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokensUpdated()
|
void UnitTest::getTokensUpdated()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getTokensUpdated(epochMS);
|
Response* response = testAccess.getTokensUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokensDeleted()
|
void UnitTest::getTokensDeleted()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getTokensDeleted(epochMS);
|
Response* response = testAccess.getTokensDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroups()
|
void UnitTest::getAccessGroups()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroups();
|
Response* response = testAccess.getAccessGroups();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupsUpdated()
|
void UnitTest::getAccessGroupsUpdated()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroupsUpdated(epochMS);
|
Response* response = testAccess.getAccessGroupsUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupsDeleted()
|
void UnitTest::getAccessGroupsDeleted()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroupsDeleted(epochMS);
|
Response* response = testAccess.getAccessGroupsDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembership()
|
void UnitTest::getAccessGroupMembership()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroupMembership();
|
Response* response = testAccess.getAccessGroupMembership();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembershipUpdated()
|
void UnitTest::getAccessGroupMembershipUpdated()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroupMembershipUpdated(epochMS);
|
Response* response = testAccess.getAccessGroupMembershipUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembershipDeleted()
|
void UnitTest::getAccessGroupMembershipDeleted()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getAccessGroupMembershipDeleted(epochMS);
|
Response* response = testAccess.getAccessGroupMembershipDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::setTokens()
|
void UnitTest::setTokens()
|
||||||
@ -208,139 +218,65 @@ void UnitTest::setTokens()
|
|||||||
QHash<QString, std::shared_ptr<Token>> tokens;
|
QHash<QString, std::shared_ptr<Token>> tokens;
|
||||||
auto token = getTestToken();
|
auto token = getTestToken();
|
||||||
tokens.insert(token->idToStringWithoutBraces(), token);
|
tokens.insert(token->idToStringWithoutBraces(), token);
|
||||||
auto testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->setTokens(tokens);
|
Response* response = testAccess.setTokens(tokens);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::deleteTokens()
|
void UnitTest::deleteTokens()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
QList<QString> ids;
|
QList<QString> ids;
|
||||||
ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
||||||
ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
||||||
Response* response = testAccess->deleteTokens(ids);
|
Response* response = testAccess.deleteTokens(ids);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::subjectJSONParser()
|
void UnitTest::subjectJSONParser()
|
||||||
{
|
{
|
||||||
/*
|
RequestManager testAccess;
|
||||||
QFile jsonData(QDir::current().filePath("subjects.json"));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
|
Response* response = testAccess.getSubjects();
|
||||||
if (!jsonData.open(QIODevice::ReadOnly)) {
|
|
||||||
qCritical() << "Couldn't open config file config.json" << QDir::current().filePath("subjects.json");
|
|
||||||
QCoreApplication::exit(-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(jsonData.readAll());
|
|
||||||
QJsonObject obj = doc.object();
|
|
||||||
QJsonArray arr = obj["items"].toArray();
|
|
||||||
*/
|
|
||||||
auto* testAccess = new RequestManager();
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
|
||||||
Response* response = testAccess->getSubjects();
|
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QJsonArray arr = doc.object()["items"].toArray();
|
QJsonArray arr = doc.object()["items"].toArray();
|
||||||
auto testSubject = new Subject();
|
Subject testSubject;
|
||||||
testSubject->fromJSON(arr[1].toObject());
|
testSubject.fromJSON(arr[1].toObject());
|
||||||
qDebug() << testSubject->getName() << " Size: " << arr.size();
|
qDebug() << testSubject.getName() << " Size: " << arr.size();
|
||||||
QVERIFY(!testSubject->getName().isEmpty());
|
QVERIFY(!testSubject.getName().isEmpty());
|
||||||
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::tokenJSONParser()
|
void UnitTest::tokenJSONParser()
|
||||||
{
|
{
|
||||||
auto* testAccess = new RequestManager();
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess->getTokens();
|
Response* response = testAccess.getTokens();
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QJsonArray arr = doc.object()["items"].toArray();
|
QJsonArray arr = doc.object()["items"].toArray();
|
||||||
auto testToken = new Token();
|
Token testToken;
|
||||||
testToken->fromJSON(arr[5].toObject());
|
testToken.fromJSON(arr[5].toObject());
|
||||||
qDebug() << testToken->getName() << " Size: " << arr.size();
|
qDebug() << testToken.getName() << " Size: " << arr.size();
|
||||||
QVERIFY(!testToken->getName().isEmpty());
|
QVERIFY(!testToken.getName().isEmpty());
|
||||||
}
|
response->deleteLater();
|
||||||
|
|
||||||
//void UnitTest::connectToDB()
|
|
||||||
//{
|
|
||||||
// DatabaseManager *db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
|
||||||
// QVERIFY(db->getOpened());
|
|
||||||
// qDebug() << db->getTestMessage(1);
|
|
||||||
// QVERIFY(true);
|
|
||||||
// QCOMPARE(db->getTestMessage(1), QStringLiteral("Hello world"));
|
|
||||||
// QCOMPARE(db->getTestMessage(db->createTestRecord("Now it's diffrent")), QStringLiteral("Now it's diffrent"));
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void UnitTest::debugConnection()
|
|
||||||
{
|
|
||||||
QSslSocket ssl;// = new QSslSocket();
|
|
||||||
ssl.connectToHostEncrypted("192.168.1.3", 8443);
|
|
||||||
ssl.ignoreSslErrors();
|
|
||||||
if (!ssl.waitForEncrypted())
|
|
||||||
{
|
|
||||||
qDebug() << ssl.errorString();
|
|
||||||
}
|
|
||||||
QString tmp = "POST /AaaManager/authSession HTTP/1.1\r\nHost: 192.168.1.3:8443\r\nAuthorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==\r\nUser-Agent: curl/7.65.3\r\nAccept: **\r\nContent-Type: application/json\r\nContent-Length: 164\r\n\r\n{\"password\":\"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0\",\"username\":\"spaceti\"}";
|
|
||||||
qDebug().noquote() << tmp.toUtf8();
|
|
||||||
ssl.write(tmp.toUtf8());
|
|
||||||
QString data;
|
|
||||||
while (ssl.waitForReadyRead() && data.isEmpty())
|
|
||||||
{
|
|
||||||
data.append(ssl.readAll().data());
|
|
||||||
}
|
|
||||||
qDebug().noquote() << data;
|
|
||||||
int index = data.lastIndexOf("id");
|
|
||||||
QString tkn = data.mid( index + 5, 36);
|
|
||||||
tkn = tkn + ":";
|
|
||||||
qDebug() << "parsed token : " <<tkn;
|
|
||||||
tmp = "POST /SubjectManager/getSubjects HTTP/1.1\r\nHost: 192.168.1.3:8443\r\nAuthorization: Basic " + tkn.toUtf8().toBase64() + "\r\nUser-Agent: curl/7.65.3\r\nAccept: **\r\n\r\n";
|
|
||||||
QFile file("output1234.txt");
|
|
||||||
file.open(QIODevice::ReadWrite);
|
|
||||||
QTextStream st(&file);
|
|
||||||
st << tmp;
|
|
||||||
file.close();
|
|
||||||
qDebug().noquote() << tmp.toUtf8();
|
|
||||||
ssl.write(tmp.toUtf8());
|
|
||||||
while (ssl.waitForReadyRead())
|
|
||||||
{
|
|
||||||
qDebug() << ssl.readAll().data();
|
|
||||||
}
|
|
||||||
qDebug() << ssl.errorString();
|
|
||||||
|
|
||||||
QVERIFY(true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void UnitTest::saveDataToDB()
|
|
||||||
{
|
|
||||||
|
|
||||||
// dataMan->localSaveTokens();
|
|
||||||
QVERIFY(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnitTest::getUuid()
|
|
||||||
{
|
|
||||||
qDebug() << QUuid::createUuid().toString().mid(1,36);
|
|
||||||
QCOMPARE(1,1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Token> UnitTest::getTestToken()
|
std::shared_ptr<Token> UnitTest::getTestToken()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user