fix tests
Some checks failed
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/DocsGenerator Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.
buildbot/IOSCMakeBuilder Build finished.
buildbot/WindowsCMakeBuilder Build finished.

This commit is contained in:
Andrei Yankovich 2023-07-16 21:44:34 +02:00
parent 5d279991f4
commit 5e1d48ce03
3 changed files with 56 additions and 2 deletions

View File

@ -8,9 +8,11 @@
#include <QtTest>
#include "cryptotest.h"
#include "authtest.h"
#include "crttest.h"
#include "easyssl/rsassl.h"
#include <easyssl/ecdsassl.h>
// Use This macros for initialize your own test classes.
// Check exampletests
#define TestCase(name, testClass) \
@ -18,6 +20,9 @@
initTest(new testClass()); \
}
using CrtTestX509RSA = CrtTest<EasySSL::X509, EasySSL::RSASSL>;
using CrtTestX509ECDSA = CrtTest<EasySSL::X509, EasySSL::ECDSASSL>;
/**
* @brief The tstMain class - this is main test class
*/
@ -33,13 +38,14 @@ public:
private slots:
// BEGIN TESTS CASES
TestCase(authTest, AuthTest)
TestCase(cryptoTestESDSA, CryptoTest<EasySSL::ECDSASSL>)
TestCase(cryptoTestRSA, CryptoTest<EasySSL::RSASSL>)
TestCase(crtTestX509RSA, CrtTestX509RSA)
TestCase(crtTestX509ECDSA, CrtTestX509ECDSA)
// END TEST CASES
// END TEST CASESa
private:

0
tests/units/crttest.cpp Normal file
View File

48
tests/units/crttest.h Normal file
View File

@ -0,0 +1,48 @@
//#
//# Copyright (C) 2020-2023 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CRTTEST_H
#define CRTTEST_H
#include "qtestcase.h"
#include "test.h"
#include "testutils.h"
#include <easyssl/icertificate.h>
#include <easyssl/x509.h>
/**
* @brief The CrtTest class is bse test class for the testin all certificate generators
* @tparam CrtGenerator This any class inheret of ICertificate interface.
*
* @example
* @code{cpp}
* #include "x509.h"
* #include "CrtTest"
*
* TestCase(cryptoTestRSA, CrtTest<EasySSL::x509, EasySSL::RSASSL>)
* @endcode
*/
template <class CrtGenerator, class Algorithm>
class CrtTest: public Test, protected TestUtils
{
public:
CrtTest() = default;
void test() override {
CrtGenerator gen(QSharedPointer<Algorithm>::create());
EasySSL::SslSrtData data;
auto crt = gen.create(data);
QVERIFY2(!crt.crt.isNull(), "Failed to generate certificate.");
QVERIFY2(!crt.key.isNull(), "Failed to generate private key for certificate.");
}
};
#endif // CRTTEST_H