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

Function TestValidRefreshToken

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

Source from the content-addressed store, hash-verified

629}
630
631func TestValidRefreshToken(t *testing.T) {
632 // the middleware to test
633 authMiddleware, _ := New(&GinJWTMiddleware{
634 Realm: "test zone",
635 Key: key,
636 Timeout: time.Hour,
637 MaxRefresh: 2 * time.Hour,
638 RefreshTokenTimeout: 24 * time.Hour, // Long refresh token timeout
639 Authenticator: defaultAuthenticator,
640 })
641
642 handler := ginHandler(authMiddleware)
643
644 r := gofight.New()
645
646 // Test that a valid refresh token still works
647 refreshToken := getRefreshTokenFromLogin(handler)
648 if refreshToken != "" {
649 r.POST("/auth/refresh_token").
650 SetJSON(gofight.D{
651 "refresh_token": refreshToken,
652 }).
653 Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
654 assert.Equal(t, http.StatusOK, r.Code)
655 })
656 }
657}
658
659func TestExpiredTokenOnRefreshHandler(t *testing.T) {
660 // the middleware to test

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
ginHandlerFunction · 0.85
getRefreshTokenFromLoginFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…