MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestApiRequest_AuthForwarding

Function TestApiRequest_AuthForwarding

backend/api/mcp/tool_http_test.go:32–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestApiRequest_AuthForwarding(t *testing.T) {
33 var capturedAuth string
34 s := newTestServerWithMock(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
35 capturedAuth = r.Header.Get("Authorization")
36 w.WriteHeader(http.StatusOK)
37 fmt.Fprint(w, `{}`)
38 }))
39
40 ctx := withAccessToken(context.Background(), "test-token-123")
41 resp, err := s.apiRequest(ctx, "/api/test", nil)
42 require.NoError(t, err)
43 require.Equal(t, http.StatusOK, resp.Status)
44 require.Equal(t, "Bearer test-token-123", capturedAuth)
45}
46
47func TestApiRequest_ErrorParsing(t *testing.T) {
48 s := newTestServerWithMock(t, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {

Callers

nothing calls this directly

Calls 5

newTestServerWithMockFunction · 0.85
withAccessTokenFunction · 0.85
GetMethod · 0.80
apiRequestMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected