Skip to content

Commit

Permalink
test(frontend): fetch node info
Browse files Browse the repository at this point in the history
issue #2032
  • Loading branch information
frankiejol committed Mar 8, 2024
1 parent 43f5b78 commit adbe958
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions t/mojo/20_ws.t
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,36 @@ sub test_remove_booking_entry_non_admin($t, $id) {

}

sub test_node_info($vm_name) {
my $sth = connector->dbh->prepare("SELECT * FROM vms WHERE vm_type=?");
$sth->execute($vm_name);

my $user = create_user(new_domain_name(), $$);

while ( my $node = $sth->fetchrow_hashref) {
my $ws_args = {
channel => '/'.$node->{id}
,login => user_admin->name
};

my $node_info = Ravada::WebSocket::_get_node_info
(rvd_front(), $ws_args);
if ($node->{hostname} =~ /localhost|127.0.0.1/) {
is($node_info->{is_local},1);
} else {
is($node_info->{is_local},0);
}

$ws_args->{login} = $user->name;

$node_info = Ravada::WebSocket::_get_node_info
(rvd_front(), $ws_args);

is_deeply($node_info,{});
}

}

########################################################################################

init('/etc/ravada.conf',0);
Expand Down Expand Up @@ -379,6 +409,8 @@ for my $vm_name ( @{rvd_front->list_vm_types} ) {

diag("Testing Web Services in $vm_name");

test_node_info($vm_name);

mojo_login($t, $USERNAME, $PASSWORD);
test_bookings($t);
my @bases = _create_bases($t, $vm_name);
Expand Down

0 comments on commit adbe958

Please sign in to comment.