eclipse-kura / kura

Eclipse Kura™ is a versatile framework to supercharge your edge devices, streamlining the process of configuring your gateway, connecting sensors, and IoT devices to seamlessly collect, process, and send data to the cloud.
https://eclipse.dev/kura/
Eclipse Public License 2.0
506 stars 312 forks source link

fix(rest.identity): fixed status codes and error messages for malformed requests #5267

Closed sfiorani closed 5 months ago

sfiorani commented 5 months ago

This PR modifies the response status code and error message in case of malformed request body for Identity/Permission REST APIs of IdentityV2.

When the request doesn't contain the name key or it's wrong (eg: nam), the corresponding DTO (Identity or Permission DTO) will have a null value as name. On Kura side, null/empty checks were missing, so the IdentityService was trying to remove something that it could not found, responding with a 404 status code with message Identity not found.

After this change, the null/empty checks are added: if the name value is null (missing or wrong name field) or empty, a 400 status code is returned with an appropriate message.

Related Issue:

Description of the solution adopted:

Screenshots:

Manual Tests:

Any side note on the changes made: