diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7fc6acd6..9d23daeb 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: 3.x - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: key: ${{ github.ref }} path: .cache @@ -101,14 +101,14 @@ jobs: steps: - uses: actions/checkout@v3 - name: Cache pip - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Cache PlatformIO - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.platformio key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} @@ -142,7 +142,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: 3.x - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: key: ${{ github.ref }} path: .cache @@ -194,7 +194,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: 3.x - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: key: ${{ github.ref }} path: .cache diff --git a/.github/workflows/pio.yml b/.github/workflows/pio.yml index ec777853..189351fd 100644 --- a/.github/workflows/pio.yml +++ b/.github/workflows/pio.yml @@ -20,21 +20,21 @@ jobs: example: [examples/ESP/main.cpp, examples/ESP-TLS/main.cpp] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache pip - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Cache PlatformIO - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.platformio key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 - name: Install PlatformIO run: | python -m pip install --upgrade pip diff --git a/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp b/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp index e9dc39d2..dc395ff9 100644 --- a/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp +++ b/src/MicroOcpp/Model/Authorization/AuthorizationService.cpp @@ -24,7 +24,7 @@ using namespace MicroOcpp; AuthorizationService::AuthorizationService(Context& context, std::shared_ptr filesystem) : MemoryManaged("v16.Authorization.AuthorizationService"), context(context), filesystem(filesystem) { - localAuthListEnabledBool = declareConfiguration("LocalAuthListEnabled", true); + localAuthListEnabledBool = declareConfiguration("LocalAuthListEnabled", true, CONFIGURATION_FN, false, true); declareConfiguration("LocalAuthListMaxLength", MO_LocalAuthListMaxLength, CONFIGURATION_VOLATILE, true); declareConfiguration("SendLocalListMaxLength", MO_SendLocalListMaxLength, CONFIGURATION_VOLATILE, true); @@ -75,7 +75,7 @@ bool AuthorizationService::loadLists() { } AuthorizationData *AuthorizationService::getLocalAuthorization(const char *idTag) { - if (!localAuthListEnabledBool->getBool()) { + if (!localAuthListEnabled()) { return nullptr; //auth cache will follow } @@ -101,7 +101,14 @@ size_t AuthorizationService::getLocalListSize() { return localAuthorizationList.size(); } +bool AuthorizationService::localAuthListEnabled() const { + return localAuthListEnabledBool && localAuthListEnabledBool->getBool(); +} + bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential) { + //TC_043_3_CS-Send Local Authorization List - Failed + //return false; + bool success = localAuthorizationList.readJson(localAuthorizationListJson, listVersion, differential, false); if (success) { @@ -127,7 +134,7 @@ bool AuthorizationService::updateLocalList(JsonArray localAuthorizationListJson, void AuthorizationService::notifyAuthorization(const char *idTag, JsonObject idTagInfo) { //check local list conflicts. In future: also update authorization cache - if (!localAuthListEnabledBool->getBool()) { + if (!localAuthListEnabled()) { return; //auth cache will follow } diff --git a/src/MicroOcpp/Model/Authorization/AuthorizationService.h b/src/MicroOcpp/Model/Authorization/AuthorizationService.h index 88ba7936..536bba1f 100644 --- a/src/MicroOcpp/Model/Authorization/AuthorizationService.h +++ b/src/MicroOcpp/Model/Authorization/AuthorizationService.h @@ -35,6 +35,7 @@ class AuthorizationService : public MemoryManaged { AuthorizationData *getLocalAuthorization(const char *idTag); int getLocalListVersion(); + bool localAuthListEnabled() const; size_t getLocalListSize(); //number of entries in current localAuthList; used in unit tests bool updateLocalList(JsonArray localAuthorizationListJson, int listVersion, bool differential); diff --git a/src/MicroOcpp/Model/Model.cpp b/src/MicroOcpp/Model/Model.cpp index f2e19c1e..fe59568f 100644 --- a/src/MicroOcpp/Model/Model.cpp +++ b/src/MicroOcpp/Model/Model.cpp @@ -317,7 +317,7 @@ void Model::updateSupportedStandardProfiles() { } #if MO_ENABLE_LOCAL_AUTH - if (authorizationService) { + if (authorizationService && authorizationService->localAuthListEnabled()) { if (!strstr(supportedFeatureProfilesString->getString(), "LocalAuthListManagement")) { if (!buf.empty()) buf += ','; buf += "LocalAuthListManagement"; diff --git a/src/MicroOcpp/Operations/GetLocalListVersion.cpp b/src/MicroOcpp/Operations/GetLocalListVersion.cpp index f2c8a058..4c2d4688 100644 --- a/src/MicroOcpp/Operations/GetLocalListVersion.cpp +++ b/src/MicroOcpp/Operations/GetLocalListVersion.cpp @@ -30,9 +30,11 @@ std::unique_ptr GetLocalListVersion::createConf(){ auto doc = makeJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1)); JsonObject payload = doc->to(); - if (auto authService = model.getAuthorizationService()) { + auto authService = model.getAuthorizationService(); + if (authService && authService->localAuthListEnabled()) { payload["listVersion"] = authService->getLocalListVersion(); } else { + //TC_042_1_CS Get Local List Version (not supported) payload["listVersion"] = -1; } return doc; diff --git a/src/MicroOcpp/Operations/SendLocalList.cpp b/src/MicroOcpp/Operations/SendLocalList.cpp index 45f0dfbe..29890024 100644 --- a/src/MicroOcpp/Operations/SendLocalList.cpp +++ b/src/MicroOcpp/Operations/SendLocalList.cpp @@ -27,6 +27,12 @@ const char* SendLocalList::getOperationType(){ void SendLocalList::processReq(JsonObject payload) { + //TC_043_1_CS Send Local Authorization List - NotSupported + if (!authService.localAuthListEnabled()) { + errorCode = "NotSupported"; + return; + } + if (!payload.containsKey("listVersion") || !payload.containsKey("updateType")) { errorCode = "FormationViolation"; return;