Skip to content

Commit

Permalink
Improved local and default networks tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jun 2, 2017
1 parent cbdcf69 commit f8911dd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sql/data/insert_networks.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
insert into networks (name, address,n_order, all_domains,requires_password)
VALUES ('localnet', '127.0.0.0/24',1,1,0);
VALUES ('localnet', '127.0.0.0/8',1,1,0);
insert into networks (name, address,n_order, all_domains,requires_password)
VALUES ('default', '0.0.0.0/0',99,1,1);

2 changes: 2 additions & 0 deletions sql/mysql/networks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ CREATE TABLE `networks` (
`no_domains` int(11) DEFAULT '0',
`requires_password` int(11) DEFAULT '0',
`n_order` int(11) DEFAULT '0',
unique('address'),
unique('name'),
PRIMARY KEY (`id`)
);
1 change: 1 addition & 0 deletions sql/sqlite/networks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ CREATE TABLE `networks` (
, `no_domains` integer DEFAULT '0'
, `requires_password` integer DEFAULT '0'
, `n_order` integer DEFAULT '0'
, unique('address')
);
31 changes: 28 additions & 3 deletions t/kvm/p10_password.t
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ sub test_any_network_password {
$domain->start(user => $USER, remote_ip => '127.0.0.1');

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

$domain->start(user => $USER, remote_ip => '10.0.0.1');
Expand Down Expand Up @@ -236,6 +236,10 @@ sub add_network_10 {
$requires_password = 1 if !defined $requires_password;

my $sth = $test->connector->dbh->prepare(
"DELETE FROM networks where address='10.0.0.0/24'"
);
$sth->execute;
$sth = $test->connector->dbh->prepare(
"INSERT INTO networks (name,address,all_domains,requires_password)"
."VALUES('10','10.0.0.0/24',1,?)"
);
Expand All @@ -247,8 +251,13 @@ sub add_network_any {
$requires_password = 1 if !defined $requires_password;

my $sth = $test->connector->dbh->prepare(
"INSERT INTO networks (name,address,all_domains,requires_password)"
."VALUES('any','0.0.0.0/0',1,?)"
"DELETE FROM networks where address='0.0.0.0/0'"
);
$sth->execute;

$sth = $test->connector->dbh->prepare(
"INSERT INTO networks (name,address,all_domains,requires_password,n_order)"
."VALUES('any','0.0.0.0/0',1,?,999)"
);
$sth->execute($requires_password);
}
Expand All @@ -261,6 +270,15 @@ sub remove_network_10 {

}

sub remove_network_default {
my $sth = $test->connector->dbh->prepare(
"DELETE FROM networks where name='default'"
);
$sth->execute();

}


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

clean();
Expand All @@ -286,6 +304,13 @@ SKIP: {

$domain1->start(user => $USER, remote_ip => '10.0.0.1');
my $password = $domain1->spice_password();
ok($password,"Expecting password, got : '".($password or '')."'");

remove_network_default();
$domain1->shutdown_now($USER);
$domain1->start(user => $USER, remote_ip => '10.0.0.1');
$password = $domain1->spice_password();

is($password,undef,"Expecting no password, got : '".($password or '')."'");
$domain1->shutdown_now($USER) if $domain1->is_active;

Expand Down

0 comments on commit f8911dd

Please sign in to comment.