diff --git a/lib/NGCP/Panel/Role/API/Admins.pm b/lib/NGCP/Panel/Role/API/Admins.pm index 5760cf7229..66a55662fe 100644 --- a/lib/NGCP/Panel/Role/API/Admins.pm +++ b/lib/NGCP/Panel/Role/API/Admins.pm @@ -80,7 +80,7 @@ sub process_form_resource{ $resource->{saltedpass} = NGCP::Panel::Utils::Admin::generate_salted_hash($pass); } foreach my $f(qw/billing_data call_data is_active is_master is_superuser lawful_intercept read_only show_passwords/) { - $resource->{$f} = (ref $resource->{$f} eq 'JSON::true' || (defined $resource->{$f} and $resource->{$f} eq 'true')) ? 1 : 0; + $resource->{$f} = (ref $resource->{$f} eq 'JSON::true' || ( defined $resource->{$f} && ( $resource->{$f} eq 'true' || $resource->{$f} eq '1' ) ) ) ? 1 : 0; } return $resource; } diff --git a/t/api-rest/api-admins-collection.t b/t/api-rest/api-admins-collection.t index 7b1d890879..c2751dac7c 100644 --- a/t/api-rest/api-admins-collection.t +++ b/t/api-rest/api-admins-collection.t @@ -41,10 +41,19 @@ $test_machine->DATA_ITEM_STORE($fake_data->process('admins')); $test_machine->form_data_item( ); # create 3 new admins from DATA_ITEM -my $admins = $test_machine->check_create_correct( 3 , sub { - $_[0]->{login}.=seq() +my $admins = $test_machine->check_create_correct( 2 , sub { + $_[0]->{login}.=time().seq() }); ok($admins->[0]->{content}->{is_active},"Check if newly created admin is active"); +my $admins2 = $test_machine->check_create_correct( 2 , sub { + $_[0]->{login}.=time().seq(); + print "login=".$_[0]->{login}.";"; + foreach my $field(qw/is_active is_master is_superuser billing_data call_data lawful_intercept read_only show_passwords/) { + $_[0]->{$field} = $_[0]->{$field} eq 'true' ? '1' : '0'; + } +}); +ok($admins2->[0]->{content}->{is_active},"Check if newly created admin is active"); + $test_machine->check_bundle(); $test_machine->clear_test_data_all();