MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / doHTTP

Function doHTTP

internal/ws/handler_test.go:115–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
115func 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

Callers 5

TestHandler_NoTokenFunction · 0.85
TestHandler_InvalidTokenFunction · 0.85
TestHandler_NotOwnerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected