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

Function createTestMiddleware

auth_jwt_redis_test.go:303–325  ·  view source on GitHub ↗
(redisAddr string)

Source from the content-addressed store, hash-verified

301}
302
303func createTestMiddleware(redisAddr string) *GinJWTMiddleware {
304 middleware := &GinJWTMiddleware{
305 Realm: "test zone",
306 Key: []byte("secret key"),
307 Timeout: time.Hour,
308 MaxRefresh: time.Hour * 24,
309 IdentityKey: "id",
310 Authenticator: testAuthenticator,
311 PayloadFunc: testPayloadFunc,
312 }
313
314 // Configure Redis using functional options
315 middleware.EnableRedisStore(
316 WithRedisAddr(redisAddr),
317 WithRedisCache(
318 1024*1024,
319 50*time.Millisecond,
320 ), // 1MB for testing, very short TTL for testing
321 WithRedisKeyPrefix("test-jwt:"),
322 )
323
324 return middleware
325}
326
327func testAuthenticator(c *gin.Context) (any, error) {
328 var loginVals struct {

Calls 4

EnableRedisStoreMethod · 0.95
WithRedisAddrFunction · 0.85
WithRedisCacheFunction · 0.85
WithRedisKeyPrefixFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…