QDtls(Cookie) autotests - use the proper API to detect DTLS support
Instead of relying on some string comparisons and the current knowledge of which backend supports DTLS, use the proper API we already have in place to test if a particular class is supported by the active backend. Change-Id: I58ca0f7b7fcef68ec375cd64b83e51d4335817da Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
7920c03ff1
commit
fd217e7f00
|
|
@ -171,7 +171,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
void tst_QDtls::initTestCase()
|
||||
{
|
||||
if (!TlsAux::activeBackendSupportsDtls())
|
||||
if (!TlsAux::classImplemented(QSsl::ImplementedClass::Dtls))
|
||||
QSKIP("The active TLS backend does not support DTLS");
|
||||
|
||||
certDirPath = QFileInfo(QFINDTESTDATA("certs")).absolutePath();
|
||||
|
|
|
|||
|
|
@ -141,7 +141,10 @@ QHostAddress tst_QDtlsCookie::toNonAny(const QHostAddress &addr)
|
|||
|
||||
void tst_QDtlsCookie::initTestCase()
|
||||
{
|
||||
if (!TlsAux::activeBackendSupportsDtls())
|
||||
using TlsCl = QSsl::ImplementedClass;
|
||||
using TlsAux::classImplemented;
|
||||
|
||||
if (!classImplemented(TlsCl::DtlsCookie) || !classImplemented(TlsCl::Dtls))
|
||||
QSKIP("The active TLS backend does not support DTLS");
|
||||
|
||||
QVERIFY(noiseMaker.bind());
|
||||
|
|
|
|||
|
|
@ -42,24 +42,20 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
|
||||
namespace TlsAux {
|
||||
|
||||
inline bool activeBackendSupportsDtls()
|
||||
inline bool classImplemented(QSsl::ImplementedClass cl)
|
||||
{
|
||||
// In case Qt was built with OpenSSL (the only DTLS-capable backend
|
||||
// at the moment) and some other backend, and later when running
|
||||
// the test OpenSSL library is not available, skip the whole
|
||||
// test.
|
||||
// IMPORTANT: extend this definition, if a new backend supporting
|
||||
// DTLS is introduced or if one of the already-supported backends
|
||||
// adds DTLS support.
|
||||
return QSslSocket::activeBackend() == QStringLiteral("openssl");
|
||||
#if QT_CONFIG(ssl)
|
||||
return QSslSocket::implementedClasses().contains(cl);
|
||||
#endif
|
||||
return cl == QSsl::ImplementedClass::Certificate; // This is the only thing our 'cert-only' supports.
|
||||
}
|
||||
|
||||
} // namespace TlsAux
|
||||
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue