]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(simulator): encode station identity in WebSocket connection URL (#2177)
authorVitor Coelho <6161176+VitorCoelho@users.noreply.github.com>
Sat, 31 Oct 2026 13:44:31 +0000 (13:44 +0000)
committerGitHub <noreply@github.com>
Sat, 31 Oct 2026 13:44:31 +0000 (13:44 +0000)
commit02009d08eb4be9d1ace5a6b6e16c1f85e1eb6d00
tree96476537913171f9fb28eadb612b29584a0cb25c
parent298b84696af5d7e6e9845733d4a9882145bfa7fa
fix(simulator): encode station identity in WebSocket connection URL (#2177)

* fix(charging-station): percent-encode the station identity in the supervision connection URL

ChargingStation.wsConnectionUrl appended the raw chargingStationId to the
supervision URL, so a reserved character in the identity became URL syntax:
'FRESH#1' turned into the fragment '#1' (ws throws 'The URL contains a
fragment identifier'), 'A?B' into a query and 'A/B' into two path segments.
OCPP-J 1.6 section 3.1.1 requires the identity to be percent-encoded as per
RFC 3986. Encode it with encodeURIComponent when composing the connection
URL only; the raw identity is unchanged everywhere else.

Closes #2176

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(charging-station): cover station identity encoding in the supervision connection URL

Exercise ChargingStation.wsConnectionUrl with identities holding reserved
characters (' ', '%', '/', '?', '#'), through the station info and the OCPP
configuration key paths, and against real TCP and Unix socket WebSocket
servers that must observe a single encoded path segment.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ui-web): strip the percent-encoded station identity from the supervision URL

The connection URL published to the UI now ends with the identity encoded
as one path segment, but stripStationId only matched the raw '/<id>'
suffix. SetSupervisionUrlDialog therefore prefilled the full connection
URL as the base URL and a save without editing it (for example a
credentials-only update) stored that as the base and appended the
identity again ('/OCPP16/CS%2B1/CS%2B1').

Match the encoded suffix first and keep the raw one for URLs composed
without encoding.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ui-web): cover the supervision URL prefill with an encoded identity

Prefill for 'CS+1', 'CS@1', 'CS 1' and 'FRESH#1', and a credentials-only
save that must resend the base URL unchanged.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(charging-station): skip the Unix socket identity test on Windows

On Windows the socket path is not a listenable filesystem path
('listen EACCES'), which failed the simulator CI job. Only the Unix
transport case is skipped on win32; the TCP case still runs everywhere.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(charging-station): delete the stations created by the identity encoding tests

The test file built real ChargingStation instances and never deleted
them, so their BroadcastChannels stayed open and the file only finished
because the CI runner forces exit. Each test now records the stations it
creates and afterEach awaits station.delete(false) for each of them
before the templates are removed. Without --test-force-exit the file
now exits on its own.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
---------

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
src/charging-station/ChargingStation.ts
tests/charging-station/ChargingStation-WsConnectionUrlIdentity.test.ts [new file with mode: 0644]
ui/web/src/shared/utils/stripStationId.ts
ui/web/tests/unit/skins/modern/Dialogs.test.ts