NAME
OPCUA::Open62541::Test::Client - run open62541 client for testing
SYNOPSIS
use OPCUA::Open62541::Test::Client;
use Test::More tests => OPCUA::Open62541::Test::Client::planning();
my $client = OPCUA::Open62541::Test::Client->new();
DESCRIPTION
In a module test start and run an open62541 OPC UA client that connects to a server. The client is considered part of the test and will write to the TAP stream.
- OPCUA::Open62541::Test::Client::planning
-
Return the number of tests results that running one client will create. Add this to your number of planned tests.
METHODS
- $client = OPCUA::Open62541::Test::Client->new(%args);
-
Create a new test client instance.
- $args{host}
-
Hostname or IP of the server. Defaults to localhost.
- $args{port}
-
Optional port number of the server.
- $args{url}
-
URL of the server. Overwrites host and port arguments.
- $args{certificate}
-
Certificate in PEM or DER format for signing and encryption. If the certificate and privateKey parameters are set, the client config will be configured with the relevant security policies.
By default the client will match any security policy from the server. Set the security mode with
$client_config->setSecurityMode(MESSAGESECURITYMODE_SIGNANDENCRYPT).
- $args{privateKey}
-
Private key in PEM or DER format that has to match the certificate.
- $args{trustList}
-
Array reference with a list of trusted certificates in PEM or DER format.
- $args{revocationList}
-
Array reference with a list of certificate revocation lists (CRL) in PEM or DER format.
- $args{logfile}
-
Logs to the specified file instead of "client.log" in the current directory.
- $args{timeout}
-
Maximum time the client will run during iterate. Defaults to 10 seconds.
- $client->url($url)
-
Returns the URL of the server. Can also set the URL by passing an argument.
- $client->start()
-
Configure the client.
- $client->run()
-
Connect the client to the open62541 server.
- $client->iterate(\$end, $ident)
-
Run the iterate function of the client for up to 5 seconds. This has to be done to complete asynchronous calls. The scalar reference to $end is used to finish the iteration loop successfully when set to true in a callback. Otherwise the loop terminates with failure if the status of client run_iterate() is not good or after calling it 50 times. If $ident is set, it is used to identify a passed or failed test. This one test is not included in planning().
If $end is undef, the iteration will continue until the client has disconnected. If $end is an array or hash reference, the iteration will continue until the array or hash is empty. If $end is a code reference, the iteration will continue until the function call returns true.
- $client->iterate_connect($ident)
-
Run iterate until connected and session is activated.
- $client->iterate_disconnect($ident)
-
Run iterate until session or connection are closed.
- $client->stop()
-
Disconnect the client from the open62541 server.
SEE ALSO
OPCUA::Open62541, OPCUA::Open62541::Test::Server, OPCUA::Open62541::Test::Logger
AUTHORS
Alexander Bluhm <bluhm@genua.de>, Anton Borowka
COPYRIGHT AND LICENSE
Copyright (c) 2020-2023 Alexander Bluhm
Copyright (c) 2020-2023 Anton Borowka
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Thanks to genua GmbH, https://www.genua.de/ for sponsoring this work.