From fcb03e435c5898d2ebb677a11daccc2cca07b832 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Tue, 27 Dec 2016 22:25:16 +0200 Subject: [PATCH] TT#8185 Fix domain deletion for the reseller Change-Id: Ia42db03fb9ddbb1b5d192b82fbf9b2f9ce881dff --- lib/NGCP/Panel/Controller/API/DomainsItem.pm | 3 ++- t/api-rest/api-domains.t | 4 ++-- t/lib/Test/Collection.pm | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/DomainsItem.pm b/lib/NGCP/Panel/Controller/API/DomainsItem.pm index 60a3fb7e74..dbd738a06b 100644 --- a/lib/NGCP/Panel/Controller/API/DomainsItem.pm +++ b/lib/NGCP/Panel/Controller/API/DomainsItem.pm @@ -117,7 +117,8 @@ sub DELETE :Allow { if($c->user->roles eq "admin") { } elsif($c->user->roles eq "reseller") { - unless($domain->domain_resellers->reseller_id == $c->user->reseller_id) { + #relation domain->domain_resellers is one to many. + unless($domain->domain_resellers->search({ reseller_id => $c->user->reseller_id })->first() ) { $self->error($c, HTTP_FORBIDDEN, "Domain does not belong to reseller"); last; } diff --git a/t/api-rest/api-domains.t b/t/api-rest/api-domains.t index 545f5ef7c7..54592ec7a1 100644 --- a/t/api-rest/api-domains.t +++ b/t/api-rest/api-domains.t @@ -29,12 +29,12 @@ $test_machine->DATA_ITEM_STORE($fake_data->process('domains')); $test_machine->form_data_item( ); # create 3 new sound sets from DATA_ITEM -$test_machine->check_create_correct( 1, sub{ $_[0]->{domain} .= $_[1]->{i}; } ); +$test_machine->check_create_correct( 1, sub{ $_[0]->{domain} .= $_[1]->{i}.time(); } ); $test_machine->check_bundle(); $test_machine->runas('reseller'); diag('8185: Run as reseller'); -$test_machine->check_create_correct( 1, sub{ $_[0]->{domain} .= 'reseller'.$_[1]->{i}; } ); +$test_machine->check_create_correct( 1, sub{ $_[0]->{domain} .= 'reseller'.$_[1]->{i}.time(); } ); $test_machine->check_bundle(); diff --git a/t/lib/Test/Collection.pm b/t/lib/Test/Collection.pm index 3fb3ee1d5c..6715d9c007 100644 --- a/t/lib/Test/Collection.pm +++ b/t/lib/Test/Collection.pm @@ -48,6 +48,11 @@ has 'DEBUG_ONLY' => ( isa => 'Bool', default => 0, ); +has 'QUIET_DELETION' => ( + is => 'rw', + isa => 'Bool', + default => 0, +); has 'ALLOW_EMPTY_COLLECTION' => ( is => 'rw', isa => 'Bool', @@ -607,6 +612,8 @@ sub request_delete{ diag($name.": Item $del_uri is absent already."); }elsif($res->code == 204){ diag($name.": Item $del_uri deleted."); + }elsif(!$self->QUIET_DELETION){ + $self->http_code_msg(204, "$name: check response from DELETE $uri", $res); } my $content = $self->get_response_content($res); if($self->cache_data){