invokeAsClient runs one /tunnel POST as the given clientID and returns the decoded downstream frames the server replied with.
(tb testing.TB, s *Server, c *frame.Crypto, clientID [frame.ClientIDLen]byte, frames []*frame.Frame)
| 196 | // invokeAsClient runs one /tunnel POST as the given clientID and returns the |
| 197 | // decoded downstream frames the server replied with. |
| 198 | func invokeAsClient(tb testing.TB, s *Server, c *frame.Crypto, clientID [frame.ClientIDLen]byte, frames []*frame.Frame) []*frame.Frame { |
| 199 | tb.Helper() |
| 200 | body, err := frame.EncodeBatch(c, clientID, frames) |
| 201 | if err != nil { |
| 202 | tb.Fatalf("encode: %v", err) |
| 203 | } |
| 204 | req := httptest.NewRequest(http.MethodPost, "/tunnel", bytes.NewReader(body)) |
| 205 | rec := httptest.NewRecorder() |
| 206 | s.handleTunnel(rec, req) |
| 207 | resp := rec.Result() |
| 208 | defer resp.Body.Close() |
| 209 | respBody, _ := io.ReadAll(resp.Body) |
| 210 | if len(respBody) == 0 { |
| 211 | return nil |
| 212 | } |
| 213 | _, out, err := frame.DecodeBatch(c, respBody) |
| 214 | if err != nil { |
| 215 | tb.Fatalf("decode response: %v", err) |
| 216 | } |
| 217 | return out |
| 218 | } |
| 219 | |
| 220 | // TestExit_MultiClient_SessionIsolation is the regression test for issue #23: |
| 221 | // when two clients share one server, neither should ever see the other's |
no test coverage detected