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

Function TestGinJWTMiddleware_RedisStore_Integration

auth_jwt_redis_test.go:45–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestGinJWTMiddleware_RedisStore_Integration(t *testing.T) {
46 gin.SetMode(gin.TestMode)
47
48 host, port := setupRedisContainerForJWT(t)
49
50 // Create middleware with Redis store
51 middleware := createTestMiddleware(fmt.Sprintf("%s:%s", host, port))
52
53 // Initialize middleware
54 err := middleware.MiddlewareInit()
55 require.NoError(t, err, "middleware initialization should not fail")
56
57 // Create test router
58 r := gin.New()
59 r.POST("/login", middleware.LoginHandler)
60 r.POST("/refresh", middleware.RefreshHandler)
61
62 auth := r.Group("/auth")
63 auth.Use(middleware.MiddlewareFunc())
64 {
65 auth.GET("/hello", func(c *gin.Context) {
66 c.JSON(200, gin.H{"message": "hello"})
67 })
68 }
69
70 t.Run("LoginAndRefreshWithRedis", func(t *testing.T) {
71 testLoginAndRefreshFlow(t, r)
72 })
73
74 t.Run("TokenPersistenceAcrossRequests", func(t *testing.T) {
75 testTokenPersistenceAcrossRequests(t, r)
76 })
77
78 t.Run("RedisStoreOperations", func(t *testing.T) {
79 testRedisStoreOperations(t, middleware)
80 })
81}
82
83func TestGinJWTMiddleware_RedisStoreFallback(t *testing.T) {
84 gin.SetMode(gin.TestMode)

Callers

nothing calls this directly

Calls 7

createTestMiddlewareFunction · 0.85
testLoginAndRefreshFlowFunction · 0.85
testRedisStoreOperationsFunction · 0.85
MiddlewareInitMethod · 0.80
MiddlewareFuncMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…