From 8e118c7404feb044f7de81d2fa250e0616e627bf Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Tue, 27 Aug 2019 18:41:10 +0200 Subject: [PATCH] Revert "TT#64605 add usrloc_expires_type support" This reverts commit 73dd45c93a30d869b20348b4b474ce72044f48ea. Change-Id: Ia040c63ef2e0cc711812f4a4d17093ae753531ab --- lib/NGCP/Panel/Utils/Kamailio.pm | 11 ++++------- t/api-rest/api-subscriberregistrations.t | 25 ++++++------------------ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/lib/NGCP/Panel/Utils/Kamailio.pm b/lib/NGCP/Panel/Utils/Kamailio.pm index e26c1bb00f..18582ad712 100644 --- a/lib/NGCP/Panel/Utils/Kamailio.pm +++ b/lib/NGCP/Panel/Utils/Kamailio.pm @@ -45,23 +45,20 @@ sub create_location { my($contact, $q, $expires, $flags, $cflags) = @$params{qw/contact q expires flags cflags/}; my $aor = get_aor($c, $prov_subscriber); my $path = _compose_location_path($c, $prov_subscriber, $params);#compose path from path or socket from params - my $exp_type = $c->config->{sip}{usrloc_expires_type} // ''; if ($expires) { + $expires = NGCP::Panel::Utils::DateTime::from_string($expires)->epoch; $expires //= 0; - if ($exp_type ne 'epoch') { - $expires = NGCP::Panel::Utils::DateTime::from_string($expires)->epoch; - $expires -= time(); - } + $expires -= time(); # "expires" is required to be an integer but it is not a timestamp # <=0: 1970-01-01 00:00:00 # 1: now # >=1: now + seconds to the future + } else { + $expires = 4294967295; } - $expires //= 4294967295; $expires = 0 if $expires < 0; $flags //= 0; $cflags //= 0; - my $ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "proxy-ng", 1, 1, < diff --git a/t/api-rest/api-subscriberregistrations.t b/t/api-rest/api-subscriberregistrations.t index 51b35c7247..6d62825bb8 100644 --- a/t/api-rest/api-subscriberregistrations.t +++ b/t/api-rest/api-subscriberregistrations.t @@ -8,18 +8,6 @@ use Data::Dumper; use NGCP::Panel::Utils::DateTime; -use Config::General; -my $catalyst_config; -my $panel_config; -for my $path(qw#/etc/ngcp-panel/ngcp_panel.conf etc/ngcp_panel.conf ngcp_panel.conf#) { - if(-f $path) { - $panel_config = $path; - last; - } -} -$panel_config //= 'etc/ngcp_panel.conf'; -$catalyst_config = Config::General->new($panel_config); -my %config = $catalyst_config->getall(); #init test_machine my $test_machine = Test::Collection->new( @@ -31,14 +19,13 @@ my $fake_data = Test::FakeData->new; $test_machine->methods->{collection}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS POST)}; $test_machine->methods->{item}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS PUT PATCH DELETE)}; -my $exp_type = $config{sip}{usrloc_expires_type} // ''; -my $expires = $exp_type eq 'epoch' ? 0 : NGCP::Panel::Utils::DateTime::current_local(); +my $expires = NGCP::Panel::Utils::DateTime::current_local(); $fake_data->set_data_from_script({ 'subscriberregistrations' => { data => { 'contact' => 'test', - 'expires' => $exp_type eq 'epoch' ? $expires : $expires->ymd('-').' '.$expires->hms(':'), + 'expires' => $expires->ymd('-') . ' ' . $expires->hms(':'), 'q' => 0.5, 'subscriber_id' => sub { return shift->get_id('subscribers', @_); }, }, @@ -52,10 +39,10 @@ $test_machine->form_data_item( ); # create 3 new vouchers from DATA_ITEM $test_machine->check_create_correct( 3, sub{ $_[0]->{contact} .= time().'_'.$_[1]->{i} ; } ); -#order of [check_bundle, check_get2put ] is important here: -#subscriberregistrations really is just a wrapper arounf kamailio rpc calls, -#and update of the existing item is made as delete+create. So, on every PUT or PATCH we delete item, and create new. -#It makes internal Collection list of created items misordered with real data in db, +#order of [check_bundle, check_get2put ] is important here: +#subscriberregistrations really is just a wrapper arounf kamailio rpc calls, +#and update of the existing item is made as delete+create. So, on every PUT or PATCH we delete item, and create new. +#It makes internal Collection list of created items misordered with real data in db, #because Collection just keeps all created item, and doesn't try to recreate them on every update $test_machine->check_bundle(); $test_machine->clear_test_data_all();