summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/SecurityTest.qml
blob: b902aede7df4bb2a83632deb035337229db5b689 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

import QtQuick
import QtTest
import QtOpcUa as QtOpcUa

Item {
    property string backendName
    property int completedTestCases: 0
    property int availableTestCases: 0
    property bool completed: completedTestCases == availableTestCases
    property bool shouldRun: false

    onShouldRunChanged: {
        if (shouldRun)
            console.log("Running", parent.testName, "with", backendName);
    }

    CompletionLoggingTestCase {
        name: parent.parent.testName + ": " + backendName + ": Check supported security features"
        when: shouldRun

        QtOpcUa.Connection {
            id: connection2
            backend: backendName
        }

        function test_nodeTest() {
            verify(connection2.supportedSecurityPolicies.length > 0);
            if (backendName === "open62541") {
                if (SERVER_SUPPORTS_SECURITY)
                    compare(connection2.supportedSecurityPolicies.length,
                            connection2.supportedSecurityPolicies.includes("http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15")
                            ? 5 : 3);
                else
                    compare(connection2.supportedSecurityPolicies.length, 1);
                compare(connection2.supportedUserTokenTypes.length, 2);
            } else {
                fail(backendName, "is not support by this test case");
            }
        }
    }
}