Skip to content

Commit

Permalink
[feat] compute GET /configuration (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrd authored Mar 29, 2023
1 parent f4f870f commit 8b3b2b0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ADDED:
- Ajout de la route GET /admin/1.0.0/services dans l'API d'administration
- Ajout de la route GET /admin/1.0.0/services/{service} dans l'API d'administration
- Ajout de la route GET /admin/1.0.0/services/{service}/restart dans l'API d'administration
- Ajout de la route GET /admin/1.0.0/configuration dans l'API d'administration
- Il est maintenant possible démarrer un administrateur sans services pré-configurés

CHANGED:
Expand Down
11 changes: 11 additions & 0 deletions src/js/administrator/administrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ module.exports = class Administrator {

}

/**
*
* @function
* @name get configuration
* @description Récupérer la configuration de l'administrateur
*
*/
get configuration () {
return this._configuration;
}

/**
*
* @function
Expand Down
27 changes: 27 additions & 0 deletions src/js/apis/admin/1.0.0/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,33 @@ router.route("/health")

});

// Configuration
// Pour avoir ou changer la configuration de l'administrateur
router.route("/configuration")

.get(async function(req, res, next) {

LOGGER.debug("requete GET sur /admin/1.0.0/configuration?");
LOGGER.debug(req.originalUrl);

// On récupère l'instance d'Administrator pour répondre aux requêtes
let administrator = req.app.get("administrator");

try {

// Envoie à l'administrateur et récupération de l'objet réponse
const configurationResponse = administrator.configuration;
LOGGER.debug(configurationResponse);

res.set('content-type', 'application/json');
res.status(200).json(configurationResponse);

} catch (error) {
return next(error);
}

});

// Services
// Pour avoir des informations sur les services
router.route("/services")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"1.0.0": {
"health": "/admin/1.0.0/health",
"version": "/admin/1.0.0/version",
"configuration": "/admin/1.0.0/configuration",
"services": "/admin/1.0.0/services",
"services/<service>": "/admin/1.0.0/services/<service>",
"services/<service>/restart": "/admin/1.0.0/services/<service>/restart"
Expand Down
24 changes: 24 additions & 0 deletions test/functional/request/cucumber/features/req-admin-1.0.0.feature
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@ Feature: Road2 with data
Then the server should send a response with status 404
And the response should contain "Not found"

Scenario: [admin/1.0.0] Configuration de l'administrateur
Given an "GET" request on operation "configuration" in api "admin" "1.0.0"
When I send the request
Then the server should send a response with status 200
And the response should contain "administration"

Scenario: [admin/1.0.0] Configuration de l'administrateur avec un mauvais parametre
Given an "GET" request on operation "configuration" in api "admin" "1.0.0"
And with query parameters:
| key | value |
| test | other |
When I send the request
Then the server should send a response with status 200
And the response should contain "administration"

Scenario: [admin/1.0.0] Configuration de l'administrateur en POST ne marche pas
Given an "POST" request on operation "configuration" in api "admin" "1.0.0"
And with query parameters:
| key | value |
| test | other |
When I send the request
Then the server should send a response with status 404
And the response should contain "Not found"

Scenario: [admin/1.0.0] Configurations des services
Given an "GET" request on operation "services" in api "admin" "1.0.0"
When I send the request
Expand Down

0 comments on commit 8b3b2b0

Please sign in to comment.