mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-01 19:17:47 +00:00
Adding configuration validation.
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# OpenWiFi Provisioning
|
# OpenWiFi Provisioning
|
||||||
|
|
||||||
|
## Build from source.
|
||||||
|
You need: https://github.com/pboettch/json-schema-validator.git
|
||||||
|
You need: https://github.com/nlohmann/json.git
|
||||||
|
build and install them.
|
||||||
|
|
||||||
## Root entity
|
## Root entity
|
||||||
It's UUID value is 0000-0000-0000. Its parent entity must be empty.
|
It's UUID value is 0000-0000-0000. Its parent entity must be empty.
|
||||||
|
|
||||||
|
|||||||
@@ -1934,6 +1934,11 @@ paths:
|
|||||||
format: uuid
|
format: uuid
|
||||||
example: When creating the root entity, the uuid 0000-0000-0000 must be entered. When creating a non-root entity, uuid must be 1
|
example: When creating the root entity, the uuid 0000-0000-0000 must be entered. When creating a non-root entity, uuid must be 1
|
||||||
required: true
|
required: true
|
||||||
|
- in: query
|
||||||
|
name: validateOnly
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Information used to create the new entity
|
description: Information used to create the new entity
|
||||||
content:
|
content:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenWifi {
|
|||||||
std::unique_ptr<json_validator> Validator_;
|
std::unique_ptr<json_validator> Validator_;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ValidateUCentralConfiguration(const std::string &C) { return ConfigurationValidator::instance()->Validate(C); }
|
inline bool ValidateUCentralConfiguration(const std::string &C) { return ConfigurationValidator::instance()->Validate(C); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OWPROV_CONFIGURATIONVALIDATOR_H
|
#endif //OWPROV_CONFIGURATIONVALIDATOR_H
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "RESTAPI_errors.h"
|
#include "RESTAPI_errors.h"
|
||||||
|
|
||||||
|
#include "ConfigurationValidator.h"
|
||||||
|
|
||||||
namespace OpenWifi{
|
namespace OpenWifi{
|
||||||
|
|
||||||
void RESTAPI_configurations_handler::DoGet() {
|
void RESTAPI_configurations_handler::DoGet() {
|
||||||
@@ -103,6 +105,21 @@ namespace OpenWifi{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Arg;
|
||||||
|
if(HasParameter("validateOnly",Arg) && Arg=="true") {
|
||||||
|
auto Body = ParseStream();
|
||||||
|
if(!Body->has("configuration")) {
|
||||||
|
BadRequest("Must have 'configuration' element.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto Config=Body->get("configuration").toString();
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
auto Res = ValidateUCentralConfiguration(Config);
|
||||||
|
Answer.set("valid",Res);
|
||||||
|
ReturnObject(Answer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ProvObjects::DeviceConfiguration C;
|
ProvObjects::DeviceConfiguration C;
|
||||||
Poco::JSON::Object::Ptr Obj = ParseStream();
|
Poco::JSON::Object::Ptr Obj = ParseStream();
|
||||||
if (!C.from_json(Obj)) {
|
if (!C.from_json(Obj)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user