|
|
|
@ -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();
|
|
|
|
|