MCPcopy
hub / github.com/appleboy/gin-jwt / TestLogout

Function TestLogout

auth_jwt_test.go:1402–1430  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1400}
1401
1402func TestLogout(t *testing.T) {
1403 cookieName := testJWT
1404 cookieDomain := "example.com"
1405 // the middleware to test
1406 authMiddleware, _ := New(&GinJWTMiddleware{
1407 Realm: "test zone",
1408 Key: key,
1409 Timeout: time.Hour,
1410 Authenticator: defaultAuthenticator,
1411 SendCookie: true,
1412 CookieName: cookieName,
1413 CookieDomain: cookieDomain,
1414 })
1415
1416 handler := ginHandler(authMiddleware)
1417
1418 r := gofight.New()
1419
1420 r.POST("/logout").
1421 Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
1422 assert.Equal(t, http.StatusOK, r.Code)
1423 //nolint:staticcheck
1424 assert.Equal(
1425 t,
1426 fmt.Sprintf("%s=; Path=/; Domain=%s; Max-Age=0", cookieName, cookieDomain),
1427 r.HeaderMap.Get("Set-Cookie"),
1428 )
1429 })
1430}
1431
1432func TestSetCookie(t *testing.T) {
1433 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
ginHandlerFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…