diff --git a/lib/Ravada.pm b/lib/Ravada.pm index 0b1d2d1a3..b113f30af 100644 --- a/lib/Ravada.pm +++ b/lib/Ravada.pm @@ -6367,6 +6367,7 @@ sub _req_method { ,pause => \&_cmd_pause ,create => \&_cmd_create ,remove => \&_cmd_remove + ,remove_domain => \&_cmd_remove ,remove_clones => \&_cmd_remove_clones ,restore_domain => \&_cmd_restore_domain ,resume => \&_cmd_resume diff --git a/t/mojo/10_login.t b/t/mojo/10_login.t index 2e1514d3a..6591e2396 100644 --- a/t/mojo/10_login.t +++ b/t/mojo/10_login.t @@ -365,10 +365,15 @@ sub test_login_non_admin_req($t, $base, $clone){ mojo_check_login($t, $name, $pass); $base->is_public(0); + $base->show_clones(1); $t->get_ok("/machine/clone/".$base->id.".html") ->status_is(200); die "Error cloning ".$base->id if $t->tx->res->code() != 200; + + $base->show_clones(0); + $t->get_ok("/machine/clone/".$base->id.".html") + ->status_is(403); } diff --git a/t/mojo/30_settings.t b/t/mojo/30_settings.t index f7983bc47..4698c4786 100644 --- a/t/mojo/30_settings.t +++ b/t/mojo/30_settings.t @@ -512,7 +512,39 @@ sub clean_clones() { } } +sub _create_storage_pool($id_vm , $vm_name) { + $t->get_ok("/list_storage_pools/$vm_name"); + my $sp = decode_json($t->tx->res->body); + my $name = new_pool_name(); + my ($found) = grep { $_->{name} eq $name } @$sp; + return $name if $found; + + my $dir0 = "/var/tmp/$$/"; + + mkdir $dir0 if !-e $dir0; + + my $dir = $dir0."/".new_pool_name(); + + mkdir $dir or die "$! $dir" if !-e $dir; + + + my $req = Ravada::Request->create_storage_pool( + uid => user_admin->id + ,id_vm => $id_vm + ,name => $name + ,directory => $dir + ); + wait_request( ); + is($req->error,''); + + return $name; +} + sub test_storage_pools($vm_name) { + + my $id_vm = _id_vm($vm_name); + my $sp_name = _create_storage_pool($id_vm, $vm_name); + $t->get_ok("/list_storage_pools/$vm_name"); is($t->tx->res->code(),200) or die $t->tx->res->body; @@ -520,8 +552,6 @@ sub test_storage_pools($vm_name) { my $sp = decode_json($t->tx->res->body); ok(scalar(@$sp)); - my $id_vm = _id_vm($vm_name); - $t->get_ok("/list_storage_pools/$id_vm"); is($t->tx->res->code(),200) or die $t->tx->res->body; @@ -532,11 +562,6 @@ sub test_storage_pools($vm_name) { my ($sp_inactive) = grep { $_->{name} ne 'default' } @$sp_id; - if ( !$sp_inactive ) { -# warn "Warning: no sp in addition to 'default' in ".Dumper($sp_id); - $sp_inactive = $sp_id->[0]; - } - my $name_inactive= $sp_inactive->{name}; die "Error, no name in ".Dumper($sp_inactive) if !$name_inactive;