Manager API: Fixed error when adding an app to non existing category - now returns a 404

Moo
Soisik Froger 5 years ago
parent 53cce170d2
commit e558b30628
  1. 5
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Menu/App.pm
  2. 8
      lemonldap-ng-manager/t/04-menu-api.t

@ -146,6 +146,11 @@ sub addMenuApp {
# Get latest configuration
my $conf = $self->_confAcc->getConf( { noCache => 1 } );
# Check if catConfKey is defined
return $self->sendError( $req,
"Menu category '$catConfKey' not found", 404 )
unless ( defined $conf->{applicationList}->{$catConfKey} );
return $self->sendError(
$req,
"Invalid input: A Menu Application with confKey $add->{confKey} already exists",

@ -100,6 +100,11 @@ sub checkAdd {
check201( $test, add( $test, $type, $add ) );
}
sub checkAddNotFound {
my ( $test, $type, $add ) = splice @_;
check404( $test, add( $test, $type, $add ) );
}
sub checkAddFailsIfExists {
my ( $test, $type, $add ) = splice @_;
check409( $test, add( $test, $type, $add ) );
@ -394,6 +399,9 @@ checkGetNotFound( $test, 'app/mycat2', 'myapp1' );
$test = "App - Get app myapp1 from mycat3 should err on not found";
checkGetNotFound( $test, 'app/mycat3', 'myapp1' );
$test = "App - Add app myapp1 to mycat3 should err on not found";
checkAddNotFound( $test, 'app/mycat3', $app1);
$test = "App - Add app1 to cat1 should succeed";
checkAdd( $test, 'app/mycat1', $app1 );
checkGet( $test, 'app/mycat1', 'myapp1', 'order', '1' );

Loading…
Cancel
Save