From 09eba509bd53f335dffc3d61b1706dd45af1c2ce Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Mon, 5 Feb 2018 13:36:45 +0200 Subject: [PATCH] TT#32203 Fix voicemailgreetings filters Change-Id: Ibca07c82732d84b911e0c469258edcd9a7848b0a --- lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm | 10 ++++------ t/api-rest/api-voicemailgreetings.t | 13 ++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm b/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm index 4fa5d54d1e..2aafe040d5 100644 --- a/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm +++ b/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm @@ -35,10 +35,8 @@ sub query_params { my $c = shift; my %wheres = (); if( $c->config->{features}->{multidomain}) { - $wheres{'domain.id'} = { -ident => 'subscriber.domain_id' }; + $wheres{'domain.id'} = { -ident => 'voip_subscriber.domain_id' }; } - - my $h = return { 'voip_subscriber.id' => $q, %wheres, @@ -47,12 +45,12 @@ sub query_params { second => sub { my $q = shift; my $c = shift; - my @joins = (); + my $subscriber_join = 'voip_subscriber'; if( $c->config->{features}->{multidomain}) { - push @joins, 'domain' ; + $subscriber_join = { 'voip_subscriber' => 'domain' }; } return { - join => [{ subscriber => 'voip_subscriber' },@joins] + join => [{ 'mailboxuser' => { 'provisioning_voip_subscriber' => $subscriber_join }}] }; }, }, diff --git a/t/api-rest/api-voicemailgreetings.t b/t/api-rest/api-voicemailgreetings.t index 56c427d6f9..d7478de453 100644 --- a/t/api-rest/api-voicemailgreetings.t +++ b/t/api-rest/api-voicemailgreetings.t @@ -48,11 +48,15 @@ is($greeting->{content}->{subscriber_id}, $test_machine->DATA_ITEM->{json}->{sub ok($greeting->{content}->{dir} =~/^(?:unavail|busy)$/, "Check dir after creation."); is($greeting->{content}->{dir}, $test_machine->DATA_ITEM->{json}->{dir}, "Check dir after creation #2."); +$res = $test_machine->request_get('/api/voicemailgreetings/?subscriber_id='.$greeting->{content}->{subscriber_id}.'&type='.$greeting->{content}->{dir}); +$test_machine->http_code_msg(200, "check subscriber_id and type filters", $res); + $res = $test_machine->request_get($greeting->{location}, undef, { 'Accept' => 'audio/x-wav', }); $test_machine->http_code_msg(200, "check download voicemail greeting", $res); + my $expected_downloaded_name = "voicemail_".$greeting->{content}->{dir}."_".$greeting->{content}->{subscriber_id}.".wav"; is($res->filename, $expected_downloaded_name ,"Check downloaded file name: $expected_downloaded_name ."); ok(length($res->content)>0,"Check length of the downloaded file > 0 :".length($res->content)); @@ -100,18 +104,13 @@ if(ok($soxi_output =~/GSM/, "Check that we converted wav to GSM encoding:".$soxi greetingfile => [ dirname($0).'/resources/empty.wav' ], } ); $test_machine->http_code_msg(422, "check response code on put empty file", $res_put_empty, $content_put_empty); - diag("Check dirty file:"); - #btw - other vriant of tha put data - closer to stored. will be changed by Collection::encode_content - ($res_put_empty,$content_put_empty) = $test_machine->request_put({ - 'data_cb' => $fake_data->{data}->{'voicemailgreetings'}->{data_callbacks}->{get2put}, - } ); - $test_machine->http_code_msg(422, "check response code on put empty file", $res_put_empty, $content_put_empty); } $test_machine->check_bundle(); $test_machine->check_item_delete($greeting->{location}); - $test_machine->clear_test_data_all();#fake data aren't registered in this test machine, so they will stay. +undef $fake_data; +undef $test_machine; done_testing;