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

Function TestHandleCallback_NonceMismatch_Rejected

internal/auth/cli_login_test.go:361–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

359}
360
361func TestHandleCallback_NonceMismatch_Rejected(t *testing.T) {
362 ua, _, srv := setupUserAuthWithFakeOAuth(t)
363
364 state := auth.EncodeOAuthState(&auth.OAuthState{
365 Nonce: "correct-nonce",
366 CLICallback: "http://127.0.0.1:43123/callback",
367 CLIState: "cli_state_abc",
368 })
369
370 req := httptest.NewRequest(
371 http.MethodGet,
372 fmt.Sprintf("/api/auth/callback?code=fake-code&state=%s", url.QueryEscape(state)),
373 nil,
374 )
375 req.AddCookie(&http.Cookie{Name: "e2a_oauth_state", Value: "wrong-nonce"})
376 _ = srv
377 w := httptest.NewRecorder()
378
379 ua.HandleCallback(w, req)
380
381 if w.Code != http.StatusBadRequest {
382 t.Fatalf("status = %d, want %d", w.Code, http.StatusBadRequest)
383 }
384}
385
386func TestHandleCallback_InvalidState_Rejected(t *testing.T) {
387 ua, _, srv := setupUserAuthWithFakeOAuth(t)

Callers

nothing calls this directly

Calls 3

EncodeOAuthStateFunction · 0.92
HandleCallbackMethod · 0.80

Tested by

no test coverage detected