fix(simulator): reject supervision URLs that break once the station identity is appended (#2168)
* fix(simulator): reject supervision URLs that break once the station identity is appended
The charging station dials the supervision URL with its identity appended.
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 (ENOTDIR). Reject both in SupervisionUrlSchema.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(utils): check the supervision URL schema against the URL the station dials
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* docs(readme): document the ws+unix supervision URL form
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(simulator): reject supervision URLs with a query string or an ambiguous ws+unix separator
The charging station identity is appended to the supervision URL, so after
a '?' it lands in the query (ws://h/ocpp?a=b dials /ocpp with query
'a=b/CS-1'). ws keeps only the first two ':'-separated parts of a ws+unix
pathname, so 'ws+unix:///s.sock:/oc:pp' dials /oc, and 'ws+unix:///:/ocpp'
dials the socket '/'. Reject these, checked against real TCP and Unix-socket
servers.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(utils): cover query strings and extra ws+unix separators in supervision URLs
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* docs(readme): document the query string and ws+unix separator rules for supervision URLs
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(simulator): 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 '/'.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(utils): cover one-character ws+unix socket paths and request paths without '/'
Regressions for the SupervisionUrlSchema 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.