fix(ocpp): reject a supervision URL key value the ws client cannot dial in OCPP 1.6 ChangeConfiguration (#2159)
* Add validation for supervision URL in OCPP16 service
Reject invalid supervision URL values to prevent reconnect failures.
* Add tests for supervision URL OCPP configuration key
* fix(ocpp): also reject supervision URL schemes the ws client cannot dial
URL.canParse accepted values such as ftp://host, which were stored
and then failed on reconnect. Accept only the schemes the ws client
dials: ws, wss, http, https and ws+unix.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject a supervision URL with a fragment or an empty ws+unix socket path
The ws client throws for a URL with a fragment identifier and for a
ws+unix URL without a pathname, so OCPP 1.6 ChangeConfiguration accepted
and stored values that fail on reconnect. Reject them.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover fragments and ws+unix socket paths in OCPP 1.6 ChangeConfiguration
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject an empty fragment and a ws+unix URL without a request path separator
The charging station appends its identity to the supervision URL. After a
trailing '#' the identity becomes a fragment, which the ws client rejects,
and a ws+unix URL without a ':' between the socket path and the request
path gets the identity appended to the socket path, so the connection
fails. Reject both in the OCPP 1.6 ChangeConfiguration guard.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover an empty fragment and ws+unix URLs without a request path separator
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject supervision URL key values with whitespace, a query string or an ambiguous ws+unix separator
The OCPP 1.6 ChangeConfiguration value is stored as sent, but the guard
validated the parsed URL, which strips surrounding whitespace, tabs and
newlines, so 'ws://localhost:8888 ' was accepted and the reconnect then
failed. The station identity is appended to the URL, so after a '?' it
lands in the query, and ws keeps only the first two ':'-separated parts
of a ws+unix pathname. Reject these; the query and ws+unix rules match
SupervisionUrlSchema.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover whitespace, query strings and ws+unix separators in the supervision URL key
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): accept one-character ws+unix socket paths and require a '/' request path
A relative socket path such as 's' in 'ws+unix:s:/OCPP16' is valid, so
require a socket path other than '/' instead of two characters. A request
path without a leading '/' (ws+unix:s:OCPP16) makes the server answer 400,
so require it to be empty or to start with '/'. Same rule as
SupervisionUrlSchema in #2168.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover one-character ws+unix socket paths and request paths without '/'
Regressions for the supervision URL key fix: 'ws+unix:s:/OCPP16' and
'ws+unix:./s:/OCPP16' are accepted, 'ws+unix:s:OCPP16' and
'ws+unix:///tmp/simulator.sock:OCPP16' are rejected.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* refactor(ocpp): validate the supervision URL key with the shared SupervisionUrlSchema
The OCPP 1.6 ChangeConfiguration guard duplicated the supervision endpoint
policy (schemes, '#' and '?' delimiters, ws+unix socket and request path)
that SupervisionUrlSchema owns since #2160 and #2168. Consume the shared
schema and keep only the OCPP-specific part locally: the key stores the raw
value, so whitespace and control characters are rejected before the schema
check, which would otherwise strip them. Accepted values are still stored
verbatim. No behaviour change.