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

Function TestHTTP_Authorize_WithSession

internal/agent/oauth_consent_test.go:244–265  ·  view source on GitHub ↗

TestHTTP_Authorize_WithSession redirects to {publicURL}/oauth/consent preserving every authorize parameter so the consent page can hidden- field them back into its POST.

(t *testing.T)

Source from the content-addressed store, hash-verified

242// preserving every authorize parameter so the consent page can hidden-
243// field them back into its POST.
244func TestHTTP_Authorize_WithSession(t *testing.T) {
245 f := newConsentFixture(t)
246 _, challenge := newPKCE(t)
247 q := authorizeParams(challenge, f.clientID, "s1s1s1s1s1s1s1s1")
248 resp := f.authorizeRequest(t, q, true)
249 defer resp.Body.Close()
250 if resp.StatusCode != http.StatusFound {
251 t.Fatalf("status = %d, want 302", resp.StatusCode)
252 }
253 loc, err := url.Parse(resp.Header.Get("Location"))
254 if err != nil {
255 t.Fatalf("Location parse: %v", err)
256 }
257 if !strings.HasSuffix(loc.Path, "/oauth/consent") {
258 t.Errorf("Location path = %q, want /oauth/consent", loc.Path)
259 }
260 for _, key := range []string{"response_type", "client_id", "redirect_uri", "scope", "state", "code_challenge", "code_challenge_method"} {
261 if got, want := loc.Query().Get(key), q.Get(key); got != want {
262 t.Errorf("consent redirect missing/wrong %q: got %q, want %q", key, got, want)
263 }
264 }
265}
266
267// TestHTTP_Authorize_InvalidClient — fosite rejects before we get a
268// chance to check the session. The response is a fosite-emitted

Callers

nothing calls this directly

Calls 7

newConsentFixtureFunction · 0.85
newPKCEFunction · 0.85
authorizeParamsFunction · 0.85
authorizeRequestMethod · 0.80
QueryMethod · 0.80
GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected