TT#37951 Fix regression made in /api/admins

Now it accepts both true/false and 0/1

Change-Id: Ifb96c896745483038b4c6a2fa0f9f4b4929e0484
changes/96/21696/2
Irina Peshinskaya 8 years ago
parent b003c214a7
commit b96431b909

@ -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;
}

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

Loading…
Cancel
Save