From d7cf3c1f4bc6664c9e9f30acbb14ff8612eab178 Mon Sep 17 00:00:00 2001 From: AssemblyJohn Date: Thu, 5 Dec 2024 12:16:37 +0200 Subject: [PATCH 1/3] Updated libocpp websocket dep, updated generic interface pytest integration tests for the usecase of a non-sync 'connect' Signed-off-by: AssemblyJohn --- dependencies.yaml | 2 +- .../ocpp16/ocpp_generic_interface_integration_tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index ee0c284c8..c00b22706 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -67,7 +67,7 @@ libevse-security: # OCPP libocpp: git: https://github.com/EVerest/libocpp.git - git_tag: v0.22.0 + git_tag: 6ce05ae33cffa1e23d55680dddb995e868b91111 cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP" # Josev Josev: diff --git a/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py b/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py index 70c0594c2..65e38f516 100644 --- a/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py +++ b/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py @@ -239,6 +239,7 @@ async def test_command_restart(self, _env): await asyncio.sleep(5) assert not csms_connection.is_connected res = await _env.probe_module.call_command("ocpp", "restart", None) + await asyncio.sleep(5) assert res is True assert csms_connection.is_connected From 39062c5887f5e04d25ad97d37f14a9369a32af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piet=20G=C3=B6mpel?= Date: Fri, 6 Dec 2024 12:08:27 +0100 Subject: [PATCH 2/3] Added test cases for security profile upgrades and fallbacks for OCPP1.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piet Gömpel --- .../test_sets/ocpp16/ocpp_compliance_tests.py | 71 +++++++++++++++++++ ...cpp_generic_interface_integration_tests.py | 4 +- .../ocpp_tests/test_sets/ocpp201/security.py | 6 +- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/tests/ocpp_tests/test_sets/ocpp16/ocpp_compliance_tests.py b/tests/ocpp_tests/test_sets/ocpp16/ocpp_compliance_tests.py index 5bb305bd6..41c041698 100755 --- a/tests/ocpp_tests/test_sets/ocpp16/ocpp_compliance_tests.py +++ b/tests/ocpp_tests/test_sets/ocpp16/ocpp_compliance_tests.py @@ -6230,6 +6230,77 @@ async def test_chargepoint_update_http_auth_key( assert len(response.configuration_key) > 20 +@pytest.mark.asyncio +@pytest.mark.ocpp_config_adaptions( + GenericOCPP16ConfigAdjustment([("Security", "SecurityProfile", 0)]) +) +async def test_chargepoint_update_security_profile( + central_system_v16: CentralSystem, + charge_point_v16: ChargePoint16, + test_utility: TestUtility, +): + logging.info("######### test_chargepoint_update_security_profile #########") + + await charge_point_v16.change_configuration_req(key="SecurityProfile", value="1") + # expect ChangeConfiguration.conf with status Accepted + assert await wait_for_and_validate( + test_utility, + charge_point_v16, + "ChangeConfiguration", + call_result.ChangeConfigurationPayload(ConfigurationStatus.accepted), + ) + + # wait for reconnect + await central_system_v16.wait_for_chargepoint(wait_for_bootnotification=False) + + charge_point_v16 = central_system_v16.chargepoint + test_utility = TestUtility() + + response = await charge_point_v16.get_configuration_req(key=["SecurityProfile"]) + + assert response.configuration_key[0]["key"] == "SecurityProfile" + assert response.configuration_key[0]["value"] == "1" + + +@pytest.mark.asyncio +@pytest.mark.ocpp_config_adaptions( + GenericOCPP16ConfigAdjustment( + [ + ("Internal", "RetryBackoffRandomRange", 1), + ("Internal", "RetryBackoffWaitMinimum", 2), + ] + ) +) +async def test_chargepoint_update_security_profile_fallback( + central_system_v16: CentralSystem, + charge_point_v16: ChargePoint16, + test_utility: TestUtility, +): + logging.info( + "######### test_chargepoint_update_security_profile_fallback #########" + ) + + await charge_point_v16.change_configuration_req(key="SecurityProfile", value="2") + # expect ChangeConfiguration.conf with status Accepted + assert await wait_for_and_validate( + test_utility, + charge_point_v16, + "ChangeConfiguration", + call_result.ChangeConfigurationPayload(ConfigurationStatus.accepted), + ) + + # wait for reconnect + await central_system_v16.wait_for_chargepoint(wait_for_bootnotification=False) + + charge_point_v16 = central_system_v16.chargepoint + test_utility = TestUtility() + + response = await charge_point_v16.get_configuration_req(key=["SecurityProfile"]) + + assert response.configuration_key[0]["key"] == "SecurityProfile" + assert response.configuration_key[0]["value"] == "0" + + @pytest.mark.everest_core_config( get_everest_config_path_str("everest-config-security-profile-2.yaml") ) diff --git a/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py b/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py index 65e38f516..f78ab7757 100644 --- a/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py +++ b/tests/ocpp_tests/test_sets/ocpp16/ocpp_generic_interface_integration_tests.py @@ -168,7 +168,9 @@ def _add_pm_command_mock(implementation_id, command, value, skip_implementation) "reservation", "cancel_reservation", "Accepted", skip_implementation ) _add_pm_command_mock("reservation", "reserve_now", False, skip_implementation) - _add_pm_command_mock("reservation", "exists_reservation", False, skip_implementation) + _add_pm_command_mock( + "reservation", "exists_reservation", False, skip_implementation + ) _add_pm_command_mock("system", "get_boot_reason", "PowerUp", skip_implementation) _add_pm_command_mock("system", "update_firmware", "Accepted", skip_implementation) _add_pm_command_mock( diff --git a/tests/ocpp_tests/test_sets/ocpp201/security.py b/tests/ocpp_tests/test_sets/ocpp201/security.py index ebccf7e7d..b1199c2f1 100644 --- a/tests/ocpp_tests/test_sets/ocpp201/security.py +++ b/tests/ocpp_tests/test_sets/ocpp201/security.py @@ -760,7 +760,7 @@ async def test_A02_use_newest_certificate_according_to_validity( Path(__file__).parent / "../everest-aux/certs/ca/csms/CSMS_ROOT_CA.pem" ) ca_key = Path(__file__).parent / "../everest-aux/certs/ca/csms/CSMS_ROOT_CA.key" - ca_passphrase = "123456" # nosec bandit B105 + ca_passphrase = "123456" # nosec bandit B105 # Install 3 certificates; the second is newest w.r.t. validity (shortest relative shift from now to the past) certificates = {} @@ -863,7 +863,7 @@ async def test_A03_install_new_if_expired( ca_key = ( Path(__file__).parent / "../everest-aux/certs/ca/csms/CSMS_ROOT_CA.key" ) - ca_passphrase = "123456" # nosec bandit B10 + ca_passphrase = "123456" # nosec bandit B10 else: cert_directory = Path( everest_core.everest_config["active_modules"]["evse_security"][ @@ -883,7 +883,7 @@ async def test_A03_install_new_if_expired( Path(__file__).parent / "../everest-aux/certs/client/csms/CPO_SUB_CA2.key" ) - ca_passphrase = "123456" # nosec bandit B105 + ca_passphrase = "123456" # nosec bandit B105 # Remove old certificates From 37df588f0772e016f2cf6e8d6537b54117d29bb6 Mon Sep 17 00:00:00 2001 From: AssemblyJohn Date: Fri, 13 Dec 2024 14:37:14 +0200 Subject: [PATCH 3/3] Update new libocpp version Signed-off-by: AssemblyJohn --- dependencies.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index c00b22706..c93b37133 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -67,7 +67,7 @@ libevse-security: # OCPP libocpp: git: https://github.com/EVerest/libocpp.git - git_tag: 6ce05ae33cffa1e23d55680dddb995e868b91111 + git_tag: e7a37da3610e4cbf66dfbc58b9aa98fca2aa6cec cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP" # Josev Josev: