2023-03-26 19:36:35 +03:00
|
|
|
//#
|
|
|
|
//# Copyright (C) 2020-2023 QuasarApp.
|
2023-03-26 21:25:15 +02:00
|
|
|
//# Distributed under the GPLv3 software license, see the accompanying
|
2023-03-26 19:36:35 +03:00
|
|
|
//# Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
//# of this license document, but changing it is not allowed.
|
|
|
|
//#
|
|
|
|
|
|
|
|
#include <QtTest>
|
2023-03-26 21:13:39 +02:00
|
|
|
#include "cryptotest.h"
|
|
|
|
#include "authtest.h"
|
2023-07-16 21:44:34 +02:00
|
|
|
#include "crttest.h"
|
2023-07-13 23:41:51 +02:00
|
|
|
#include "easyssl/rsassl.h"
|
|
|
|
#include <easyssl/ecdsassl.h>
|
2023-03-26 19:36:35 +03:00
|
|
|
|
2023-07-16 21:44:34 +02:00
|
|
|
|
2023-03-26 19:36:35 +03:00
|
|
|
// Use This macros for initialize your own test classes.
|
|
|
|
// Check exampletests
|
|
|
|
#define TestCase(name, testClass) \
|
|
|
|
void name() { \
|
|
|
|
initTest(new testClass()); \
|
|
|
|
}
|
|
|
|
|
2023-07-16 21:44:34 +02:00
|
|
|
using CrtTestX509RSA = CrtTest<EasySSL::X509, EasySSL::RSASSL>;
|
|
|
|
using CrtTestX509ECDSA = CrtTest<EasySSL::X509, EasySSL::ECDSASSL>;
|
|
|
|
|
2023-03-26 19:36:35 +03:00
|
|
|
/**
|
|
|
|
* @brief The tstMain class - this is main test class
|
|
|
|
*/
|
|
|
|
class tstMain : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
tstMain();
|
|
|
|
|
|
|
|
~tstMain();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
// BEGIN TESTS CASES
|
2023-03-26 21:13:39 +02:00
|
|
|
TestCase(authTest, AuthTest)
|
2023-07-13 23:41:51 +02:00
|
|
|
TestCase(cryptoTestESDSA, CryptoTest<EasySSL::ECDSASSL>)
|
|
|
|
TestCase(cryptoTestRSA, CryptoTest<EasySSL::RSASSL>)
|
2023-07-16 21:44:34 +02:00
|
|
|
TestCase(crtTestX509RSA, CrtTestX509RSA)
|
|
|
|
TestCase(crtTestX509ECDSA, CrtTestX509ECDSA)
|
2023-03-26 21:13:39 +02:00
|
|
|
|
2023-07-16 21:44:34 +02:00
|
|
|
// END TEST CASESa
|
2023-03-26 19:36:35 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief initTest This method prepare @a test for run in the QApplication loop.
|
|
|
|
* @param test are input test case class.
|
|
|
|
*/
|
|
|
|
void initTest(Test* test);
|
|
|
|
|
|
|
|
QCoreApplication *_app = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief tstMain::tstMain
|
|
|
|
* init all availabel units for testsing
|
|
|
|
*/
|
|
|
|
tstMain::tstMain() {
|
|
|
|
|
|
|
|
// init xample unit test
|
|
|
|
int argc =0;
|
|
|
|
char * argv[] = {nullptr};
|
|
|
|
|
|
|
|
_app = new QCoreApplication(argc, argv);
|
2023-03-26 18:38:04 +02:00
|
|
|
QCoreApplication::setApplicationName("testeasyssl");
|
2023-03-26 19:36:35 +03:00
|
|
|
QCoreApplication::setOrganizationName("QuasarApp");
|
|
|
|
|
|
|
|
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
|
|
|
|
|
|
QDir(path).removeRecursively();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tstMain::~tstMain() {
|
|
|
|
_app->exit(0);
|
|
|
|
delete _app;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tstMain::initTest(Test *test) {
|
|
|
|
QTimer::singleShot(0, this, [this, test]() {
|
|
|
|
test->test();
|
|
|
|
delete test;
|
|
|
|
_app->exit(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
_app->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_APPLESS_MAIN(tstMain)
|
|
|
|
|
|
|
|
#include "tstMain.moc"
|