summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2019-08-06 13:19:35 +0200
committerRainer Keller <Rainer.Keller@qt.io>2019-08-20 13:28:28 +0200
commit53453bea465dbc7a15824ad4db2b19df44e62623 (patch)
treefb3d269692d02a2a5dbd7e705486e9c51c1ebf48
parentaa577dbeda9d12d803972a9d87d88b47490863b2 (diff)
tests: Always build security test
but check instead if the actual endpoint policy is supported by the backend. Change-Id: Ic1dbcd83b936beccb0378505744d4e1e3b292d22 Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/security/security.pro6
-rw-r--r--tests/auto/security/tst_security.cpp17
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 <QtOpcUa/QOpcUaAuthenticationInformation>
#include <QtOpcUa/QOpcUaClient>
#include <QtOpcUa/QOpcUaEndpointDescription>
@@ -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<QOpcUaClient> 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