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

Function TestExpiredTokenOnRefreshHandler

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

Source from the content-addressed store, hash-verified

657}
658
659func TestExpiredTokenOnRefreshHandler(t *testing.T) {
660 // the middleware to test
661 authMiddleware, _ := New(&GinJWTMiddleware{
662 Realm: "test zone",
663 Key: key,
664 Timeout: time.Hour,
665 RefreshTokenTimeout: time.Millisecond, // Very short refresh token timeout
666 Authenticator: defaultAuthenticator,
667 })
668
669 handler := ginHandler(authMiddleware)
670
671 r := gofight.New()
672
673 // Get a refresh token and wait for it to expire
674 refreshToken := getRefreshTokenFromLogin(handler)
675 if refreshToken != "" {
676 // Wait for the refresh token to expire
677 time.Sleep(2 * time.Millisecond)
678
679 r.POST("/auth/refresh_token").
680 SetJSON(gofight.D{
681 "refresh_token": refreshToken,
682 }).
683 Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
684 assert.Equal(t, http.StatusUnauthorized, r.Code)
685 })
686 }
687}
688
689func TestAuthorizer(t *testing.T) {
690 // 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…