Skip to content

Commit

Permalink
Updated libocpp websocket dep (#984)
Browse files Browse the repository at this point in the history
* Updated libocpp websocket dep, updated generic interface pytest integration tests for the usecase of a non-sync 'connect'

Signed-off-by: AssemblyJohn <[email protected]>

* Added test cases for security profile upgrades and fallbacks for OCPP1.6

Signed-off-by: Piet Gömpel <[email protected]>

---------

Signed-off-by: AssemblyJohn <[email protected]>
Signed-off-by: Piet Gömpel <[email protected]>
Co-authored-by: Piet Gömpel <[email protected]>
  • Loading branch information
AssemblyJohn and Pietfried authored Dec 16, 2024
1 parent dee89f4 commit 0a79167
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ libevse-security:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: v0.22.0
git_tag: e7a37da3610e4cbf66dfbc58b9aa98fca2aa6cec
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
71 changes: 71 additions & 0 deletions tests/ocpp_tests/test_sets/ocpp16/ocpp_compliance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -239,6 +241,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

Expand Down
6 changes: 3 additions & 3 deletions tests/ocpp_tests/test_sets/ocpp201/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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"][
Expand All @@ -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

Expand Down

0 comments on commit 0a79167

Please sign in to comment.