doHTTP does a plain HTTP GET (no upgrade) to the WS endpoint, sending the credential (when non-empty) as an Authorization: Bearer header.
(t *testing.T, srv *httptest.Server, email, token string)
| 113 | // doHTTP does a plain HTTP GET (no upgrade) to the WS endpoint, sending the |
| 114 | // credential (when non-empty) as an Authorization: Bearer header. |
| 115 | func doHTTP(t *testing.T, srv *httptest.Server, email, token string) *http.Response { |
| 116 | t.Helper() |
| 117 | url := fmt.Sprintf("%s/api/v1/agents/%s/ws", srv.URL, email) |
| 118 | req, err := http.NewRequest(http.MethodGet, url, nil) |
| 119 | if err != nil { |
| 120 | t.Fatalf("new request: %v", err) |
| 121 | } |
| 122 | if token != "" { |
| 123 | req.Header.Set("Authorization", "Bearer "+token) |
| 124 | } |
| 125 | resp, err := http.DefaultClient.Do(req) |
| 126 | if err != nil { |
| 127 | t.Fatalf("HTTP GET failed: %v", err) |
| 128 | } |
| 129 | return resp |
| 130 | } |
| 131 | |
| 132 | // ── Tests ─────────────────────────────────────────────────────── |
| 133 |
no outgoing calls
no test coverage detected