(t *testing.T)
| 1400 | } |
| 1401 | |
| 1402 | func 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 | |
| 1432 | func TestSetCookie(t *testing.T) { |
| 1433 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected
searching dependent graphs…