From 53453bea465dbc7a15824ad4db2b19df44e62623 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 6 Aug 2019 13:19:35 +0200 Subject: tests: Always build security test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but check instead if the actual endpoint policy is supported by the backend. Change-Id: Ic1dbcd83b936beccb0378505744d4e1e3b292d22 Reviewed-by: Jannis Völker --- tests/auto/auto.pro | 4 +--- tests/auto/security/security.pro | 6 ++++++ tests/auto/security/tst_security.cpp | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a90406f..9d8b7db 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += qopcuaclient connection clientSetupInCpp +SUBDIRS += qopcuaclient connection clientSetupInCpp security QT_FOR_CONFIG += opcua-private @@ -8,5 +8,3 @@ qtHaveModule(qmltest):qtConfig(open62541)|qtConfig(uacpp) { SUBDIRS += declarative } -# This tries to check if the server supports security -qtConfig(mbedtls): SUBDIRS += security diff --git a/tests/auto/security/security.pro b/tests/auto/security/security.pro index d3d203e..bde83f7 100644 --- a/tests/auto/security/security.pro +++ b/tests/auto/security/security.pro @@ -7,3 +7,9 @@ RESOURCES += certs.qrc SOURCES += \ tst_security.cpp + +HEADERS += \ + $$PWD/../../common/backend_environment.h + +INCLUDEPATH += \ + $$PWD/../../common diff --git a/tests/auto/security/tst_security.cpp b/tests/auto/security/tst_security.cpp index 95bf22f..f2ddd68 100644 --- a/tests/auto/security/tst_security.cpp +++ b/tests/auto/security/tst_security.cpp @@ -34,6 +34,8 @@ ** ****************************************************************************/ +#include "backend_environment.h" + #include #include #include @@ -249,19 +251,23 @@ void Tst_QOpcUaSecurity::initTestCase() qDebug() << endpoint.securityPolicy(); } } - - QVERIFY(m_endpoints.size() > 0); } } void Tst_QOpcUaSecurity::connectAndDisconnectSecureUnencryptedKey() { + if (m_endpoints.size() == 0) + QSKIP("No secure endpoints available"); + QFETCH(QString, backend); QFETCH(QOpcUaEndpointDescription, endpoint); QScopedPointer client(m_opcUa.createClient(backend)); QVERIFY2(client, QString("Loading backend failed: %1").arg(backend).toLatin1().data()); + if (!client->supportedSecurityPolicies().contains(endpoint.securityPolicy())) + QSKIP(QString("This test is skipped because backend %1 does not support security policy %2").arg(client->backend()).arg(endpoint.securityPolicy()).toLatin1().constData()); + const QString pkidir = m_pkiData->path(); QOpcUaPkiConfiguration pkiConfig; pkiConfig.setClientCertificateFile(pkidir + "/own/certs/tst_security.der"); @@ -315,6 +321,9 @@ void Tst_QOpcUaSecurity::connectAndDisconnectSecureUnencryptedKey() void Tst_QOpcUaSecurity::connectAndDisconnectSecureEncryptedKey() { + if (m_endpoints.size() == 0) + QSKIP("No secure endpoints available"); + QFETCH(QString, backend); QFETCH(QOpcUaEndpointDescription, endpoint); @@ -324,6 +333,9 @@ void Tst_QOpcUaSecurity::connectAndDisconnectSecureEncryptedKey() if (client->backend() == QLatin1String("open62541")) QSKIP(QString("This test is skipped because backend %1 does not support encrypted keys").arg(client->backend()).toLatin1().constData()); + if (!client->supportedSecurityPolicies().contains(endpoint.securityPolicy())) + QSKIP(QString("This test is skipped because backend %1 does not support security policy %2").arg(client->backend()).arg(endpoint.securityPolicy()).toLatin1().constData()); + const QString pkidir = m_pkiData->path(); QOpcUaPkiConfiguration pkiConfig; pkiConfig.setClientCertificateFile(pkidir + "/own/certs/tst_security.der"); @@ -396,6 +408,7 @@ void Tst_QOpcUaSecurity::cleanupTestCase() int main(int argc, char *argv[]) { + updateEnvironment(); QCoreApplication app(argc, argv); QTEST_SET_MAIN_SOURCE_PATH -- cgit v1.2.3