(t *testing.T)
| 456 | } |
| 457 | |
| 458 | func 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 | } |
nothing calls this directly
no test coverage detected