Added --http-upgrade and --direct to ws-test dial, so it can connect to job-search serve or ws-test serve
One of the two is required. --http-upgrade upgrades an HTTP connection to a WebSocket on /ws, as before, for job-search serve; --url and --origin go with it. --direct connects straight to ws-test serve over plain TCP, one JSON message per line, at --addr (default from server.host and server.port). --ping, --message, --listen and stdin work the same in both modes. The README's ws-test section explains the two modes.
This commit is contained in:
1 parent
88f879d844
commit
f0c171c8a8
5 files changed
+506
-60
No files matched your search
@@ -59,7 +59,7 @@ func TestDialPing(t *testing.T) {
|
||||
_, url := wsServer(t)
|
||||
|
||||
out := cmdtest.MustRun(
|
||||
t, newRoot, "dial", "--url", url, "--message", ping,
|
||||
t, newRoot, "dial", "--http-upgrade", "--url", url, "--message", ping,
|
||||
)
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
@@ -76,7 +76,7 @@ func TestDialPingFlag(t *testing.T) {
|
||||
cmdtest.Setup(t, "")
|
||||
_, url := wsServer(t)
|
||||
|
||||
out := cmdtest.MustRun(t, newRoot, "dial", "--url", url, "--ping")
|
||||
out := cmdtest.MustRun(t, newRoot, "dial", "--http-upgrade", "--url", url, "--ping")
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
out,
|
||||
@@ -111,7 +111,7 @@ func TestDialPingTimeout(t *testing.T) {
|
||||
t,
|
||||
newRoot,
|
||||
"",
|
||||
"dial", "--url", url, "--ping", "--timeout", "100ms",
|
||||
"dial", "--http-upgrade", "--url", url, "--ping", "--timeout", "100ms",
|
||||
)
|
||||
cmdtest.ErrContains(t, err, "no pong within 100ms")
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func TestDialMessages(t *testing.T) {
|
||||
out := cmdtest.MustRun(
|
||||
t,
|
||||
newRoot,
|
||||
"dial", "--url", url,
|
||||
"dial", "--http-upgrade", "--url", url,
|
||||
"--message", `{"type":"echo","id":"7","payload":{"a":1}}`,
|
||||
"--message", `{"type":"nonsense","id":"8"}`,
|
||||
)
|
||||
@@ -145,7 +145,7 @@ func TestDialOrigin(t *testing.T) {
|
||||
t,
|
||||
newRoot,
|
||||
"",
|
||||
"dial", "--url", url, "--message", ping,
|
||||
"dial", "--http-upgrade", "--url", url, "--message", ping,
|
||||
"--origin", "https://evil.example",
|
||||
)
|
||||
cmdtest.ErrContains(t, err, "upgrade refused: 403 Forbidden")
|
||||
@@ -153,7 +153,7 @@ func TestDialOrigin(t *testing.T) {
|
||||
out := cmdtest.MustRun(
|
||||
t,
|
||||
newRoot,
|
||||
"dial", "--url", url, "--message", ping,
|
||||
"dial", "--http-upgrade", "--url", url, "--message", ping,
|
||||
"--origin", "https://admin.example.com",
|
||||
)
|
||||
cmdtest.Contains(t, out, "connected (101 Switching Protocols)")
|
||||
|
||||
Reference in new issue
Block a user