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.