Skip to content

Commit de480fa

Browse files
committed
fix TC_042_1_CS and TC_043_1_CS / local auth list not supported
1 parent 0455ec0 commit de480fa

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

src/MicroOcpp/Model/Authorization/AuthorizationService.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool AuthorizationService::loadLists() {
7575
}
7676

7777
AuthorizationData *AuthorizationService::getLocalAuthorization(const char *idTag) {
78-
if (!localAuthListEnabledBool->getBool()) {
78+
if (!localAuthListEnabled()) {
7979
return nullptr; //auth cache will follow
8080
}
8181

@@ -101,6 +101,10 @@ size_t AuthorizationService::getLocalListSize() {
101101
return localAuthorizationList.size();
102102
}
103103

104+
bool AuthorizationService::localAuthListEnabled() const {
105+
return localAuthListEnabledBool && localAuthListEnabledBool->getBool();
106+
}
107+
104108
bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential) {
105109
bool success = localAuthorizationList.readJson(localAuthorizationListJson, listVersion, differential, false);
106110

@@ -127,7 +131,7 @@ bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson,
127131
void AuthorizationService::notifyAuthorization(const char *idTag, JsonObject idTagInfo) {
128132
//check local list conflicts. In future: also update authorization cache
129133

130-
if (!localAuthListEnabledBool->getBool()) {
134+
if (!localAuthListEnabled()) {
131135
return; //auth cache will follow
132136
}
133137

src/MicroOcpp/Model/Authorization/AuthorizationService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AuthorizationService : public MemoryManaged {
3535
AuthorizationData *getLocalAuthorization(const char *idTag);
3636

3737
int getLocalListVersion();
38+
bool localAuthListEnabled() const;
3839
size_t getLocalListSize(); //number of entries in current localAuthList; used in unit tests
3940

4041
bool updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential);

src/MicroOcpp/Model/Model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void Model::updateSupportedStandardProfiles() {
317317
}
318318

319319
#if MO_ENABLE_LOCAL_AUTH
320-
if (authorizationService) {
320+
if (authorizationService && authorizationService->localAuthListEnabled()) {
321321
if (!strstr(supportedFeatureProfilesString->getString(), "LocalAuthListManagement")) {
322322
if (!buf.empty()) buf += ',';
323323
buf += "LocalAuthListManagement";

src/MicroOcpp/Operations/GetLocalListVersion.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ std::unique_ptr<JsonDoc> GetLocalListVersion::createConf(){
3030
auto doc = makeJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
3131
JsonObject payload = doc->to<JsonObject>();
3232

33-
if (auto authService = model.getAuthorizationService()) {
33+
auto authService = model.getAuthorizationService();
34+
if (authService && authService->localAuthListEnabled()) {
3435
payload["listVersion"] = authService->getLocalListVersion();
3536
} else {
37+
//TC_042_1_CS Get Local List Version (not supported)
3638
payload["listVersion"] = -1;
3739
}
3840
return doc;

src/MicroOcpp/Operations/SendLocalList.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ const char* SendLocalList::getOperationType(){
2727

2828
void SendLocalList::processReq(JsonObject payload) {
2929

30+
//TC_043_1_CS Send Local Authorization List - NotSupported
31+
if (!authService.localAuthListEnabled()) {
32+
errorCode = "NotSupported";
33+
return;
34+
}
35+
3036
if (!payload.containsKey("listVersion") || !payload.containsKey("updateType")) {
3137
errorCode = "FormationViolation";
3238
return;

0 commit comments

Comments
 (0)