Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] compute GET /configuration #59

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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