1 use Test::More tests => 12;
12 require 't/common.pl';
14 my $debug = $config{debug};
16 diag("Client library tests");
18 my $cli = OpenXPKI::Client->new(
20 SOCKETFILE => $config{socket_file},
23 ok(defined $cli, 'Client object defined');
25 ok($cli->init_session(), 'Init session');
26 #BAIL_OUT("exiting...");
29 ok($session_id = $cli->get_session_id(), 'get_session_id()');
30 diag("Got session id $session_id");
32 ok($cli->get_communication_state() eq 'can_send', 'status: can_send');
34 my $response = $cli->send_receive_service_msg('PING');
36 ok($response->{SERVICE_MSG} eq 'GET_AUTHENTICATION_STACK', 'Response is GET_AUTHENTICATION_STACK') or diag Dumper $response;
37 ok(exists $response->{PARAMS}->{AUTHENTICATION_STACKS}->{Anonymous}, 'Response contains anonymous auth stack') or diag Dumper $response;
41 $response = $cli->send_receive_service_msg('GET_AUTHENTICATION_STACK',
43 AUTHENTICATION_STACK => 'Anonymous',
45 is($response->{SERVICE_MSG}, 'SERVICE_READY', 'Anonymous login') or diag Dumper $response;
48 # try to operate a simple Server API function
49 $response = $cli->get_API()->nop();
52 is(ref $response, 'HASH', 'NOP response is a hash') or diag Dumper $response;
53 is($response->{SERVICE_MSG}, 'COMMAND', 'NOP SERVICE_MSG is COMMAND') or diag Dumper $response;
54 is($response->{COMMAND}, 'nop', 'NOP COMMAND is nop') or diag Dumper $response;
55 ok(exists $response->{PARAMS}, 'PARAMS reply exists') or diag Dumper $response;
56 ok(! defined $response->{PARAMS}, 'PARAMS reply is undef') or diag Dumper $response;