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

Function callAPIWithBearer

internal/agent/oauth_bearer_test.go:87–99  ·  view source on GitHub ↗

callAPIWithBearer hits /v1/account with the given Authorization value. Returns the status code and the WWW-Authenticate header. v1/account is the right validity probe because it authenticates with requirePrincipal — i.e. it returns 200 for ANY valid credential regardless of scope (account OR agent),

(t *testing.T, serverURL, bearer string)

Source from the content-addressed store, hash-verified

85// is account-scope-gated and would 403 a valid agent-scoped token —
86// conflating credential validity with authorization.)
87func callAPIWithBearer(t *testing.T, serverURL, bearer string) (int, string) {
88 t.Helper()
89 req, _ := http.NewRequest("GET", serverURL+"/v1/account", nil)
90 if bearer != "" {
91 req.Header.Set("Authorization", "Bearer "+bearer)
92 }
93 resp, err := http.DefaultClient.Do(req)
94 if err != nil {
95 t.Fatal(err)
96 }
97 defer resp.Body.Close()
98 return resp.StatusCode, resp.Header.Get("WWW-Authenticate")
99}
100
101// ──────────────────────── Bearer dispatch tests ────────────────────────
102

Calls 2

GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected