MCPcopy
hub / github.com/yusing/godoxy / TestLogoutHandler

Function TestLogoutHandler

internal/auth/oidc_test.go:458–488  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

456}
457
458func TestLogoutHandler(t *testing.T) {
459 t.Helper()
460
461 setupMockOIDC(t)
462
463 req := httptest.NewRequest(http.MethodGet, OIDCLogoutPath, nil)
464 w := httptest.NewRecorder()
465
466 req.AddCookie(&http.Cookie{
467 Name: CookieOauthToken,
468 Value: "test-token",
469 })
470 req.AddCookie(&http.Cookie{
471 Name: CookieOauthSessionToken,
472 Value: "test-session-token",
473 })
474
475 defaultAuth.(*OIDCProvider).LogoutHandler(w, req)
476
477 if got := w.Code; got != http.StatusFound {
478 t.Errorf("LogoutHandler() status = %v, want %v", got, http.StatusFound)
479 }
480
481 if got := w.Header().Get("Location"); got == "" {
482 t.Error("LogoutHandler() missing redirect location")
483 }
484
485 if len(w.Header().Values("Set-Cookie")) != 2 {
486 t.Error("LogoutHandler() did not clear all cookies")
487 }
488}

Callers

nothing calls this directly

Calls 5

setupMockOIDCFunction · 0.85
LogoutHandlerMethod · 0.65
GetMethod · 0.65
HeaderMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected