Skip to content

Commit 5cfcc02

Browse files
authored
Merge pull request #425 from vampirebyte/fix-unsupported-local-auth-list-not-supported-test-case
fix TC_042_1_CS and TC_043_1_CS / local auth list not supported
2 parents da3428a + 9a4f1da commit 5cfcc02

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

.github/workflows/documentation.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/setup-python@v4
2222
with:
2323
python-version: 3.x
24-
- uses: actions/cache@v2
24+
- uses: actions/cache@v4
2525
with:
2626
key: ${{ github.ref }}
2727
path: .cache
@@ -101,14 +101,14 @@ jobs:
101101
steps:
102102
- uses: actions/checkout@v3
103103
- name: Cache pip
104-
uses: actions/cache@v2
104+
uses: actions/cache@v4
105105
with:
106106
path: ~/.cache/pip
107107
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
108108
restore-keys: |
109109
${{ runner.os }}-pip-
110110
- name: Cache PlatformIO
111-
uses: actions/cache@v2
111+
uses: actions/cache@v4
112112
with:
113113
path: ~/.platformio
114114
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
@@ -142,7 +142,7 @@ jobs:
142142
- uses: actions/setup-python@v4
143143
with:
144144
python-version: 3.x
145-
- uses: actions/cache@v2
145+
- uses: actions/cache@v4
146146
with:
147147
key: ${{ github.ref }}
148148
path: .cache
@@ -194,7 +194,7 @@ jobs:
194194
- uses: actions/setup-python@v4
195195
with:
196196
python-version: 3.x
197-
- uses: actions/cache@v2
197+
- uses: actions/cache@v4
198198
with:
199199
key: ${{ github.ref }}
200200
path: .cache

.github/workflows/pio.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ jobs:
2020
example: [examples/ESP/main.cpp, examples/ESP-TLS/main.cpp]
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
2424
- name: Cache pip
25-
uses: actions/cache@v2
25+
uses: actions/cache@v4
2626
with:
2727
path: ~/.cache/pip
2828
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
2929
restore-keys: |
3030
${{ runner.os }}-pip-
3131
- name: Cache PlatformIO
32-
uses: actions/cache@v2
32+
uses: actions/cache@v4
3333
with:
3434
path: ~/.platformio
3535
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
3636
- name: Set up Python
37-
uses: actions/setup-python@v2
37+
uses: actions/setup-python@v4
3838
- name: Install PlatformIO
3939
run: |
4040
python -m pip install --upgrade pip

src/MicroOcpp/Model/Authorization/AuthorizationService.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace MicroOcpp;
2424

2525
AuthorizationService::AuthorizationService(Context& context, std::shared_ptr<FilesystemAdapter> filesystem) : MemoryManaged("v16.Authorization.AuthorizationService"), context(context), filesystem(filesystem) {
2626

27-
localAuthListEnabledBool = declareConfiguration<bool>("LocalAuthListEnabled", true);
27+
localAuthListEnabledBool = declareConfiguration<bool>("LocalAuthListEnabled", true, CONFIGURATION_FN, false, true);
2828
declareConfiguration<int>("LocalAuthListMaxLength", MO_LocalAuthListMaxLength, CONFIGURATION_VOLATILE, true);
2929
declareConfiguration<int>("SendLocalListMaxLength", MO_SendLocalListMaxLength, CONFIGURATION_VOLATILE, true);
3030

@@ -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,7 +101,14 @@ 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) {
109+
//TC_043_3_CS-Send Local Authorization List - Failed
110+
//return false;
111+
105112
bool success = localAuthorizationList.readJson(localAuthorizationListJson, listVersion, differential, false);
106113

107114
if (success) {
@@ -127,7 +134,7 @@ bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson,
127134
void AuthorizationService::notifyAuthorization(const char *idTag, JsonObject idTagInfo) {
128135
//check local list conflicts. In future: also update authorization cache
129136

130-
if (!localAuthListEnabledBool->getBool()) {
137+
if (!localAuthListEnabled()) {
131138
return; //auth cache will follow
132139
}
133140

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)