summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2021-05-28 11:33:57 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2021-06-03 20:08:32 +0200
commitfd217e7f005d1825d95d73a15a075703bb6346c6 (patch)
tree4a5170b0987c14c98387d31d9f698a6f421042bb
parent7920c03ff1954355d588baa466820a60afc9b587 (diff)
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>
-rw-r--r--tests/auto/network/ssl/qdtls/tst_qdtls.cpp2
-rw-r--r--tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp5
-rw-r--r--tests/auto/network/ssl/shared/tlshelpers.h18
3 files changed, 12 insertions, 13 deletions
diff --git a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp
index d11fc6e99a..dd380923df 100644
--- a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp
+++ b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp
@@ -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();
diff --git a/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp b/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp
index 18efc82491..42b51ad413 100644
--- a/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp
+++ b/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp
@@ -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());
diff --git a/tests/auto/network/ssl/shared/tlshelpers.h b/tests/auto/network/ssl/shared/tlshelpers.h
index 490f9af89e..cd0f785aee 100644
--- a/tests/auto/network/ssl/shared/tlshelpers.h
+++ b/tests/auto/network/ssl/shared/tlshelpers.h
@@ -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