Skip to content

Commit

Permalink
Improved test for spice password
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jun 1, 2017
1 parent 6e3e5bc commit 4d899a6
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions t/kvm/p10_password.t
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,38 @@ sub test_any_network_password_hybernate{

$domain->hybernate($USER);
is($domain->is_active(),0);
is($domain->is_hibernated(),1,"Domain should be hybernated");

eval { $domain->start(user => $USER, remote_ip => '10.0.0.1') };
is($@,'',"Expecting no error start hybernated domain, got : '".($@ or '')."'");
is($domain->is_active(),1);
ok(!$@,"Expecting no error start hybernated domain, got : '".($@ or '')."'");
is($domain->is_active(),1,"Expecting domain active");

$password = $domain->spice_password();
is($password, undef ,"Expecting no password, got '".($password or '')."'");

$domain->hybernate($USER);
is($domain->is_active(),0);
is($password, undef ,"Expecting no password, got '".($password or '')."' after hybernate");

$domain->start(user => $USER, remote_ip => '1.2.3.4');
# create another domain to start from far away
$domain = $vm->create_domain( name => new_domain_name
, id_iso => 1 , id_owner => $USER->id);

$password = $domain->spice_password();
eval {
$domain->start($USER) if !$domain->is_active;
for ( 1 .. 10 ){
last if $domain->is_active;
sleep 1;
}
$domain->hybernate($USER);
};
ok(!$@,"Expecting no error after \$domain->hybernate, got : '".($@ or '')."'");
is($domain->is_active(),0,"Domain should not be active, got :".$domain->is_active);
is($domain->is_hibernated(),1,"Domain should be hybernated");

eval { $domain->start(user => $USER, remote_ip => '1.2.3.4') };
ok(!$@,"Expecting no error after \$domain->start, got : '".($@ or '')."'");

eval { $password = $domain->spice_password() };
is($@,'',"Expecting no error after \$domain->spice_password hybernate/start");
like($password,qr/./,"Expecting a password, got '".($password or '')."'");
$domain->shutdown_now($USER);
$domain->shutdown_now($USER) if $domain->is_active;

}

Expand Down Expand Up @@ -271,12 +287,12 @@ SKIP: {
$domain1->start(user => $USER, remote_ip => '10.0.0.1');
my $password = $domain1->spice_password();
is($password,undef,"Expecting no password, got : '".($password or '')."'");
$domain1->shutdown_now($USER);
$domain1->shutdown_now($USER) if $domain1->is_active;

$domain2->start(user => $USER, remote_ip => '10.0.0.1');
$password = $domain2->spice_password();
is($password,undef,"Expecting no password, got : '".($password or '')."'");
$domain2->shutdown_now($USER);
$domain2->shutdown_now($USER) if $domain2->is_active;

test_domain_no_password($vm_name);

Expand Down

0 comments on commit 4d899a6

Please sign in to comment.