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)
| 85 | // is account-scope-gated and would 403 a valid agent-scoped token — |
| 86 | // conflating credential validity with authorization.) |
| 87 | func 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 |
no test coverage detected