Skip to content

Commit

Permalink
feat(projection): return 400 if empty parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkerloch committed Apr 6, 2023
1 parent 0c48625 commit a6e4ed7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/js/administrator/administrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ module.exports = class Administrator {
* @description Gestion de la requête pour une route d'administration sur un serveur
* @param {string} serviceId - Id du service selon l'administrateur
* @param {object} request - Instance fille de la classe Request
* @return {object} responses - Json contenant la réponse du service à la requête
*
*/

Expand Down
6 changes: 3 additions & 3 deletions src/js/apis/admin/1.0.0/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = {
throw errorManager.createError(" Parameter 'service' is invalid: there is no value", 400);
}

if (parameters.service === "") {
if (parameters.service.trim() === "") {
throw errorManager.createError(" Parameter 'service' is invalid: value should not be empty", 400);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ module.exports = {
throw errorManager.createError(" Parameter 'service' is invalid: there is no value", 400);
}

if (parameters.service === "") {
if (parameters.service.trim() === "") {
throw errorManager.createError(" Parameter 'service' is invalid: value should not be empty", 400);
}

Expand All @@ -142,7 +142,7 @@ module.exports = {
throw errorManager.createError(" Parameter 'projection' is invalid: there is no value", 400);
}

if (parameters.projection === "") {
if (parameters.projection.trim() === "") {
throw errorManager.createError(" Parameter 'projection' is invalid: value should not be empty", 400);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,24 @@ Feature: Road2 with data
| service | Unknown |
| projection | Unknown |
When I send the request
Then the server should send a response with status 404
Then the server should send a response with status 404

Scenario: [admin/1.0.0] Projection sur service non défini
Given an "GET" request on operation "services/<service>/projections/<projection>" in api "admin" "1.0.0"
And with path parameters:
| key | value |
| service | %20 |
| projection | EPSG:4326 |
When I send the request
Then the server should send a response with status 400


Scenario: [admin/1.0.0] Projection non définie sur service "main"
Given an "GET" request on operation "services/<service>/projections/<projection>" in api "admin" "1.0.0"
And with path parameters:
| key | value |
| service | main |
| projection | %20 |
When I send the request
Then the server should send a response with status 400

0 comments on commit a6e4ed7

Please sign in to comment.